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:
16
providers/katmovies/index.ts
Normal file
16
providers/katmovies/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import {katCatalog, katGenresList} from './katCatalog';
|
||||
import {katEpisodeLinks} from './katGetEpsodes';
|
||||
import {katGetInfo} from './katGetInfo';
|
||||
import {katGetPosts, katGetPostsSearch} from './katGetPosts';
|
||||
import {katGetStream} from './katGetSteam';
|
||||
import {ProviderType} from '../types';
|
||||
|
||||
export const katMoviesHd: ProviderType = {
|
||||
catalog: katCatalog,
|
||||
genres: katGenresList,
|
||||
GetMetaData: katGetInfo,
|
||||
GetHomePosts: katGetPosts,
|
||||
GetStream: katGetStream,
|
||||
GetEpisodeLinks: katEpisodeLinks,
|
||||
GetSearchPosts: katGetPostsSearch,
|
||||
};
|
||||
61
providers/katmovies/katCatalog.ts
Normal file
61
providers/katmovies/katCatalog.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
export const katCatalog = [
|
||||
{
|
||||
title: 'Latest',
|
||||
filter: '',
|
||||
},
|
||||
{
|
||||
title: 'Netflix',
|
||||
filter: '/category/netflix',
|
||||
},
|
||||
{
|
||||
title: 'Animated',
|
||||
filter: '/category/animated',
|
||||
},
|
||||
{
|
||||
title: 'Amazon Prime',
|
||||
filter: '/category/amazon-prime',
|
||||
},
|
||||
];
|
||||
|
||||
export const katGenresList = [
|
||||
{
|
||||
title: 'Action',
|
||||
filter: '/category/action',
|
||||
},
|
||||
{
|
||||
title: 'Crime',
|
||||
filter: '/category/crime',
|
||||
},
|
||||
{
|
||||
title: 'Comedy',
|
||||
filter: '/category/comedy',
|
||||
},
|
||||
{
|
||||
title: 'Drama',
|
||||
filter: '/category/drama',
|
||||
},
|
||||
{
|
||||
title: 'Horror',
|
||||
filter: '/category/horror',
|
||||
},
|
||||
{
|
||||
title: 'Family',
|
||||
filter: '/category/family',
|
||||
},
|
||||
{
|
||||
title: 'Sci-Fi',
|
||||
filter: '/category/sifi',
|
||||
},
|
||||
{
|
||||
title: 'Thriller',
|
||||
filter: '/category/triller',
|
||||
},
|
||||
{
|
||||
title: 'Romance',
|
||||
filter: '/category/romance',
|
||||
},
|
||||
{
|
||||
title: 'Fight',
|
||||
filter: '/category/fight',
|
||||
},
|
||||
];
|
||||
84
providers/katmovies/katGetEpsodes.ts
Normal file
84
providers/katmovies/katGetEpsodes.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import {EpisodeLink, ProviderContext} from '../types';
|
||||
|
||||
export const katEpisodeLinks = async function ({
|
||||
url,
|
||||
providerContext,
|
||||
}: {
|
||||
url: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<EpisodeLink[]> {
|
||||
const {axios, cheerio} = providerContext;
|
||||
const episodesLink: EpisodeLink[] = [];
|
||||
try {
|
||||
if (url.includes('gdflix')) {
|
||||
const baseUrl = url.split('/pack')?.[0];
|
||||
const res = await axios.get(url);
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
const links = $('.list-group-item');
|
||||
links?.map((i, link) => {
|
||||
episodesLink.push({
|
||||
title: $(link).text() || '',
|
||||
link: baseUrl + $(link).find('a').attr('href') || '',
|
||||
});
|
||||
});
|
||||
if (episodesLink.length > 0) {
|
||||
return episodesLink;
|
||||
}
|
||||
}
|
||||
if (url.includes('/pack')) {
|
||||
const epIds = await extractKmhdEpisodes(url, providerContext);
|
||||
epIds?.forEach((id: string, index: number) => {
|
||||
episodesLink.push({
|
||||
title: `Episode ${index + 1}`,
|
||||
link: url.split('/pack')[0] + '/file/' + id,
|
||||
});
|
||||
});
|
||||
}
|
||||
const res = await axios.get(url, {
|
||||
headers: {
|
||||
Cookie:
|
||||
'_ga_GNR438JY8N=GS1.1.1722240350.5.0.1722240350.0.0.0; _ga=GA1.1.372196696.1722150754; unlocked=true',
|
||||
},
|
||||
});
|
||||
const episodeData = res.data;
|
||||
const $ = cheerio.load(episodeData);
|
||||
const links = $('.autohyperlink');
|
||||
links?.map((i, link) => {
|
||||
episodesLink.push({
|
||||
title: $(link).parent().children().remove().end().text() || '',
|
||||
link: $(link).attr('href') || '',
|
||||
});
|
||||
});
|
||||
|
||||
return episodesLink;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export async function extractKmhdLink(
|
||||
katlink: string,
|
||||
providerContext: ProviderContext,
|
||||
) {
|
||||
const {axios} = providerContext;
|
||||
const res = await axios.get(katlink);
|
||||
const data = res.data;
|
||||
const hubDriveRes = data.match(/hubdrive_res:\s*"([^"]+)"/)[1];
|
||||
const hubDriveLink = data.match(
|
||||
/hubdrive_res\s*:\s*{[^}]*?link\s*:\s*"([^"]+)"/,
|
||||
)[1];
|
||||
return hubDriveLink + hubDriveRes;
|
||||
}
|
||||
|
||||
async function extractKmhdEpisodes(
|
||||
katlink: string,
|
||||
providerContext: ProviderContext,
|
||||
) {
|
||||
const {axios} = providerContext;
|
||||
const res = await axios.get(katlink);
|
||||
const data = res.data;
|
||||
const ids = data.match(/[\w]+_[a-f0-9]{8}/g);
|
||||
return ids;
|
||||
}
|
||||
131
providers/katmovies/katGetInfo.ts
Normal file
131
providers/katmovies/katGetInfo.ts
Normal file
@@ -0,0 +1,131 @@
|
||||
import {Info, Link, ProviderContext} from '../types';
|
||||
|
||||
export const katGetInfo = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
try {
|
||||
const {axios, cheerio} = providerContext;
|
||||
const url = link;
|
||||
const res = await axios.get(url);
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
const container = $('.yQ8hqd.ksSzJd.LoQAYe').html()
|
||||
? $('.yQ8hqd.ksSzJd.LoQAYe')
|
||||
: $('.FxvUNb');
|
||||
const imdbId =
|
||||
container
|
||||
.find('a[href*="imdb.com/title/tt"]:not([href*="imdb.com/title/tt/"])')
|
||||
.attr('href')
|
||||
?.split('/')[4] || '';
|
||||
const title = container
|
||||
.find('li:contains("Name")')
|
||||
.children()
|
||||
.remove()
|
||||
.end()
|
||||
.text();
|
||||
const type = $('.yQ8hqd.ksSzJd.LoQAYe').html() ? 'series' : 'movie';
|
||||
const synopsis = container.find('li:contains("Stars")').text();
|
||||
const image =
|
||||
$('h4:contains("SCREENSHOTS")').next().find('img').attr('src') || '';
|
||||
|
||||
console.log('katGetInfo', title, synopsis, image, imdbId, type);
|
||||
|
||||
// Links
|
||||
const links: Link[] = [];
|
||||
const directLink: Link['directLinks'] = [];
|
||||
|
||||
// direct links
|
||||
$('.entry-content')
|
||||
.find('p:contains("Episode")')
|
||||
.each((i, element) => {
|
||||
const dlLink =
|
||||
$(element)
|
||||
.nextAll('h3,h2')
|
||||
.first()
|
||||
.find('a:contains("1080"),a:contains("720"),a:contains("480")')
|
||||
.attr('href') || '';
|
||||
const dlTitle = $(element).find('span').text();
|
||||
|
||||
if (link.trim().length > 0 && dlTitle.includes('Episode ')) {
|
||||
directLink.push({
|
||||
title: dlTitle,
|
||||
link: dlLink,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (directLink.length > 0) {
|
||||
links.push({
|
||||
quality: '',
|
||||
title: title,
|
||||
directLinks: directLink,
|
||||
});
|
||||
}
|
||||
|
||||
$('.entry-content')
|
||||
.find('pre')
|
||||
.nextUntil('div')
|
||||
.filter('h2')
|
||||
.each((i, element) => {
|
||||
const link = $(element).find('a').attr('href');
|
||||
const quality =
|
||||
$(element)
|
||||
.text()
|
||||
.match(/\b(480p|720p|1080p|2160p)\b/i)?.[0] || '';
|
||||
const title = $(element).text();
|
||||
if (link && title.includes('')) {
|
||||
links.push({
|
||||
quality,
|
||||
title,
|
||||
episodesLink: link,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (links.length === 0 && type === 'movie') {
|
||||
$('.entry-content')
|
||||
.find('h2:contains("DOWNLOAD"),h3:contains("DOWNLOAD")')
|
||||
.nextUntil('pre,div')
|
||||
.filter('h2')
|
||||
.each((i, element) => {
|
||||
const link = $(element).find('a').attr('href');
|
||||
const quality =
|
||||
$(element)
|
||||
.text()
|
||||
.match(/\b(480p|720p|1080p|2160p)\b/i)?.[0] || '';
|
||||
const title = $(element).text();
|
||||
if (link && !title.includes('Online')) {
|
||||
links.push({
|
||||
quality,
|
||||
title,
|
||||
directLinks: [{link, title, type: 'movie'}],
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// console.log('drive meta', title, synopsis, image, imdbId, type, links);
|
||||
return {
|
||||
title,
|
||||
synopsis,
|
||||
image,
|
||||
imdbId,
|
||||
type,
|
||||
linkList: links,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return {
|
||||
title: '',
|
||||
synopsis: '',
|
||||
image: '',
|
||||
imdbId: '',
|
||||
type: 'movie',
|
||||
linkList: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
72
providers/katmovies/katGetPosts.ts
Normal file
72
providers/katmovies/katGetPosts.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import {Post, ProviderContext} from '../types';
|
||||
|
||||
export const katGetPosts = async function ({
|
||||
filter,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
filter: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl, cheerio} = providerContext;
|
||||
const baseUrl = await getBaseUrl('kat');
|
||||
const url = `${baseUrl + filter}/page/${page}/`;
|
||||
return posts({url, signal, cheerio});
|
||||
};
|
||||
|
||||
export const katGetPostsSearch = async function ({
|
||||
searchQuery,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
searchQuery: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl, cheerio} = providerContext;
|
||||
const baseUrl = await getBaseUrl('kat');
|
||||
const url = `${baseUrl}/page/${page}/?s=${searchQuery}`;
|
||||
return posts({url, signal, cheerio});
|
||||
};
|
||||
|
||||
async function posts({
|
||||
url,
|
||||
signal,
|
||||
cheerio,
|
||||
}: {
|
||||
url: string;
|
||||
signal: AbortSignal;
|
||||
cheerio: ProviderContext['cheerio'];
|
||||
}): Promise<Post[]> {
|
||||
try {
|
||||
const res = await fetch(url, {signal});
|
||||
const data = await res.text();
|
||||
const $ = cheerio.load(data);
|
||||
const catalog: Post[] = [];
|
||||
$('.recent-posts')
|
||||
.children()
|
||||
.map((i, element) => {
|
||||
const title = $(element).find('img').attr('alt');
|
||||
const link = $(element).find('a').attr('href');
|
||||
const image = $(element).find('img').attr('src');
|
||||
if (title && link && image) {
|
||||
catalog.push({
|
||||
title: title.replace('Download', '').trim(),
|
||||
link: link,
|
||||
image: image,
|
||||
});
|
||||
}
|
||||
});
|
||||
return catalog;
|
||||
} catch (err) {
|
||||
console.error('katmovies error ', err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
99
providers/katmovies/katGetSteam.ts
Normal file
99
providers/katmovies/katGetSteam.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import {Stream, ProviderContext} from '../types';
|
||||
|
||||
async function extractKmhdLink(
|
||||
katlink: string,
|
||||
providerContext: ProviderContext,
|
||||
) {
|
||||
const {axios} = providerContext;
|
||||
const res = await axios.get(katlink);
|
||||
const data = res.data;
|
||||
const hubDriveRes = data.match(/hubdrive_res:\s*"([^"]+)"/)[1];
|
||||
const hubDriveLink = data.match(
|
||||
/hubdrive_res\s*:\s*{[^}]*?link\s*:\s*"([^"]+)"/,
|
||||
)[1];
|
||||
return hubDriveLink + hubDriveRes;
|
||||
}
|
||||
export async function katGetStream({
|
||||
link,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
type: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
const {axios, cheerio, extractors} = providerContext;
|
||||
const {hubcloudExtracter, gdFlixExtracter} = extractors;
|
||||
const streamLinks: Stream[] = [];
|
||||
console.log('katGetStream', link);
|
||||
try {
|
||||
if (link.includes('gdflix')) {
|
||||
return await gdFlixExtracter(link, signal);
|
||||
}
|
||||
if (link.includes('kmhd')) {
|
||||
const hubcloudLink = await extractKmhdLink(link, providerContext);
|
||||
return await hubcloudExtracter(hubcloudLink, signal);
|
||||
}
|
||||
if (link.includes('gdflix')) {
|
||||
// resume link
|
||||
try {
|
||||
const resumeDrive = link.replace('/file', '/zfile');
|
||||
// console.log('resumeDrive', resumeDrive);
|
||||
const resumeDriveRes = await axios.get(resumeDrive);
|
||||
const resumeDriveHtml = resumeDriveRes.data;
|
||||
const $resumeDrive = cheerio.load(resumeDriveHtml);
|
||||
const resumeLink = $resumeDrive('.btn-success').attr('href');
|
||||
console.log('resumeLink', resumeLink);
|
||||
if (resumeLink) {
|
||||
streamLinks.push({
|
||||
server: 'ResumeCloud',
|
||||
link: resumeLink,
|
||||
type: 'mkv',
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('Resume link not found');
|
||||
}
|
||||
//instant link
|
||||
try {
|
||||
const driveres = await axios.get(link, {timeout: 10000});
|
||||
const $drive = cheerio.load(driveres.data);
|
||||
const seed = $drive('.btn-danger').attr('href') || '';
|
||||
const instantToken = seed.split('=')[1];
|
||||
// console.log('InstantToken', instantToken);
|
||||
const InstantFromData = new FormData();
|
||||
InstantFromData.append('keys', instantToken);
|
||||
const videoSeedUrl = seed.split('/').slice(0, 3).join('/') + '/api';
|
||||
// console.log('videoSeedUrl', videoSeedUrl);
|
||||
const instantLinkRes = await fetch(videoSeedUrl, {
|
||||
method: 'POST',
|
||||
body: InstantFromData,
|
||||
headers: {
|
||||
'x-token': videoSeedUrl,
|
||||
},
|
||||
});
|
||||
const instantLinkData = await instantLinkRes.json();
|
||||
console.log('instantLinkData', instantLinkData);
|
||||
if (instantLinkData.error === false) {
|
||||
const instantLink = instantLinkData.url;
|
||||
streamLinks.push({
|
||||
server: 'Gdrive-Instant',
|
||||
link: instantLink,
|
||||
type: 'mkv',
|
||||
});
|
||||
} else {
|
||||
console.log('Instant link not found', instantLinkData);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('Instant link not found', err);
|
||||
}
|
||||
return streamLinks;
|
||||
}
|
||||
const stereams = await hubcloudExtracter(link, signal);
|
||||
return stereams;
|
||||
} catch (error: any) {
|
||||
console.log('katgetStream error: ', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user