Add vidker embed

This commit is contained in:
TPN 2024-07-17 13:39:40 +01:00
parent 5735b4cd87
commit 178e181bba
No known key found for this signature in database
GPG key ID: 40AE091637892B91
3 changed files with 66 additions and 1 deletions

View file

@ -11,6 +11,7 @@ import { streamsbScraper } from '@/providers/embeds/streamsb';
import { turbovidScraper } from '@/providers/embeds/turbovid';
import { upcloudScraper } from '@/providers/embeds/upcloud';
import { upstreamScraper } from '@/providers/embeds/upstream';
import { vidkerScraper } from '@/providers/embeds/vidker';
import { vidsrcembedScraper } from '@/providers/embeds/vidsrc';
import { vTubeScraper } from '@/providers/embeds/vtube';
import { astraScraper, novaScraper } from '@/providers/embeds/whvx';
@ -144,5 +145,6 @@ export function gatherAllEmbeds(): Array<Embed> {
turbovidScraper,
novaScraper,
astraScraper,
vidkerScraper,
];
}

View file

@ -0,0 +1,62 @@
import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '@/providers/base';
import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '@/providers/captions';
import { FileBasedStream } from '@/providers/streams';
import { getValidQualityFromString } from '@/utils/quality';
export const vidkerScraper = makeEmbed({
id: 'vidker',
name: 'VidKer',
rank: 93,
async scrape(ctx) {
const embed = await ctx.proxiedFetcher<string>(ctx.url);
const sourcesMatch = embed.match(/sources:\s*(\[.*?\])/)?.[1];
const tracksMatch = embed.match(/tracks:\s*(\[[^\]]*\])/)?.[1];
if (!sourcesMatch) throw new Error('No sources found');
const sources: { file: string; label: string }[] = JSON.parse(sourcesMatch.replace(/(\w+):"(\S*?)"/g, '"$1":"$2"'));
const tracks: { file: string; label: string }[] = JSON.parse(
tracksMatch?.replace(/\s+/g, '').replace(/(\w+):"(\S*?)"/g, '"$1":"$2"') ?? '[]',
);
const qualities = sources.reduce(
(acc, source) => {
const validQuality = getValidQualityFromString(source.label);
acc[validQuality] = {
type: 'mp4',
url: `${source.file}`,
};
return acc;
},
{} as FileBasedStream['qualities'],
);
const captions: Caption[] = [];
for (const caption of tracks) {
const language = labelToLanguageCode(caption.label);
const captionType = getCaptionTypeFromUrl(caption.file);
if (!language || !captionType) continue;
captions.push({
id: caption.file,
url: caption.file,
type: captionType,
language,
hasCorsRestrictions: false,
});
}
return {
stream: [
{
id: 'primary',
type: 'file',
qualities,
flags: [flags.CORS_ALLOWED],
captions,
},
],
};
},
});

View file

@ -4,6 +4,7 @@
// and i dont feel like doing that now
import { load } from 'cheerio';
import { flags } from '@/entrypoint/utils/targets';
import { SourcererEmbed, SourcererOutput, makeSourcerer } from '@/providers/base';
import { compareMedia } from '@/utils/compare';
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
@ -89,6 +90,6 @@ export const moviplusScraper = makeSourcerer({
id: 'moviplus',
name: 'MoviPlus',
rank: 92,
flags: [],
flags: [flags.CORS_ALLOWED],
scrapeMovie: comboScraper,
});