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,36 +636,43 @@ 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
} }
const found = subPlaylist.data.subtitles.find((sub) => sub.language === s) if (subPlaylist) {
if (found) { const found = subPlaylist.data.subtitles.find((sub) => sub.language === s)
subDownloadList.push({ ...found, isDub: false }) if (found) {
console.log(`Subtitle ${s}.ass found, adding to download`) subDownloadList.push({ ...found, isDub: false })
server.logger.log({ console.log(`Subtitle ${s}.ass found, adding to download`)
level: 'info', server.logger.log({
message: `Subtitle ${s}.ass found in Download ${downloadID}, adding to download`, level: 'info',
timestamp: new Date().toISOString(), message: `Subtitle ${s}.ass found in Download ${downloadID}, adding to download`,
section: 'crunchyrollDownloadProcessSubtitles' timestamp: new Date().toISOString(),
}) section: 'crunchyrollDownloadProcessSubtitles'
} else { })
console.warn(`Subtitle ${s}.ass not found, skipping`) } else {
server.logger.log({ console.warn(`Subtitle ${s}.ass not found, skipping`)
level: 'warn', server.logger.log({
message: `Subtitle ${s}.ass not found in Download ${downloadID}, skipping`, level: 'warn',
timestamp: new Date().toISOString(), message: `Subtitle ${s}.ass not found in Download ${downloadID}, skipping`,
section: 'crunchyrollDownloadProcessSubtitles' timestamp: new Date().toISOString(),
}) section: 'crunchyrollDownloadProcessSubtitles'
})
}
} }
} }