From f5facc7d399e72499379dbcf76d0ed2405f7e5b7 Mon Sep 17 00:00:00 2001 From: wukko Date: Thu, 1 Aug 2024 07:43:51 +0600 Subject: [PATCH] youtube: catch cipher errors not the first and seemingly not the last time it's gonna happen --- src/localization/languages/en.json | 3 ++- src/modules/processing/services/youtube.js | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/localization/languages/en.json b/src/localization/languages/en.json index 2b10f41d..8db4585b 100644 --- a/src/localization/languages/en.json +++ b/src/localization/languages/en.json @@ -160,6 +160,7 @@ "ErrorYTAgeRestrict": "this youtube video is age-restricted, so i can't see it. try another one!", "ErrorYTLogin": "couldn't get this youtube video because it requires an account to view.\n\nthis limitation is done by google to seemingly stop scraping, affecting all 3rd party tools and even their own clients.\n\ntry again, but if issue persists, {ContactLink}.", "ErrorYTRateLimit": "i got rate limited by youtube. try again in a few seconds, but if issue persists, {ContactLink}.", - "ErrorInvalidAcceptHeader": "invalid accept header" + "ErrorInvalidAcceptHeader": "invalid accept header", + "ErrorYoutubeDecipher": "youtube updated its decipher algorithm, so i can't get the video info. try again, but if it still doesn't work, please create an issue on github." } } diff --git a/src/modules/processing/services/youtube.js b/src/modules/processing/services/youtube.js index 5aa201ce..d3ee5602 100644 --- a/src/modules/processing/services/youtube.js +++ b/src/modules/processing/services/youtube.js @@ -50,7 +50,9 @@ const transformSessionData = (cookie) => { const cloneInnertube = async (customFetch) => { const innertube = await ytBase; if (innertube instanceof Error) { - throw innertube; + if (innertube?.message?.endsWith("decipher algorithm")) { + return { error: "ErrorYoutubeDecipher" } + } else throw innertube; } const session = new Session( @@ -101,6 +103,7 @@ export default async function(o) { dispatcher: o.dispatcher }) ); + if (yt.error) return yt; const quality = o.quality === "max" ? "9000" : o.quality;