Fixed Spotify Playlists with no cover
authorRemixDev <deezloaderremix@gmail.com>
Thu, 30 Jan 2020 20:33:33 +0000 (21:33 +0100)
committerRemixDev <deezloaderremix@gmail.com>
Thu, 30 Jan 2020 20:33:33 +0000 (21:33 +0100)
app/app.js
app/public/js/frontend.js

index 8e3d1acac2c40dc2b7b92292291e2bf80f4b423f..53221b0e469e6748be7f5663ca15455e5ec64a9e 100644 (file)
@@ -812,7 +812,11 @@ io.sockets.on('connection', function (s) {
                                        bitrate: data.bitrate+"",
                                        type: "spotifyplaylist",
                                        obj: resp.body,
-                                       cover: resp.body.images[0].url,
+                               }
+                               if (Array.isArray(resp.body.images) && resp.body.images.length){
+                                       _playlist.cover = resp.body.images[0].url
+                               }else{
+                                       _playlist.cover = "https://e-cdns-images.dzcdn.net/images/cover//56x56-000000-80-0-0.jpg"
                                }
                                var numPages=Math.floor((_playlist.size-1)/100)
                                var trackList = new Array(_playlist.size)
@@ -1433,9 +1437,14 @@ io.sockets.on('connection', function (s) {
                                        explicit: false,
                                        compilation: true,
                                        discTotal: 1,
-                                       cover: downloading.obj.images[0].url.replace("56x56",`${downloading.settings.embeddedArtworkSize}x${downloading.settings.embeddedArtworkSize}`),
                                        fullSize: downloading.trackList.length,
                                }
+                               if (Array.isArray(downloading.obj.images) && downloading.obj.images.length){
+                                       downloading.settings.playlist.cover = downloading.obj.images[0].url
+                               }else{
+                                       downloading.settings.playlist.cover = "https://e-cdns-images.dzcdn.net/images/cover//56x56-000000-80-0-0.jpg"
+                               }
+                               downloading.settings.playlist.cover = downloading.settings.playlist.cover.replace("56x56",`${downloading.settings.embeddedArtworkSize}x${downloading.settings.embeddedArtworkSize}`)
                                downloading.downloadPromise = new Promise((resolve,reject)=>{
                                        downloading.trackList.every(function (t, index) {
                                                downloading.tracksData[index] = {
@@ -1521,7 +1530,7 @@ io.sockets.on('connection', function (s) {
                                        if (downloading.settings.saveArtwork){
                                                if (!fs.existsSync(downloading.filePath)) fs.mkdirpSync(downloading.filePath);
                                                let imgPath = downloading.filePath + antiDot(settingsRegexAlbum(downloading.settings.playlist, downloading.settings.coverImageTemplate))+(downloading.settings.PNGcovers ? ".png" : ".jpg");
-                                               if (downloading.obj.images){
+                                               if (Array.isArray(downloading.obj.images) && downloading.obj.images.length){
                                                        downloading.cover = downloading.obj.images[0].url
                                                        request.get(downloading.cover, {strictSSL: false,encoding: 'binary'}, function(error,response,body){
                                                                if(error){
index b7ae025cd6718d09940df86d1cfb63ea10f2ecaa..d2a8b0c37a04f83a1fa5be1ba6fa9fdbf98e80ac 100644 (file)
@@ -1390,7 +1390,7 @@ socket.on("getMyPlaylistList", function (data) {
                var currentResultPlaylist = data.playlists[i]
                $(tableBody).append(
                                `<tr>
-                               <td><img src="${currentResultPlaylist.image}" class="rounded" width="56px" /></td>
+                               <td><img src="${currentResultPlaylist.image || "/img/noCover.jpg"}" class="rounded" width="56px" /></td>
                                <td>${currentResultPlaylist.title}</td>
                                <td>${currentResultPlaylist.songs}</td>
                                </tr>`)