From 9292746580fd42a8aba414e5b28db0c488255024 Mon Sep 17 00:00:00 2001 From: stratuma Date: Thu, 11 Jul 2024 20:56:11 +0200 Subject: [PATCH] fixed versions not found triggering if no dubs --- .../routes/crunchyroll/crunchyroll.service.ts | 15 +++++++------ src/api/routes/service/service.service.ts | 21 +++++-------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/api/routes/crunchyroll/crunchyroll.service.ts b/src/api/routes/crunchyroll/crunchyroll.service.ts index cabb720..60f7e49 100644 --- a/src/api/routes/crunchyroll/crunchyroll.service.ts +++ b/src/api/routes/crunchyroll/crunchyroll.service.ts @@ -232,7 +232,6 @@ async function crunchyLoginFetch(user: string, passw: string) { } export async function crunchyVersionsFetch(q: string) { - const account = await loggedInCheck('CR') if (!account) return @@ -257,13 +256,13 @@ export async function crunchyVersionsFetch(q: string) { data: { episode_metadata: { versions: { - audio_locale: string, - guid: string, - is_premium_only: boolean, - media_guid: string, - original: boolean, - season_guid: string, - variant: string, + audio_locale: string + guid: string + is_premium_only: boolean + media_guid: string + original: boolean + season_guid: string + variant: string geo: string }[] } diff --git a/src/api/routes/service/service.service.ts b/src/api/routes/service/service.service.ts index a376cab..0a6d973 100644 --- a/src/api/routes/service/service.service.ts +++ b/src/api/routes/service/service.service.ts @@ -538,17 +538,6 @@ export async function downloadCrunchyrollPlaylist( const versions = await crunchyVersionsFetch(e) - if (!versions) { - messageBox('error', ['Cancel'], 2, 'Failed to get versions', 'Failed to get versions', 'Failed to get versions') - server.logger.log({ - level: 'error', - message: `Failed to get versions ${downloadID}`, - timestamp: new Date().toISOString(), - section: 'crunchyrollDownloadProcess' - }) - return - } - var playlist = await crunchyGetPlaylist(e, geo) if (!playlist) { @@ -688,7 +677,7 @@ export async function downloadCrunchyrollPlaylist( for (const s of subs) { var subPlaylist - if (playlist.data.audioLocale !== 'ja-JP') { + if (playlist.data.audioLocale !== 'ja-JP' && versions) { const foundStream = versions.find((v) => v.audio_locale === 'ja-JP') if (foundStream) { subPlaylist = await crunchyGetPlaylist(foundStream.guid, foundStream.geo) @@ -758,7 +747,7 @@ export async function downloadCrunchyrollPlaylist( } dubDownloadList.push(found) console.log(`Audio ${d}.aac found, adding to download`) - } else if (versions.length === 0) { + } else if (!versions) { const foundSub = playlist.data.subtitles.find((sub) => sub.language === d) if (foundSub) { subDownloadList.push({ ...foundSub, isDub: true }) @@ -780,7 +769,7 @@ export async function downloadCrunchyrollPlaylist( } } - if (dubDownloadList.length === 0) { + if (dubDownloadList.length === 0 && versions) { const jpVersion = versions.find((v) => v.audio_locale === 'ja-JP') if (jpVersion) { @@ -1012,7 +1001,7 @@ export async function downloadCrunchyrollPlaylist( var hardsubGEO: string | undefined - if (hardsub.format === 'dub') { + if (hardsub.format === 'dub' && versions) { const found = versions.find((h) => h.audio_locale === hardsub.locale) if (!found) { hardsubURL = undefined @@ -1028,7 +1017,7 @@ export async function downloadCrunchyrollPlaylist( } } - if (hardsub.format === 'sub') { + if (hardsub.format === 'sub' && versions) { const found = versions.find((h) => h.audio_locale === 'ja-JP') if (!found) { hardsubURL = undefined