mirror of
https://github.com/sussy-code/providers.git
synced 2026-04-21 08:31:57 +00:00
Add turbovid embed
This commit is contained in:
parent
26d32b5531
commit
d2233481c2
2 changed files with 76 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import { mixdropScraper } from '@/providers/embeds/mixdrop';
|
||||||
import { mp4uploadScraper } from '@/providers/embeds/mp4upload';
|
import { mp4uploadScraper } from '@/providers/embeds/mp4upload';
|
||||||
import { streambucketScraper } from '@/providers/embeds/streambucket';
|
import { streambucketScraper } from '@/providers/embeds/streambucket';
|
||||||
import { streamsbScraper } from '@/providers/embeds/streamsb';
|
import { streamsbScraper } from '@/providers/embeds/streamsb';
|
||||||
|
import { turbovidScraper } from '@/providers/embeds/turbovid';
|
||||||
import { upcloudScraper } from '@/providers/embeds/upcloud';
|
import { upcloudScraper } from '@/providers/embeds/upcloud';
|
||||||
import { upstreamScraper } from '@/providers/embeds/upstream';
|
import { upstreamScraper } from '@/providers/embeds/upstream';
|
||||||
import { vidsrcembedScraper } from '@/providers/embeds/vidsrc';
|
import { vidsrcembedScraper } from '@/providers/embeds/vidsrc';
|
||||||
|
|
@ -133,5 +134,6 @@ export function gatherAllEmbeds(): Array<Embed> {
|
||||||
autoembedBengaliScraper,
|
autoembedBengaliScraper,
|
||||||
autoembedTamilScraper,
|
autoembedTamilScraper,
|
||||||
autoembedTeluguScraper,
|
autoembedTeluguScraper,
|
||||||
|
turbovidScraper,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
74
src/providers/embeds/turbovid.ts
Normal file
74
src/providers/embeds/turbovid.ts
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
import { flags } from '@/entrypoint/utils/targets';
|
||||||
|
import { makeEmbed } from '@/providers/base';
|
||||||
|
|
||||||
|
// Thanks to Paradox_77 for helping with the decryption
|
||||||
|
function hexToChar(hex: string): string {
|
||||||
|
return String.fromCharCode(parseInt(hex, 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
function decrypt(data: string, key: string): string {
|
||||||
|
const formatedData = data.match(/../g)?.map(hexToChar).join('') || '';
|
||||||
|
return formatedData
|
||||||
|
.split('')
|
||||||
|
.map((char, i) => String.fromCharCode(char.charCodeAt(0) ^ key.charCodeAt(i % key.length)))
|
||||||
|
.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
export const turbovidScraper = makeEmbed({
|
||||||
|
id: 'turbovid',
|
||||||
|
name: 'Turbovid',
|
||||||
|
rank: 122,
|
||||||
|
async scrape(ctx) {
|
||||||
|
const baseUrl = new URL(ctx.url).origin;
|
||||||
|
const embedPage = await ctx.proxiedFetcher(ctx.url);
|
||||||
|
|
||||||
|
// the whitespace is for future-proofing the regex a bit
|
||||||
|
const apkey = embedPage.match(/const\s+apkey\s*=\s*"(.*?)";/)?.[1];
|
||||||
|
const xxid = embedPage.match(/const\s+xxid\s*=\s*"(.*?)";/)?.[1];
|
||||||
|
|
||||||
|
if (!apkey || !xxid) throw new Error('Failed to get required values');
|
||||||
|
|
||||||
|
// json isn't parsed by proxiedFetcher due to content-type being text/html
|
||||||
|
const juiceKey = JSON.parse(
|
||||||
|
await ctx.proxiedFetcher('/api/cucked/juice_key', {
|
||||||
|
baseUrl,
|
||||||
|
headers: {
|
||||||
|
referer: ctx.url,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).juice;
|
||||||
|
|
||||||
|
if (!juiceKey) throw new Error('Failed to fetch the key');
|
||||||
|
|
||||||
|
const data = JSON.parse(
|
||||||
|
await ctx.proxiedFetcher('/api/cucked/the_juice/', {
|
||||||
|
baseUrl,
|
||||||
|
query: {
|
||||||
|
[apkey]: xxid,
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
referer: ctx.url,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).data;
|
||||||
|
|
||||||
|
if (!data) throw new Error('Failed to fetch required data');
|
||||||
|
|
||||||
|
const playlist = decrypt(data, juiceKey);
|
||||||
|
|
||||||
|
return {
|
||||||
|
stream: [
|
||||||
|
{
|
||||||
|
type: 'hls',
|
||||||
|
id: 'primary',
|
||||||
|
playlist,
|
||||||
|
headers: {
|
||||||
|
referer: baseUrl,
|
||||||
|
},
|
||||||
|
flags: [flags.CORS_ALLOWED],
|
||||||
|
captions: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue