Fix warezcdn

This commit is contained in:
TPN 2024-12-08 12:01:29 +00:00
parent 1010fc5882
commit a2c8784369
No known key found for this signature in database
GPG key ID: 40AE091637892B91
3 changed files with 83 additions and 87 deletions

View file

@ -1,8 +1,8 @@
import { ScrapeContext } from '@/utils/context'; import { ScrapeContext } from '@/utils/context';
export const warezcdnBase = 'https://embed.warezcdn.com'; export const warezcdnBase = 'https://embed.warezcdn.link';
export const warezcdnApiBase = 'https://warezcdn.com/embed'; export const warezcdnApiBase = 'https://warezcdn.link/embed';
export const warezcdnPlayerBase = 'https://warezcdn.com/player'; export const warezcdnPlayerBase = 'https://warezcdn.link/player';
export const warezcdnWorkerProxy = 'https://workerproxy.warezcdn.workers.dev'; export const warezcdnWorkerProxy = 'https://workerproxy.warezcdn.workers.dev';
export async function getExternalPlayerUrl(ctx: ScrapeContext, embedId: string, embedUrl: string) { export async function getExternalPlayerUrl(ctx: ScrapeContext, embedId: string, embedUrl: string) {

View file

@ -1,15 +1,51 @@
import { load } from 'cheerio';
import { flags } from '@/entrypoint/utils/targets'; import { flags } from '@/entrypoint/utils/targets';
import { SourcererEmbed, makeSourcerer } from '@/providers/base'; import { SourcererEmbed, makeSourcerer } from '@/providers/base';
import { mixdropScraper } from '@/providers/embeds/mixdrop'; import { mixdropScraper } from '@/providers/embeds/mixdrop';
import { warezcdnembedHlsScraper } from '@/providers/embeds/warezcdn/hls'; import { warezcdnembedHlsScraper } from '@/providers/embeds/warezcdn/hls';
import { warezcdnembedMp4Scraper } from '@/providers/embeds/warezcdn/mp4'; import { warezcdnembedMp4Scraper } from '@/providers/embeds/warezcdn/mp4';
import { warezPlayerScraper } from '@/providers/embeds/warezcdn/warezplayer'; import { warezPlayerScraper } from '@/providers/embeds/warezcdn/warezplayer';
import { ScrapeContext } from '@/utils/context';
import { NotFoundError } from '@/utils/errors'; import { NotFoundError } from '@/utils/errors';
import { getExternalPlayerUrl, warezcdnBase } from './common'; import { warezcdnBase } from './common';
import { SerieAjaxResponse } from './types'; import { cachedSeasonsRes } from './types';
async function getEmbeds(id: string, servers: string, ctx: ScrapeContext): Promise<SourcererEmbed[]> {
const embeds: SourcererEmbed[] = [];
for (const server of servers.split(',')) {
if (server === 'warezcdn') {
embeds.push(
{ embedId: warezcdnembedHlsScraper.id, url: id },
{ embedId: warezcdnembedMp4Scraper.id, url: id },
{ embedId: warezPlayerScraper.id, url: id },
);
} else if (server === 'mixdrop') {
// Without this req, the next one fails
await ctx.proxiedFetcher<string>(`/getEmbed.php`, {
baseUrl: warezcdnBase,
headers: {
Referer: `${warezcdnBase}/getEmbed.php?${new URLSearchParams({ id, sv: 'mixdrop' })}`,
},
method: 'HEAD',
query: { id, sv: 'mixdrop' },
});
const embedPage = await ctx.proxiedFetcher<string>(`/getPlay.php`, {
baseUrl: warezcdnBase,
headers: {
Referer: `${warezcdnBase}/getEmbed.php?${new URLSearchParams({ id, sv: 'mixdrop' })}`,
},
query: { id, sv: 'mixdrop' },
});
const url = embedPage.match(/window.location.href\s*=\s*"([^"]+)"/)?.[1];
if (url) embeds.push({ embedId: mixdropScraper.id, url });
}
}
return embeds;
}
export const warezcdnScraper = makeSourcerer({ export const warezcdnScraper = makeSourcerer({
id: 'warezcdn', id: 'warezcdn',
@ -18,44 +54,14 @@ export const warezcdnScraper = makeSourcerer({
flags: [flags.CORS_ALLOWED], flags: [flags.CORS_ALLOWED],
scrapeMovie: async (ctx) => { scrapeMovie: async (ctx) => {
if (!ctx.media.imdbId) throw new NotFoundError('This source requires IMDB id.'); if (!ctx.media.imdbId) throw new NotFoundError('This source requires IMDB id.');
const serversPage = await ctx.proxiedFetcher<string>(`/filme/${ctx.media.imdbId}`, { const serversPage = await ctx.proxiedFetcher<string>(`/filme/${ctx.media.imdbId}`, {
baseUrl: warezcdnBase, baseUrl: warezcdnBase,
}); });
const $ = load(serversPage);
const embedsHost = $('.hostList.active [data-load-embed]').get(); const [, id, servers] = serversPage.match(/let\s+data\s*=\s*'\[\s*\{\s*"id":"([^"]+)".*?"servers":"([^"]+)"/)!;
if (!id || !servers) throw new NotFoundError('Failed to find episode id');
const embeds: SourcererEmbed[] = []; const embeds: SourcererEmbed[] = await getEmbeds(id, servers, ctx);
embedsHost.forEach(async (element) => {
const embedHost = $(element).attr('data-load-embed-host')!;
const embedUrl = $(element).attr('data-load-embed')!;
if (embedHost === 'mixdrop') {
const realEmbedUrl = await getExternalPlayerUrl(ctx, 'mixdrop', embedUrl);
if (!realEmbedUrl) throw new Error('Could not find embed url');
embeds.push({
embedId: mixdropScraper.id,
url: realEmbedUrl,
});
} else if (embedHost === 'warezcdn') {
embeds.push(
{
embedId: warezcdnembedHlsScraper.id,
url: embedUrl,
},
{
embedId: warezcdnembedMp4Scraper.id,
url: embedUrl,
},
{
embedId: warezPlayerScraper.id,
url: embedUrl,
},
);
}
});
return { return {
embeds, embeds,
@ -63,54 +69,38 @@ export const warezcdnScraper = makeSourcerer({
}, },
scrapeShow: async (ctx) => { scrapeShow: async (ctx) => {
if (!ctx.media.imdbId) throw new NotFoundError('This source requires IMDB id.'); if (!ctx.media.imdbId) throw new NotFoundError('This source requires IMDB id.');
const url = `${warezcdnBase}/serie/${ctx.media.imdbId}/${ctx.media.season.number}/${ctx.media.episode.number}`; const url = `${warezcdnBase}/serie/${ctx.media.imdbId}/${ctx.media.season.number}/${ctx.media.episode.number}`;
const serversPage = await ctx.proxiedFetcher<string>(url); const serversPage = await ctx.proxiedFetcher<string>(url);
const episodeId = serversPage.match(/\$\('\[data-load-episode-content="(\d+)"\]'\)/)?.[1]; const seasonsApi = serversPage.match(/var\s+cachedSeasons\s*=\s*"([^"]+)"/)?.[1];
if (!seasonsApi) throw new NotFoundError('Failed to find data');
if (!episodeId) throw new NotFoundError('Failed to find episode id'); const streamsData = await ctx.proxiedFetcher<cachedSeasonsRes>(seasonsApi, {
const streamsData = await ctx.proxiedFetcher<string>(`/serieAjax.php`, {
method: 'POST',
baseUrl: warezcdnBase, baseUrl: warezcdnBase,
body: new URLSearchParams({
getAudios: episodeId,
}),
headers: { headers: {
Origin: warezcdnBase,
Referer: url, Referer: url,
'X-Requested-With': 'XMLHttpRequest', 'X-Requested-With': 'XMLHttpRequest',
}, },
}); });
const streams: SerieAjaxResponse = JSON.parse(streamsData); const season = Object.values(streamsData.seasons).find((s) => s.name === ctx.media.season.number.toString());
const list = streams.list['0']; if (!season) throw new NotFoundError('Failed to find season id');
const embeds: SourcererEmbed[] = []; const episode = Object.values(season.episodes).find((e) => e.name === ctx.media.season.number.toString())?.id;
if (!episode) throw new NotFoundError('Failed to find episode id');
// 3 means ok const episodeData = await ctx.proxiedFetcher<string>('/core/ajax.php', {
if (list.mixdropStatus === '3') { baseUrl: warezcdnBase,
const realEmbedUrl = await getExternalPlayerUrl(ctx, 'mixdrop', list.id); headers: {
if (!realEmbedUrl) throw new Error('Could not find embed url'); Referer: url,
embeds.push({ 'X-Requested-With': 'XMLHttpRequest',
embedId: mixdropScraper.id, },
url: realEmbedUrl, query: { audios: episode },
}); });
}
if (list.warezcdnStatus === '3') { const [, id, servers] = episodeData.replace(/\\"/g, '"').match(/"\[\s*\{\s*"id":"([^"]+)".*?"servers":"([^"]+)"/)!;
embeds.push( if (!id || !servers) throw new NotFoundError('Failed to find episode id');
{
embedId: warezcdnembedHlsScraper.id, const embeds: SourcererEmbed[] = await getEmbeds(id, servers, ctx);
url: list.id,
},
{
embedId: warezcdnembedMp4Scraper.id,
url: list.id,
},
);
}
return { return {
embeds, embeds,

View file

@ -1,16 +1,22 @@
interface Data { interface Episode {
id: string; id: string;
audio: string; name: string;
mixdropStatus: string; editedName: string | null;
fembedStatus: string; released: string;
streamtapeStatus: string; titlePt: string;
warezcdnStatus: string; rating: string;
runtime: string;
airdate: string;
} }
type List = { interface Season {
[key: string]: Data; id: string;
}; name: string;
episodesCount: number;
export interface SerieAjaxResponse { episodes: Record<string, Episode>;
list: List; }
export interface cachedSeasonsRes {
seasonCount: number;
seasons: Record<string, Season>;
} }