mirror of
https://github.com/sussy-code/providers.git
synced 2026-03-11 17:55:37 +00:00
hopefully futureproof enough this time
This commit is contained in:
parent
1b1940b390
commit
1549f84df0
1 changed files with 13 additions and 31 deletions
|
|
@ -1,8 +1,5 @@
|
||||||
import JSON5 from 'json5';
|
|
||||||
|
|
||||||
import { flags } from '@/entrypoint/utils/targets';
|
import { flags } from '@/entrypoint/utils/targets';
|
||||||
import { SourcererOutput, makeSourcerer } from '@/providers/base';
|
import { SourcererOutput, makeSourcerer } from '@/providers/base';
|
||||||
import { Caption, labelToLanguageCode } from '@/providers/captions';
|
|
||||||
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
||||||
import { NotFoundError } from '@/utils/errors';
|
import { NotFoundError } from '@/utils/errors';
|
||||||
|
|
||||||
|
|
@ -10,41 +7,26 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis
|
||||||
const embedPage = await ctx.proxiedFetcher(
|
const embedPage = await ctx.proxiedFetcher(
|
||||||
`https://vidsrc.su/embed/${ctx.media.type === 'movie' ? `movie/${ctx.media.tmdbId}` : `tv/${ctx.media.tmdbId}/${ctx.media.season.number}/${ctx.media.episode.number}`}`,
|
`https://vidsrc.su/embed/${ctx.media.type === 'movie' ? `movie/${ctx.media.tmdbId}` : `tv/${ctx.media.tmdbId}/${ctx.media.season.number}/${ctx.media.episode.number}`}`,
|
||||||
);
|
);
|
||||||
const serverDataMatch = embedPage.match(/const fixedServers = +(\[.*?\])/s);
|
|
||||||
if (!serverDataMatch[1]) throw new NotFoundError('No data found');
|
const servers = [...embedPage.matchAll(/label: 'Server (1|2|3)', url: '(https.*)'/g)] // only server 1,2 and 3 are flixhq
|
||||||
// const servers: { label: string; url: string }[] = JSON.parse(serverDataMatch[1].replace(/([a-zA-Z0-9_]+): /g, '"$1":').replace(/'/g, '"').replace(/,\s*\]$/, ']'))
|
.sort((a, b) => {
|
||||||
const servers: { label: string; url: string }[] = JSON5.parse(serverDataMatch[1]);
|
// ranking for servers
|
||||||
let playlist;
|
const ranks: Record<string, number> = { '1': 10, '2': 30, '3': 20 }; // server 2 > 3 > 1
|
||||||
// we only want flixhq which is server 1 and server 2
|
return ranks[b[1]] - ranks[a[1]];
|
||||||
servers.forEach((server) => {
|
})
|
||||||
if (['Server 1', 'Server 2', 'Server 3'].includes(server.label) && server.url) playlist = server.url;
|
.map((x) => x[2]);
|
||||||
});
|
|
||||||
if (!playlist) throw new NotFoundError('No flixhq playlist found');
|
if (!servers[0]) throw new NotFoundError('No flixhq playlist found');
|
||||||
const captionsDataMatch = embedPage.match(/const subtitles = +(\[.*?\])/s);
|
|
||||||
const captions: Caption[] = [];
|
|
||||||
if (captionsDataMatch[1]) {
|
|
||||||
const captionsData: { label: string; file: string }[] = JSON5.parse(captionsDataMatch[1]);
|
|
||||||
for (const caption of captionsData) {
|
|
||||||
const language = labelToLanguageCode(caption.label);
|
|
||||||
if (!language) continue;
|
|
||||||
captions.push({
|
|
||||||
id: caption.file,
|
|
||||||
url: caption.file,
|
|
||||||
type: 'vtt',
|
|
||||||
hasCorsRestrictions: false,
|
|
||||||
language,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
embeds: [],
|
embeds: [],
|
||||||
stream: [
|
stream: [
|
||||||
{
|
{
|
||||||
id: 'primary',
|
id: 'primary',
|
||||||
playlist,
|
playlist: servers[0],
|
||||||
type: 'hls',
|
type: 'hls',
|
||||||
flags: [flags.CORS_ALLOWED],
|
flags: [flags.CORS_ALLOWED],
|
||||||
captions,
|
captions: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue