mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
init
This commit is contained in:
14
providers/kissKh/index.ts
Normal file
14
providers/kissKh/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import {kisskhCatalog, kisskhGenresList} from './kissKhCatalog';
|
||||
import {kissKhGetInfo} from './kissKhGetInfo';
|
||||
import {kissKhGetPosts, kissKhGetPostsSearch} from './kissKhGetPosts';
|
||||
import {kissKhGetStream} from './kissKhGetStream';
|
||||
import {ProviderType} from '../types';
|
||||
|
||||
export const kissKhProvider: ProviderType = {
|
||||
catalog: kisskhCatalog,
|
||||
genres: kisskhGenresList,
|
||||
GetHomePosts: kissKhGetPosts,
|
||||
GetMetaData: kissKhGetInfo,
|
||||
GetStream: kissKhGetStream,
|
||||
GetSearchPosts: kissKhGetPostsSearch,
|
||||
};
|
||||
20
providers/kissKh/kissKhCatalog.ts
Normal file
20
providers/kissKh/kissKhCatalog.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export const kisskhCatalog = [
|
||||
{
|
||||
title: 'Latest',
|
||||
filter: '/api/DramaList/List?type=0&sub=0&country=0&status=0&order=2',
|
||||
},
|
||||
{
|
||||
title: 'Hollywood',
|
||||
filter: '/api/DramaList/List?type=4&sub=0&country=0&status=0&order=2',
|
||||
},
|
||||
{
|
||||
title: 'Anime',
|
||||
filter: '/api/DramaList/List?type=3&sub=0&country=0&status=0&order=2',
|
||||
},
|
||||
{
|
||||
title: 'K Drama',
|
||||
filter: '/api/DramaList/List?type=0&sub=0&country=0&status=0&order=2',
|
||||
},
|
||||
];
|
||||
|
||||
export const kisskhGenresList = [];
|
||||
57
providers/kissKh/kissKhGetInfo.ts
Normal file
57
providers/kissKh/kissKhGetInfo.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import {Info, Link, ProviderContext} from '../types';
|
||||
|
||||
export const kissKhGetInfo = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
try {
|
||||
const {axios} = providerContext;
|
||||
const res = await axios.get(link);
|
||||
const data = res.data;
|
||||
const meta = {
|
||||
title: data.title,
|
||||
synopsis: data.description,
|
||||
image: data.thumbnail,
|
||||
tags: [data?.releaseDate?.split('-')[0], data?.status, data?.type],
|
||||
imdbId: '',
|
||||
type: data.episodesCount > 1 ? 'series' : 'movie',
|
||||
};
|
||||
|
||||
const linkList: Link[] = [];
|
||||
const subLinks: Link['directLinks'] = [];
|
||||
|
||||
data?.episodes?.reverse().map((episode: any) => {
|
||||
const title = 'Episode ' + episode?.number;
|
||||
const link = episode?.id?.toString();
|
||||
if (link && title) {
|
||||
subLinks.push({
|
||||
title,
|
||||
link,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
linkList.push({
|
||||
title: meta.title,
|
||||
directLinks: subLinks,
|
||||
});
|
||||
|
||||
return {
|
||||
...meta,
|
||||
linkList: linkList,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return {
|
||||
title: '',
|
||||
synopsis: '',
|
||||
image: '',
|
||||
imdbId: '',
|
||||
type: 'movie',
|
||||
linkList: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
75
providers/kissKh/kissKhGetPosts.ts
Normal file
75
providers/kissKh/kissKhGetPosts.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import {Post, ProviderContext} from '../types';
|
||||
|
||||
export const kissKhGetPosts = async function ({
|
||||
filter,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
filter: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl, axios} = providerContext;
|
||||
const baseUrl = await getBaseUrl('kissKh');
|
||||
const url = `${baseUrl + filter}&type=0`;
|
||||
try {
|
||||
const res = await axios.get(url, {signal});
|
||||
const data = res.data?.data;
|
||||
const catalog: Post[] = [];
|
||||
data?.map((element: any) => {
|
||||
const title = element.title;
|
||||
const link = baseUrl + `/api/DramaList/Drama/${element?.id}?isq=false`;
|
||||
const image = element.thumbnail;
|
||||
if (title && link && image) {
|
||||
catalog.push({
|
||||
title: title,
|
||||
link: link,
|
||||
image: image,
|
||||
});
|
||||
}
|
||||
});
|
||||
return catalog;
|
||||
} catch (err) {
|
||||
console.error('kiss error ', err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export const kissKhGetPostsSearch = async function ({
|
||||
searchQuery,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
searchQuery: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl, axios} = providerContext;
|
||||
const baseUrl = await getBaseUrl('kissKh');
|
||||
const url = `${baseUrl}/api/DramaList/Search?q=${searchQuery}&type=0`;
|
||||
try {
|
||||
const res = await axios.get(url, {signal});
|
||||
const data = res.data;
|
||||
const catalog: Post[] = [];
|
||||
data?.map((element: any) => {
|
||||
const title = element.title;
|
||||
const link = baseUrl + `/api/DramaList/Drama/${element?.id}?isq=false`;
|
||||
const image = element.thumbnail;
|
||||
if (title && link && image) {
|
||||
catalog.push({
|
||||
title: title,
|
||||
link: link,
|
||||
image: image,
|
||||
});
|
||||
}
|
||||
});
|
||||
return catalog;
|
||||
} catch (err) {
|
||||
console.error('kiss error ', err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
45
providers/kissKh/kissKhGetStream.ts
Normal file
45
providers/kissKh/kissKhGetStream.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import {Stream, ProviderContext, TextTrackType, TextTracks} from '../types';
|
||||
|
||||
export const kissKhGetStream = async function ({
|
||||
link: id,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
try {
|
||||
const {axios, getBaseUrl} = providerContext;
|
||||
const streamLinks: Stream[] = [];
|
||||
const subtitles: TextTracks = [];
|
||||
const baseUrl = await getBaseUrl('kissKh');
|
||||
const streamUrl =
|
||||
'https://adorable-salamander-ecbb21.netlify.app/api/kisskh/video?id=' +
|
||||
id;
|
||||
const res = await axios.get(streamUrl);
|
||||
const stream = res.data?.source?.Video;
|
||||
const subData = res.data?.subtitles;
|
||||
subData?.map((sub: any) => {
|
||||
subtitles.push({
|
||||
title: sub?.label,
|
||||
language: sub?.land,
|
||||
type: sub?.src?.includes('.vtt')
|
||||
? TextTrackType.VTT
|
||||
: TextTrackType.SUBRIP,
|
||||
uri: sub?.src,
|
||||
});
|
||||
});
|
||||
streamLinks.push({
|
||||
server: 'kissKh',
|
||||
link: stream,
|
||||
type: 'm3u8',
|
||||
subtitles,
|
||||
headers: {
|
||||
referer: baseUrl,
|
||||
},
|
||||
});
|
||||
return streamLinks;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user