Improve playlist download stability by skipping failed tracks
Added try-catch blocks in downloadPlaylistAsZip, downloadAlbumAsZip, and downloadDiscography to handle individual track download failures gracefully. Errors are now logged to the console, and the download process continues for the remaining tracks.
This commit is contained in:
parent
c5d4160e77
commit
2ae6b620f2
1 changed files with 89 additions and 77 deletions
|
|
@ -244,10 +244,10 @@ export async function downloadAlbumAsZip(album, tracks, api, quality, lyricsMana
|
|||
|
||||
updateBulkDownloadProgress(notification, i, tracks.length, trackTitle);
|
||||
|
||||
try {
|
||||
const blob = await downloadTrackBlob(track, quality, api);
|
||||
zip.file(`${folderName}/${filename}`, blob);
|
||||
|
||||
|
||||
try {
|
||||
const meta = buildTrackMetadata(track, api);
|
||||
const metaFilename = filename.replace(/\.[^.]+$/, '.json');
|
||||
|
|
@ -276,6 +276,9 @@ export async function downloadAlbumAsZip(album, tracks, api, quality, lyricsMana
|
|||
console.log('Could not add lyrics for:', trackTitle);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Failed to download track ${trackTitle}:`, err);
|
||||
}
|
||||
}
|
||||
|
||||
updateBulkDownloadProgress(notification, tracks.length, tracks.length, 'Creating ZIP...');
|
||||
|
|
@ -323,6 +326,7 @@ export async function downloadPlaylistAsZip(playlist, tracks, api, quality, lyri
|
|||
|
||||
updateBulkDownloadProgress(notification, i, tracks.length, trackTitle);
|
||||
|
||||
try {
|
||||
const blob = await downloadTrackBlob(track, quality, api);
|
||||
zip.file(`${folderName}/${filename}`, blob);
|
||||
|
||||
|
|
@ -354,6 +358,9 @@ export async function downloadPlaylistAsZip(playlist, tracks, api, quality, lyri
|
|||
console.log('Could not add lyrics for:', trackTitle);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Failed to download track ${trackTitle}:`, err);
|
||||
}
|
||||
}
|
||||
|
||||
updateBulkDownloadProgress(notification, tracks.length, tracks.length, 'Creating ZIP...');
|
||||
|
|
@ -410,6 +417,8 @@ export async function downloadDiscography(artist, api, quality, lyricsManager =
|
|||
|
||||
for (const track of tracks) {
|
||||
const filename = buildTrackFilename(track, quality);
|
||||
|
||||
try {
|
||||
const blob = await downloadTrackBlob(track, quality, api);
|
||||
zip.file(`${rootFolder}/${albumFolder}/${filename}`, blob);
|
||||
|
||||
|
|
@ -439,6 +448,9 @@ export async function downloadDiscography(artist, api, quality, lyricsManager =
|
|||
console.log('Could not add lyrics for:', track.title);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Failed to download track ${track.title} in album ${album.title}:`, err);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to download album ${album.title}:`, error);
|
||||
|
|
|
|||
Loading…
Reference in a new issue