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:
183
providers/hdhub4u/hdhub4uGetSteam.ts
Normal file
183
providers/hdhub4u/hdhub4uGetSteam.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
import {ProviderContext} from '../types';
|
||||
|
||||
export async function hdhub4uGetStream({
|
||||
link,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
type: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}) {
|
||||
const {axios, cheerio, extractors, commonHeaders: headers} = providerContext;
|
||||
const {hubcloudExtracter} = extractors;
|
||||
let hubdriveLink = '';
|
||||
if (link.includes('hubdrive')) {
|
||||
const hubdriveRes = await axios.get(link, {headers, signal});
|
||||
const hubdriveText = hubdriveRes.data;
|
||||
const $ = cheerio.load(hubdriveText);
|
||||
hubdriveLink =
|
||||
$('.btn.btn-primary.btn-user.btn-success1.m-1').attr('href') || link;
|
||||
} else {
|
||||
const res = await axios.get(link, {headers, signal});
|
||||
const text = res.data;
|
||||
const encryptedString = text.split("s('o','")?.[1]?.split("',180")?.[0];
|
||||
const decodedString: any = decodeString(encryptedString);
|
||||
link = atob(decodedString?.o);
|
||||
const redirectLink = await getRedirectLinks(link, signal, headers);
|
||||
const redirectLinkRes = await axios.get(redirectLink, {headers, signal});
|
||||
const redirectLinkText = redirectLinkRes.data;
|
||||
const $ = cheerio.load(redirectLinkText);
|
||||
hubdriveLink =
|
||||
$('h3:contains("1080p")').find('a').attr('href') ||
|
||||
redirectLinkText.match(
|
||||
/href="(https:\/\/hubcloud\.[^\/]+\/drive\/[^"]+)"/,
|
||||
)[1];
|
||||
if (hubdriveLink.includes('hubdrive')) {
|
||||
const hubdriveRes = await axios.get(hubdriveLink, {headers, signal});
|
||||
const hubdriveText = hubdriveRes.data;
|
||||
const $$ = cheerio.load(hubdriveText);
|
||||
hubdriveLink =
|
||||
$$('.btn.btn-primary.btn-user.btn-success1.m-1').attr('href') ||
|
||||
hubdriveLink;
|
||||
}
|
||||
}
|
||||
const hubdriveLinkRes = await axios.get(hubdriveLink, {headers, signal});
|
||||
const hubcloudText = hubdriveLinkRes.data;
|
||||
const hubcloudLink =
|
||||
hubcloudText.match(
|
||||
/<META HTTP-EQUIV="refresh" content="0; url=([^"]+)">/i,
|
||||
)?.[1] || hubdriveLink;
|
||||
try {
|
||||
return await hubcloudExtracter(hubcloudLink, signal);
|
||||
} catch (error: any) {
|
||||
console.log('hd hub 4 getStream error: ', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
const encode = function (value: string) {
|
||||
return btoa(value.toString());
|
||||
};
|
||||
const decode = function (value: string) {
|
||||
if (value === undefined) {
|
||||
return '';
|
||||
}
|
||||
return atob(value.toString());
|
||||
};
|
||||
const pen = function (value: string) {
|
||||
return value.replace(/[a-zA-Z]/g, function (_0x1a470e: any) {
|
||||
return String.fromCharCode(
|
||||
(_0x1a470e <= 'Z' ? 90 : 122) >=
|
||||
(_0x1a470e = _0x1a470e.charCodeAt(0) + 13)
|
||||
? _0x1a470e
|
||||
: _0x1a470e - 26,
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const abortableTimeout = (
|
||||
ms: number,
|
||||
{signal}: {signal?: AbortSignal} = {},
|
||||
) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (signal && signal.aborted) {
|
||||
return reject(new Error('Aborted'));
|
||||
}
|
||||
|
||||
const timer = setTimeout(resolve, ms);
|
||||
|
||||
if (signal) {
|
||||
signal.addEventListener('abort', () => {
|
||||
clearTimeout(timer);
|
||||
reject(new Error('Aborted'));
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export async function getRedirectLinks(
|
||||
link: string,
|
||||
signal: AbortSignal,
|
||||
headers: any,
|
||||
) {
|
||||
try {
|
||||
const res = await fetch(link, {headers, signal});
|
||||
const resText = await res.text();
|
||||
|
||||
var regex = /ck\('_wp_http_\d+','([^']+)'/g;
|
||||
var combinedString = '';
|
||||
|
||||
var match;
|
||||
while ((match = regex.exec(resText)) !== null) {
|
||||
// console.log(match[1]);
|
||||
combinedString += match[1];
|
||||
}
|
||||
// console.log(decode(combinedString));
|
||||
const decodedString = decode(pen(decode(decode(combinedString))));
|
||||
// console.log(decodedString);
|
||||
const data = JSON.parse(decodedString);
|
||||
console.log(data);
|
||||
const token = encode(data?.data);
|
||||
const blogLink = data?.wp_http1 + '?re=' + token;
|
||||
// abort timeout on signal
|
||||
let wait = abortableTimeout((Number(data?.total_time) + 3) * 1000, {
|
||||
signal,
|
||||
});
|
||||
|
||||
await wait;
|
||||
console.log('blogLink', blogLink);
|
||||
|
||||
let vcloudLink = 'Invalid Request';
|
||||
while (vcloudLink.includes('Invalid Request')) {
|
||||
const blogRes = await fetch(blogLink, {headers, signal});
|
||||
const blogResText = (await blogRes.text()) as any;
|
||||
if (blogResText.includes('Invalid Request')) {
|
||||
console.log(blogResText);
|
||||
} else {
|
||||
vcloudLink = blogResText.match(/var reurl = "([^"]+)"/) || '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('vcloudLink', vcloudLink?.[1]);
|
||||
return blogLink || link;
|
||||
} catch (err) {
|
||||
console.log('Error in getRedirectLinks', err);
|
||||
return link;
|
||||
}
|
||||
}
|
||||
|
||||
function rot13(str: string) {
|
||||
return str.replace(/[a-zA-Z]/g, function (char) {
|
||||
const charCode = char.charCodeAt(0);
|
||||
const isUpperCase = char <= 'Z';
|
||||
const baseCharCode = isUpperCase ? 65 : 97;
|
||||
return String.fromCharCode(
|
||||
((charCode - baseCharCode + 13) % 26) + baseCharCode,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function decodeString(encryptedString: string) {
|
||||
try {
|
||||
// First base64 decode
|
||||
let decoded = atob(encryptedString);
|
||||
|
||||
// Second base64 decode
|
||||
decoded = atob(decoded);
|
||||
|
||||
// ROT13 decode
|
||||
decoded = rot13(decoded);
|
||||
|
||||
// Third base64 decode
|
||||
decoded = atob(decoded);
|
||||
|
||||
// Parse JSON
|
||||
return JSON.parse(decoded);
|
||||
} catch (error) {
|
||||
console.error('Error decoding string:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
61
providers/hdhub4u/hdhubCatalog.ts
Normal file
61
providers/hdhub4u/hdhubCatalog.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
export const hdhub4uCatalog = [
|
||||
{
|
||||
title: 'Latest',
|
||||
filter: '',
|
||||
},
|
||||
{
|
||||
title: 'Web Series',
|
||||
filter: '/category/web-series',
|
||||
},
|
||||
{
|
||||
title: 'Hollywood ',
|
||||
filter: '/category/hollywood-movies',
|
||||
},
|
||||
{
|
||||
title: 'South Movies',
|
||||
filter: '/category/south-hindi-movies',
|
||||
},
|
||||
];
|
||||
|
||||
export const hdhub4uGenresList = [
|
||||
{
|
||||
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',
|
||||
},
|
||||
];
|
||||
129
providers/hdhub4u/hdhubGetInfo.ts
Normal file
129
providers/hdhub4u/hdhubGetInfo.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
import {Info, Link, ProviderContext} from '../types';
|
||||
|
||||
const hdbHeaders = {
|
||||
Cookie: 'xla=s4t',
|
||||
Referer: 'https://google.com',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0',
|
||||
};
|
||||
export const hdhub4uGetInfo = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
try {
|
||||
const {axios, cheerio} = providerContext;
|
||||
const url = link;
|
||||
const res = await axios.get(url, {headers: hdbHeaders});
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
const container = $('.page-body');
|
||||
const imdbId =
|
||||
container
|
||||
.find('a[href*="imdb.com/title/tt"]:not([href*="imdb.com/title/tt/"])')
|
||||
.attr('href')
|
||||
?.split('/')[4] || '';
|
||||
const title = container
|
||||
.find(
|
||||
'h2[data-ved="2ahUKEwjL0NrBk4vnAhWlH7cAHRCeAlwQ3B0oATAfegQIFBAM"],h2[data-ved="2ahUKEwiP0pGdlermAhUFYVAKHV8tAmgQ3B0oATAZegQIDhAM"]',
|
||||
)
|
||||
.text();
|
||||
const type = title.toLocaleLowerCase().includes('season')
|
||||
? 'series'
|
||||
: 'movie';
|
||||
const synopsis = container
|
||||
.find('strong:contains("DESCRIPTION")')
|
||||
.parent()
|
||||
.text()
|
||||
.replace('DESCRIPTION:', '');
|
||||
const image = container.find('img[decoding="async"]').attr('src') || '';
|
||||
|
||||
// Links
|
||||
const links: Link[] = [];
|
||||
const directLink: Link['directLinks'] = [];
|
||||
|
||||
// direct link type
|
||||
$('strong:contains("EPiSODE")').map((i, element) => {
|
||||
const epTitle = $(element).parent().parent().text();
|
||||
const episodesLink =
|
||||
$(element)
|
||||
.parent()
|
||||
.parent()
|
||||
.parent()
|
||||
.next()
|
||||
.next()
|
||||
.find('a')
|
||||
.attr('href') ||
|
||||
$(element).parent().parent().parent().next().find('a').attr('href');
|
||||
|
||||
if (episodesLink && episodesLink) {
|
||||
directLink.push({
|
||||
title: epTitle,
|
||||
link: episodesLink,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (directLink.length === 0) {
|
||||
container.find('a:contains("EPiSODE")').map((i, element) => {
|
||||
const epTitle = $(element).text();
|
||||
const episodesLink = $(element).attr('href');
|
||||
if (episodesLink) {
|
||||
directLink.push({
|
||||
title: epTitle.toLocaleUpperCase(),
|
||||
link: episodesLink,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (directLink.length > 0) {
|
||||
links.push({
|
||||
title: title,
|
||||
directLinks: directLink,
|
||||
});
|
||||
}
|
||||
if (directLink.length === 0) {
|
||||
container
|
||||
.find(
|
||||
'a:contains("480"),a:contains("720"),a:contains("1080"),a:contains("2160"),a:contains("4K")',
|
||||
)
|
||||
.map((i, element) => {
|
||||
const quality =
|
||||
$(element)
|
||||
.text()
|
||||
.match(/\b(480p|720p|1080p|2160p)\b/i)?.[0] || '';
|
||||
const movieLinks = $(element).attr('href');
|
||||
const title = $(element).text();
|
||||
if (movieLinks) {
|
||||
links.push({
|
||||
directLinks: [{link: movieLinks, title: 'Movie', type: 'movie'}],
|
||||
quality: quality,
|
||||
title: title,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 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: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
84
providers/hdhub4u/hdhubGetPosts.ts
Normal file
84
providers/hdhub4u/hdhubGetPosts.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import {Post, ProviderContext} from '../types';
|
||||
|
||||
const hdbHeaders = {
|
||||
Cookie: 'xla=s4t',
|
||||
Referer: 'https://google.com',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0',
|
||||
};
|
||||
|
||||
export const hdhubGetPosts = async function ({
|
||||
filter,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
filter: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
providerContext: ProviderContext;
|
||||
signal: AbortSignal;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl} = providerContext;
|
||||
const baseUrl = await getBaseUrl('hdhub');
|
||||
const url = `${baseUrl + filter}/page/${page}/`;
|
||||
return posts({url, signal, providerContext});
|
||||
};
|
||||
|
||||
export const hdhubGetPostsSearch = async function ({
|
||||
searchQuery,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
searchQuery: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
providerContext: ProviderContext;
|
||||
signal: AbortSignal;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl} = providerContext;
|
||||
const baseUrl = await getBaseUrl('hdhub');
|
||||
const url = `${baseUrl}/page/${page}/?s=${searchQuery}`;
|
||||
return posts({url, signal, providerContext});
|
||||
};
|
||||
|
||||
async function posts({
|
||||
url,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
url: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {cheerio} = providerContext;
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
headers: hdbHeaders,
|
||||
signal,
|
||||
});
|
||||
const data = await res.text();
|
||||
const $ = cheerio.load(data);
|
||||
const catalog: Post[] = [];
|
||||
$('.recent-movies')
|
||||
.children()
|
||||
.map((i, element) => {
|
||||
const title = $(element).find('figure').find('img').attr('alt');
|
||||
const link = $(element).find('a').attr('href');
|
||||
const image = $(element).find('figure').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('hdhubGetPosts error ', err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
14
providers/hdhub4u/index.ts
Normal file
14
providers/hdhub4u/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import {hdhub4uCatalog, hdhub4uGenresList} from './hdhubCatalog';
|
||||
import {hdhub4uGetInfo} from './hdhubGetInfo';
|
||||
import {hdhub4uGetStream} from './hdhub4uGetSteam';
|
||||
import {hdhubGetPosts, hdhubGetPostsSearch} from './hdhubGetPosts';
|
||||
import {ProviderType} from '../types';
|
||||
|
||||
export const hdhub4uProvider: ProviderType = {
|
||||
catalog: hdhub4uCatalog,
|
||||
genres: hdhub4uGenresList,
|
||||
GetMetaData: hdhub4uGetInfo,
|
||||
GetStream: hdhub4uGetStream,
|
||||
GetHomePosts: hdhubGetPosts,
|
||||
GetSearchPosts: hdhubGetPostsSearch,
|
||||
};
|
||||
Reference in New Issue
Block a user