diff --git a/src/providers/embeds/turbovid.ts b/src/providers/embeds/turbovid.ts index 184fd15..717a2da 100644 --- a/src/providers/embeds/turbovid.ts +++ b/src/providers/embeds/turbovid.ts @@ -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 { diff --git a/src/providers/sources/catflix.ts b/src/providers/sources/catflix.ts index 0f10bc7..03c9456 100644 --- a/src/providers/sources/catflix.ts +++ b/src/providers/sources/catflix.ts @@ -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: [ {