Scrape every vidsrcsu server

This commit is contained in:
Pas 2025-01-28 11:59:59 -07:00
parent 0fa94d9c7b
commit 87a603e013
3 changed files with 154 additions and 30 deletions

View file

@ -59,6 +59,19 @@ import { streamtapeScraper } from './embeds/streamtape';
import { streamvidScraper } from './embeds/streamvid';
import { vidCloudScraper } from './embeds/vidcloud';
import { vidplayScraper } from './embeds/vidplay';
import {
VidsrcsuServer10Scraper,
VidsrcsuServer11Scraper,
VidsrcsuServer1Scraper,
VidsrcsuServer2Scraper,
VidsrcsuServer3Scraper,
VidsrcsuServer4Scraper,
VidsrcsuServer5Scraper,
VidsrcsuServer6Scraper,
VidsrcsuServer7Scraper,
VidsrcsuServer8Scraper,
VidsrcsuServer9Scraper,
} from './embeds/vidsrcsu';
import { voeScraper } from './embeds/voe';
import { warezcdnembedHlsScraper } from './embeds/warezcdn/hls';
import { warezcdnembedMp4Scraper } from './embeds/warezcdn/mp4';
@ -162,5 +175,16 @@ export function gatherAllEmbeds(): Array<Embed> {
streamwishScraper,
mp4hydraServer1Scraper,
mp4hydraServer2Scraper,
VidsrcsuServer1Scraper,
VidsrcsuServer2Scraper,
VidsrcsuServer3Scraper,
VidsrcsuServer4Scraper,
VidsrcsuServer5Scraper,
VidsrcsuServer6Scraper,
VidsrcsuServer7Scraper,
VidsrcsuServer8Scraper,
VidsrcsuServer9Scraper,
VidsrcsuServer10Scraper,
VidsrcsuServer11Scraper,
];
}

View file

@ -0,0 +1,88 @@
import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '@/providers/base';
const providers = [
{
id: 'server-1',
rank: 102,
},
{
id: 'server-2',
rank: 92,
},
{
id: 'server-3',
rank: 82,
},
{
id: 'server-4',
rank: 72,
},
{
id: 'server-5',
rank: 62,
},
{
id: 'server-6',
rank: 52,
},
{
id: 'server-7',
rank: 42,
},
{
id: 'server-8',
rank: 32,
},
{
id: 'server-9',
rank: 22,
},
{
id: 'server-10',
rank: 12,
},
{
id: 'server-11',
rank: 2,
},
];
function embed(provider: { id: string; rank: number; disabled?: boolean }) {
return makeEmbed({
id: provider.id,
name: provider.id
.split('-')
.map((word) => word[0].toUpperCase() + word.slice(1))
.join(' '),
disabled: provider.disabled,
rank: provider.rank,
async scrape(ctx) {
return {
stream: [
{
id: 'primary',
type: 'hls',
playlist: ctx.url,
flags: [flags.CORS_ALLOWED],
captions: [],
},
],
};
},
});
}
export const [
VidsrcsuServer1Scraper,
VidsrcsuServer2Scraper,
VidsrcsuServer3Scraper,
VidsrcsuServer4Scraper,
VidsrcsuServer5Scraper,
VidsrcsuServer6Scraper,
VidsrcsuServer7Scraper,
VidsrcsuServer8Scraper,
VidsrcsuServer9Scraper,
VidsrcsuServer10Scraper,
VidsrcsuServer11Scraper,
] = providers.map(embed);

View file

@ -1,5 +1,5 @@
import { flags } from '@/entrypoint/utils/targets';
import { SourcererOutput, makeSourcerer } from '@/providers/base';
import { SourcererEmbed, SourcererOutput, makeSourcerer } from '@/providers/base';
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
import { NotFoundError } from '@/utils/errors';
@ -7,38 +7,20 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis
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}`}`,
);
const servers = [...embedPage.matchAll(/label: 'Server (1|2|3|5|7|8|10|11)', url: '(https.*)'/g)] // only server 1,2 and 3 are flixhq
.sort((a, b) => {
// ranking for servers
const ranks: Record<string, number> = {
'7': 10,
'11': 20,
'10': 30,
'1': 40,
'3': 50,
'2': 60,
'5': 70,
'8': 80,
}; // server 8 > 5 > 2 ...
return ranks[b[1]] - ranks[a[1]];
})
.map((x) => x[2]);
if (!servers[0]) throw new NotFoundError('No flixhq playlist found');
const servers = [...embedPage.matchAll(/label: 'Server \d+', url: '(https.*)'/g)] // match all server URLs
.map((x) => x[1]);
ctx.progress(60);
if (!servers.length) throw new NotFoundError('No server playlist found');
const embeds: SourcererEmbed[] = servers.map((url, index) => ({
embedId: `server-${index + 1}`,
url,
}));
ctx.progress(90);
return {
embeds: [],
stream: [
{
id: 'primary',
playlist: servers[0],
type: 'hls',
flags: [flags.CORS_ALLOWED],
captions: [],
},
],
embeds,
};
}
export const vidsrcsuScraper = makeSourcerer({
@ -49,3 +31,33 @@ export const vidsrcsuScraper = makeSourcerer({
scrapeMovie: comboScraper,
scrapeShow: comboScraper,
});
// Just to get the flixhq playlist (Server 1, 2, and 3)
// async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promise<SourcererOutput> {
// 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}`}`,
// );
// const servers = [...embedPage.matchAll(/label: 'Server (1|2|3)', url: '(https.*)'/g)] // only server 1,2 and 3 are flixhq
// .sort((a, b) => {
// // ranking for servers
// const ranks: Record<string, number> = { '1': 10, '2': 30, '3': 20 }; // server 2 > 3 > 1
// return ranks[b[1]] - ranks[a[1]];
// })
// .map((x) => x[2]);
// if (!servers[0]) throw new NotFoundError('No flixhq playlist found');
// ctx.progress(60);
// return {
// embeds: [],
// stream: [
// {
// id: 'primary',
// playlist: servers[0],
// type: 'hls',
// flags: [flags.CORS_ALLOWED],
// captions: [],
// })),
// };