Merge pull request #138 from ztpn/embeds

Embeds
This commit is contained in:
Jorrin 2024-04-03 20:39:41 +02:00 committed by GitHub
commit c4343b81c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 189 additions and 3 deletions

View File

@ -1,7 +1,9 @@
import { Embed, Sourcerer } from '@/providers/base';
import { doodScraper } from '@/providers/embeds/dood';
import { droploadScraper } from '@/providers/embeds/dropload';
import { febboxHlsScraper } from '@/providers/embeds/febbox/hls';
import { febboxMp4Scraper } from '@/providers/embeds/febbox/mp4';
import { filelionsScraper } from '@/providers/embeds/filelions';
import { mixdropScraper } from '@/providers/embeds/mixdrop';
import { mp4uploadScraper } from '@/providers/embeds/mp4upload';
import { streambucketScraper } from '@/providers/embeds/streambucket';
@ -9,6 +11,7 @@ import { streamsbScraper } from '@/providers/embeds/streamsb';
import { upcloudScraper } from '@/providers/embeds/upcloud';
import { upstreamScraper } from '@/providers/embeds/upstream';
import { vidsrcembedScraper } from '@/providers/embeds/vidsrc';
import { vTubeScraper } from '@/providers/embeds/vtube';
import { flixhqScraper } from '@/providers/sources/flixhq/index';
import { goMoviesScraper } from '@/providers/sources/gomovies/index';
import { kissAsianScraper } from '@/providers/sources/kissasian/index';
@ -82,5 +85,8 @@ export function gatherAllEmbeds(): Array<Embed> {
streamvidScraper,
voeScraper,
streamtapeScraper,
droploadScraper,
filelionsScraper,
vTubeScraper,
];
}

View File

@ -25,6 +25,7 @@ export const doodScraper = makeEmbed({
const dataForLater = doodData.match(/\?token=([^&]+)&expiry=/)?.[1];
const path = doodData.match(/\$\.get\('\/pass_md5([^']+)/)?.[1];
const thumbnailTrack = doodData.match(/thumbnails:\s\{\s*vtt:\s'([^']*)'/);
const doodPage = await ctx.proxiedFetcher<string>(`/pass_md5${path}`, {
headers: {
@ -53,6 +54,14 @@ export const doodScraper = makeEmbed({
headers: {
Referer: baseUrl,
},
...(thumbnailTrack
? {
thumbnailTrack: {
type: 'vtt',
url: `https:${thumbnailTrack[1]}`,
},
}
: {}),
},
],
};

View File

@ -0,0 +1,52 @@
import { unpack } from 'unpacker';
import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '../base';
const evalCodeRegex = /eval\((.*)\)/g;
const fileRegex = /file:"(.*?)"/g;
const tracksRegex = /\{file:"([^"]+)",kind:"thumbnails"\}/g;
export const droploadScraper = makeEmbed({
id: 'dropload',
name: 'Dropload',
rank: 120,
scrape: async (ctx) => {
const mainPageRes = await ctx.proxiedFetcher.full<string>(ctx.url, {
headers: {
referer: ctx.url,
},
});
const mainPageUrl = new URL(mainPageRes.finalUrl);
const mainPage = mainPageRes.body;
const evalCode = mainPage.match(evalCodeRegex);
if (!evalCode) throw new Error('Failed to find eval code');
const unpacked = unpack(evalCode[1]);
const file = fileRegex.exec(unpacked);
const thumbnailTrack = tracksRegex.exec(unpacked);
if (!file?.[1]) throw new Error('Failed to find file');
return {
stream: [
{
id: 'primary',
type: 'hls',
playlist: file[1],
flags: [flags.IP_LOCKED, flags.CORS_ALLOWED],
captions: [],
...(thumbnailTrack
? {
thumbnailTrack: {
type: 'vtt',
url: mainPageUrl.origin + thumbnailTrack[1],
},
}
: {}),
},
],
};
},
});

View File

@ -0,0 +1,47 @@
import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '@/providers/base';
const linkRegex = /file: ?"(http.*?)"/;
// the white space charecters may seem useless, but without them it breaks
const tracksRegex = /\{file:\s"([^"]+)",\skind:\s"thumbnails"\}/g;
export const filelionsScraper = makeEmbed({
id: 'filelions',
name: 'filelions',
rank: 115,
async scrape(ctx) {
const mainPageRes = await ctx.proxiedFetcher.full<string>(ctx.url, {
headers: {
referer: ctx.url,
},
});
const mainPage = mainPageRes.body;
const mainPageUrl = new URL(mainPageRes.finalUrl);
const streamUrl = mainPage.match(linkRegex) ?? [];
const thumbnailTrack = tracksRegex.exec(mainPage);
const playlist = streamUrl[1];
if (!playlist) throw new Error('Stream url not found');
return {
stream: [
{
id: 'primary',
type: 'hls',
playlist,
flags: [flags.IP_LOCKED, flags.CORS_ALLOWED],
captions: [],
...(thumbnailTrack
? {
thumbnailTrack: {
type: 'vtt',
url: mainPageUrl.origin + thumbnailTrack[1],
},
}
: {}),
},
],
};
},
});

View File

@ -1,5 +1,6 @@
import * as unpacker from 'unpacker';
import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '@/providers/base';
const mixdropBase = 'https://mixdrop.ag';
@ -47,7 +48,7 @@ export const mixdropScraper = makeEmbed({
{
id: 'primary',
type: 'file',
flags: [],
flags: [flags.IP_LOCKED],
captions: [],
qualities: {
unknown: {

View File

@ -2,15 +2,18 @@ import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '@/providers/base';
const linkRegex = /'hls': ?'(http.*?)',/;
const tracksRegex = /previewThumbnails:\s{.*src:\["([^"]+)"]/;
export const voeScraper = makeEmbed({
id: 'voe',
name: 'voe.sx',
rank: 180,
async scrape(ctx) {
const embed = await ctx.proxiedFetcher<string>(ctx.url);
const embedRes = await ctx.proxiedFetcher.full<string>(ctx.url);
const embed = embedRes.body;
const playerSrc = embed.match(linkRegex) ?? [];
const thumbnailTrack = embed.match(tracksRegex);
const streamUrl = playerSrc[1];
if (!streamUrl) throw new Error('Stream url not found in embed code');
@ -21,11 +24,19 @@ export const voeScraper = makeEmbed({
type: 'hls',
id: 'primary',
playlist: streamUrl,
flags: [flags.CORS_ALLOWED],
flags: [flags.CORS_ALLOWED, flags.IP_LOCKED],
captions: [],
headers: {
Referer: 'https://voe.sx',
},
...(thumbnailTrack
? {
thumbnailTrack: {
type: 'vtt',
url: new URL(embedRes.finalUrl).origin + thumbnailTrack[1],
},
}
: {}),
},
],
};

View File

@ -0,0 +1,51 @@
import { load } from 'cheerio';
import { unpack } from 'unpacker';
import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '../base';
const evalCodeRegex = /eval\((.*)\)/g;
const fileRegex = /file:"(.*?)"/g;
const tracksRegex = /\{file:"([^"]+)",kind:"thumbnails"\}/g;
export const vTubeScraper = makeEmbed({
id: 'vtube',
name: 'vTube',
rank: 145,
scrape: async (ctx) => {
const mainPageRes = await ctx.proxiedFetcher.full<string>(ctx.url, {
headers: {
referer: ctx.url,
},
});
const mainPage = mainPageRes.body;
const html = load(mainPage);
const evalCode = html('script').text().match(evalCodeRegex);
if (!evalCode) throw new Error('Failed to find eval code');
const unpacked = unpack(evalCode?.toString());
const file = fileRegex.exec(unpacked);
const thumbnailTrack = tracksRegex.exec(unpacked);
if (!file?.[1]) throw new Error('Failed to find file');
return {
stream: [
{
id: 'primary',
type: 'hls',
playlist: file[1],
flags: [flags.CORS_ALLOWED],
captions: [],
...(thumbnailTrack
? {
thumbnailTrack: {
type: 'vtt',
url: new URL(mainPageRes.finalUrl).origin + thumbnailTrack[1],
},
}
: {}),
},
],
};
},
});

View File

@ -54,6 +54,15 @@ async function getStreams(title: string) {
case 'dood.watch':
embedId = 'dood';
break;
case 'dropload.io':
embedId = 'dropload';
break;
case 'filelions.to':
embedId = 'filelions';
break;
case 'vtube.to':
embedId = 'vtube';
break;
default:
embedId = null;
}