From b555f6c772f1470b565e5c283a4cd32b5561da8a Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Wed, 12 Mar 2025 11:37:06 -0600 Subject: [PATCH] better error handling uira.live --- src/providers/sources/uiralive.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/providers/sources/uiralive.ts b/src/providers/sources/uiralive.ts index 861c77e..a70c6b3 100644 --- a/src/providers/sources/uiralive.ts +++ b/src/providers/sources/uiralive.ts @@ -11,21 +11,33 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis ctx.media.type === 'movie' ? '' : `?s=${ctx.media.season.number}&e=${ctx.media.episode.number}` }`; - let result = await ctx.fetcher(fetchUrl); + let result; + try { + result = await ctx.fetcher(fetchUrl); + } catch (e: any) { + if (e instanceof NotFoundError) throw new NotFoundError(`uiralive: ${e.message}`); + throw e; + } - if (!result?.sources || result.sources.length === 0) { + if (!result) { try { result = await ctx.fetcher(fetchUrl); } catch (e: any) { - if (e instanceof NotFoundError) throw new NotFoundError(e.message); + if (e instanceof NotFoundError) throw new NotFoundError(`uiralive: ${e.message}`); throw e; } } - if (!result?.sources || result.sources.length === 0) throw new NotFoundError('No sources found'); + if (!result || !result.sources || result.sources.length === 0) { + throw new NotFoundError('uiralive: No sources found'); + } ctx.progress(90); + if (!result.sources[0].url) { + throw new Error('uiralive: Source URL is missing'); + } + return { embeds: [], stream: [ @@ -34,7 +46,7 @@ async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promis playlist: result.sources[0].url, type: 'hls', flags: [flags.CORS_ALLOWED], - captions: [], + captions: result.captions || [], }, ], };