Add context progress calls for catflix

This commit is contained in:
TPN 2024-06-16 15:08:41 +05:30
parent d2233481c2
commit 837a6da0b4
No known key found for this signature in database
GPG key ID: 40AE091637892B91
2 changed files with 14 additions and 0 deletions

View file

@ -22,6 +22,8 @@ export const turbovidScraper = makeEmbed({
const baseUrl = new URL(ctx.url).origin;
const embedPage = await ctx.proxiedFetcher(ctx.url);
ctx.progress(30);
// the whitespace is for future-proofing the regex a bit
const apkey = embedPage.match(/const\s+apkey\s*=\s*"(.*?)";/)?.[1];
const xxid = embedPage.match(/const\s+xxid\s*=\s*"(.*?)";/)?.[1];
@ -40,6 +42,8 @@ export const turbovidScraper = makeEmbed({
if (!juiceKey) throw new Error('Failed to fetch the key');
ctx.progress(60);
const data = JSON.parse(
await ctx.proxiedFetcher('/api/cucked/the_juice/', {
baseUrl,
@ -54,6 +58,8 @@ export const turbovidScraper = makeEmbed({
if (!data) throw new Error('Failed to fetch required data');
ctx.progress(90);
const playlist = decrypt(data, juiceKey);
return {

View file

@ -15,6 +15,8 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis
},
});
ctx.progress(40);
const $search = load(searchPage);
const searchResults: { title: string; year?: number | undefined; url: string }[] = [];
@ -32,6 +34,8 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis
let watchPageUrl = searchResults.find((x) => x && compareMedia(ctx.media, x.title, x.year))?.url;
if (!watchPageUrl) throw new NotFoundError('No watchable item found');
ctx.progress(60);
if (ctx.media.type === 'show') {
const match = watchPageUrl.match(/\/series\/([^/]+)\/?/);
if (!match) throw new Error('Failed to parse watch page url');
@ -43,9 +47,13 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis
const watchPage = load(await ctx.proxiedFetcher(watchPageUrl));
ctx.progress(80);
const url = watchPage('iframe').first().attr('src'); // I couldn't think of a better way
if (!url) throw new Error('Failed to find embed url');
ctx.progress(90);
return {
embeds: [
{