fix: fix download crashing if subtitle playlist not found

This commit is contained in:
stratuma 2024-06-22 13:57:02 +02:00
parent 37ad5233e4
commit 7309457103

View File

@ -636,18 +636,24 @@ export async function downloadCrunchyrollPlaylist(
} }
if (!subPlaylist) { if (!subPlaylist) {
await updatePlaylistByID(downloadID, 'failed') console.log(`Subtitle Playlist for ${s} not found, skipping`)
console.log('Subtitle Playlist not found') messageBox(
messageBox('error', ['Cancel'], 2, 'Subtitle Playlist not found', 'Subtitle Playlist not found', 'Subtitle Playlist not found') 'warning',
['Cancel'],
2,
`Subtitle Playlist for ${s} not found`,
`Subtitle Playlist for ${s} not found`,
`Sub Playlist for ${s} not found, skipping download`
)
server.logger.log({ server.logger.log({
level: 'error', level: 'error',
message: 'Subtitle Playlist not found', message: `Subtitle Playlist for ${s} not found, skipping`,
timestamp: new Date().toISOString(), timestamp: new Date().toISOString(),
section: 'crunchyrollDownloadProcess' section: 'crunchyrollSubtitleDownloadProcess'
}) })
return
} }
if (subPlaylist) {
const found = subPlaylist.data.subtitles.find((sub) => sub.language === s) const found = subPlaylist.data.subtitles.find((sub) => sub.language === s)
if (found) { if (found) {
subDownloadList.push({ ...found, isDub: false }) subDownloadList.push({ ...found, isDub: false })
@ -668,6 +674,7 @@ export async function downloadCrunchyrollPlaylist(
}) })
} }
} }
}
await updatePlaylistByID(downloadID, 'waiting for dub playlist') await updatePlaylistByID(downloadID, 'waiting for dub playlist')