Added check for empty single albums

Thanks digitalec
This commit is contained in:
RemixDev 2021-06-07 14:20:48 +02:00
parent 7da4ed4572
commit 5f332f7a88

View file

@ -78,7 +78,11 @@ async function generateAlbumItem(dz, id, bitrate, rootArtist){
// If the album is a single download as a track
if (albumAPI.nb_tracks == 1){
return generateTrackItem(dz, albumAPI.tracks.data[0].id, bitrate, null, albumAPI)
if (albumAPI.tracks.data.length){
return generateTrackItem(dz, albumAPI.tracks.data[0].id, bitrate, null, albumAPI)
} else {
throw new GenerationError(`https://deezer.com/album/${id}`, "Single has no tracks.")
}
}
let tracksArray = await dz.gw.get_album_tracks(id)