mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
init
This commit is contained in:
56
providers/hiAnime/HiGetSteam.ts
Normal file
56
providers/hiAnime/HiGetSteam.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import {Stream, ProviderContext, TextTracks, TextTrackType} from '../types';
|
||||
|
||||
export const hiGetStream = async function ({
|
||||
link: id,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
try {
|
||||
const {getBaseUrl, axios} = providerContext;
|
||||
const baseUrl = await getBaseUrl('consumet');
|
||||
const servers = ['vidcloud', 'vidstreaming'];
|
||||
const url = `${baseUrl}/anime/zoro/watch?episodeId=${id}&server=`;
|
||||
const streamLinks: Stream[] = [];
|
||||
await Promise.all(
|
||||
servers.map(async server => {
|
||||
try {
|
||||
const res = await axios.get(url + server);
|
||||
if (res.data) {
|
||||
const subtitles: TextTracks = [];
|
||||
res.data?.subtitles.forEach((sub: any) => {
|
||||
if (sub?.lang === 'Thumbnails') return;
|
||||
subtitles.push({
|
||||
language: sub?.lang?.slice(0, 2) || 'Und',
|
||||
uri: sub?.url,
|
||||
title: sub?.lang || 'Undefined',
|
||||
type: sub?.url?.endsWith('.vtt')
|
||||
? TextTrackType.VTT
|
||||
: TextTrackType.SUBRIP,
|
||||
});
|
||||
});
|
||||
res.data?.sources.forEach((source: any) => {
|
||||
streamLinks.push({
|
||||
server: server,
|
||||
link: source?.url,
|
||||
type: source?.isM3U8 ? 'm3u8' : 'mp4',
|
||||
headers: {
|
||||
Referer: 'https://megacloud.club/',
|
||||
Origin: 'https://megacloud.club',
|
||||
},
|
||||
subtitles: subtitles,
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}),
|
||||
);
|
||||
return streamLinks;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
20
providers/hiAnime/hiCatalog.ts
Normal file
20
providers/hiAnime/hiCatalog.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export const hiCatalog = [
|
||||
{
|
||||
title: 'Recent',
|
||||
filter: '/anime/zoro/recent-episodes',
|
||||
},
|
||||
{
|
||||
title: 'Top Airing',
|
||||
filter: '/anime/zoro/top-airing',
|
||||
},
|
||||
{
|
||||
title: 'Most Popular',
|
||||
filter: '/anime/zoro/most-popular',
|
||||
},
|
||||
{
|
||||
title: 'Most Favorited',
|
||||
filter: '/anime/zoro/most-favorite',
|
||||
},
|
||||
];
|
||||
|
||||
export const hiGenresList = [];
|
||||
83
providers/hiAnime/hiGetInfo.ts
Normal file
83
providers/hiAnime/hiGetInfo.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import {Info, Link, ProviderContext} from '../types';
|
||||
|
||||
export const hiGetInfo = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
try {
|
||||
const {getBaseUrl, axios} = providerContext;
|
||||
const baseUrl = await getBaseUrl('consumet');
|
||||
const url = `${baseUrl}/anime/zoro/info?id=` + link;
|
||||
const res = await axios.get(url);
|
||||
const data = res.data;
|
||||
const meta = {
|
||||
title: data.title,
|
||||
synopsis: data.description,
|
||||
image: data.image,
|
||||
tags: [
|
||||
data?.type,
|
||||
data?.subOrDub === 'both' ? 'Sub And Dub' : data?.subOrDub,
|
||||
],
|
||||
imdbId: '',
|
||||
type: data.episodes.length > 0 ? 'series' : 'movie',
|
||||
};
|
||||
const linkList: Link[] = [];
|
||||
const subLinks: Link['directLinks'] = [];
|
||||
data.episodes.forEach((episode: any) => {
|
||||
if (!episode?.isSubbed) {
|
||||
return;
|
||||
}
|
||||
const title =
|
||||
'Episode ' + episode.number + (episode?.isFiller ? ' (Filler)' : '');
|
||||
const link = episode.id + '$sub';
|
||||
if (link && title) {
|
||||
subLinks.push({
|
||||
title,
|
||||
link,
|
||||
});
|
||||
}
|
||||
});
|
||||
linkList.push({
|
||||
title: meta.title + ' (Sub)',
|
||||
directLinks: subLinks,
|
||||
});
|
||||
if (data?.subOrDub === 'both') {
|
||||
const dubLinks: Link['directLinks'] = [];
|
||||
data.episodes.forEach((episode: any) => {
|
||||
if (!episode?.isDubbed) {
|
||||
return;
|
||||
}
|
||||
const title =
|
||||
'Episode ' + episode.number + (episode?.isFiller ? ' (Filler)' : '');
|
||||
const link = episode.id + '$dub';
|
||||
if (link && title) {
|
||||
dubLinks.push({
|
||||
title,
|
||||
link,
|
||||
});
|
||||
}
|
||||
});
|
||||
linkList.push({
|
||||
title: meta.title + ' (Dub)',
|
||||
directLinks: dubLinks,
|
||||
});
|
||||
}
|
||||
return {
|
||||
...meta,
|
||||
linkList: linkList,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return {
|
||||
title: '',
|
||||
synopsis: '',
|
||||
image: '',
|
||||
imdbId: '',
|
||||
type: 'movie',
|
||||
linkList: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
69
providers/hiAnime/hiGetPosts.ts
Normal file
69
providers/hiAnime/hiGetPosts.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import {Post, ProviderContext} from '../types';
|
||||
|
||||
export const hiGetPosts = async function ({
|
||||
filter,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
filter: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl, axios} = providerContext;
|
||||
const baseUrl = await getBaseUrl('consumet');
|
||||
const url = `${baseUrl + filter}?page=${page}`;
|
||||
return posts({url, signal, axios});
|
||||
};
|
||||
|
||||
export const hiGetPostsSearch = async function ({
|
||||
searchQuery,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
searchQuery: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl, axios} = providerContext;
|
||||
const baseUrl = await getBaseUrl('consumet');
|
||||
const url = `${baseUrl}/anime/zoro/${searchQuery}?page=${page}`;
|
||||
return posts({url, signal, axios});
|
||||
};
|
||||
|
||||
async function posts({
|
||||
url,
|
||||
signal,
|
||||
axios,
|
||||
}: {
|
||||
url: string;
|
||||
signal: AbortSignal;
|
||||
axios: ProviderContext['axios'];
|
||||
}): Promise<Post[]> {
|
||||
try {
|
||||
const res = await axios.get(url, {signal});
|
||||
const data = res.data?.results;
|
||||
const catalog: Post[] = [];
|
||||
data?.map((element: any) => {
|
||||
const title = element.title;
|
||||
const link = element.id;
|
||||
const image = element.image;
|
||||
if (title && link && image) {
|
||||
catalog.push({
|
||||
title: title,
|
||||
link: link,
|
||||
image: image,
|
||||
});
|
||||
}
|
||||
});
|
||||
return catalog;
|
||||
} catch (err) {
|
||||
console.error('zoro error ', err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
14
providers/hiAnime/index.ts
Normal file
14
providers/hiAnime/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import {hiGetInfo} from './hiGetInfo';
|
||||
import {hiCatalog, hiGenresList} from './hiCatalog';
|
||||
import {hiGetStream} from './HiGetSteam';
|
||||
import {hiGetPosts, hiGetPostsSearch} from './hiGetPosts';
|
||||
import {ProviderType} from '../types';
|
||||
|
||||
export const HiAnime: ProviderType = {
|
||||
catalog: hiCatalog,
|
||||
genres: hiGenresList,
|
||||
GetMetaData: hiGetInfo,
|
||||
GetHomePosts: hiGetPosts,
|
||||
GetStream: hiGetStream,
|
||||
GetSearchPosts: hiGetPostsSearch,
|
||||
};
|
||||
Reference in New Issue
Block a user