Update index.ts
Some checks failed
Testing / Testing (push) Has been cancelled

This commit is contained in:
Pas 2025-11-19 17:27:57 -07:00
parent e524125a2b
commit b03b4e9f68

View file

@ -112,15 +112,15 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis
torrentioUrl += `movie/${ctx.media.imdbId}.json`; torrentioUrl += `movie/${ctx.media.imdbId}.json`;
} }
const torrentioData = (await ctx.proxiedFetcher(torrentioUrl)) as torrentioResponse; const torrentioData = (await ctx.proxiedFetcher(torrentioUrl)) as torrentioResponse;
// console.log('torrentioData', torrentioData);
const torrentioStreams = torrentioData?.streams || []; const torrentioStreams = torrentioData?.streams || [];
// console.log('torrentioStreams', torrentioStreams);
if (torrentioStreams.length === 0) { if (torrentioStreams.length === 0) {
throw new NotFoundError('No streams found'); console.log('No torrents found', torrentioData);
throw new NotFoundError('No torrents found');
} }
ctx.progress(33);
const response: DebridParsedStream[] = await ctx.proxiedFetcher('https://torrent-parse.pstream.mov/', { const response: DebridParsedStream[] = await ctx.proxiedFetcher('https://torrent-parse.pstream.mov/', {
method: 'POST', method: 'POST',
headers: { headers: {
@ -128,6 +128,12 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis
}, },
body: JSON.stringify(torrentioStreams), body: JSON.stringify(torrentioStreams),
}); });
if (response.length === 0) {
console.log('No streams found or parse failed!', response);
throw new NotFoundError('No streams found or parse failed!');
}
ctx.progress(66);
// Group by quality, pick the most compatible stream for each // Group by quality, pick the most compatible stream for each
const qualities: Partial<Record<'4k' | 1080 | 720 | 480 | 360 | 'unknown', { type: 'mp4'; url: string }>> = {}; const qualities: Partial<Record<'4k' | 1080 | 720 | 480 | 360 | 'unknown', { type: 'mp4'; url: string }>> = {};
@ -170,6 +176,8 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis
} }
} }
ctx.progress(100);
return { return {
embeds: [], embeds: [],
stream: [ stream: [