From 3d2965d0f6b54b15b895b1859af4a4eb3fa46b12 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Thu, 23 Dec 2021 19:02:14 +0100 Subject: [PATCH] quick fixes and code cleanup --- deemix/downloader.js | 4 ++-- deemix/itemgen.js | 4 +--- deemix/plugins/spotify.js | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/deemix/downloader.js b/deemix/downloader.js index 74271a5..27ec0a2 100644 --- a/deemix/downloader.js +++ b/deemix/downloader.js @@ -129,7 +129,7 @@ async function getPreferredBitrate(dz, track, preferredBitrate, shouldFallback, } if (track.localTrack) { - let url = await getCorrectURL(track, "MP3_MISC", TrackFormats.LOCAL) + let url = await getCorrectURL(track, "MP3_MISC", TrackFormats.LOCAL, feelingLucky) track.urls["MP3_MISC"] = url return TrackFormats.LOCAL } @@ -205,7 +205,7 @@ async function getPreferredBitrate(dz, track, preferredBitrate, shouldFallback, } } if (is360Format) throw new TrackNot360 - let url = await getCorrectURL(track, "MP3_MISC", TrackFormats.DEFAULT) + let url = await getCorrectURL(track, "MP3_MISC", TrackFormats.DEFAULT, feelingLucky) track.urls["MP3_MISC"] = url return TrackFormats.DEFAULT } diff --git a/deemix/itemgen.js b/deemix/itemgen.js index 2b1d34a..fc92fb6 100644 --- a/deemix/itemgen.js +++ b/deemix/itemgen.js @@ -125,8 +125,6 @@ async function generateAlbumItem(dz, id, bitrate, rootArtist){ collection.push(trackAPI) }) - let explicit = albumAPI.explicit_lyrics - return new Collection({ type: 'album', id: id, @@ -134,7 +132,7 @@ async function generateAlbumItem(dz, id, bitrate, rootArtist){ title: albumAPI.title, artist: albumAPI.artist.name, cover: cover, - explicit: explicit, + explicit: albumAPI.explicit_lyrics, size: totalSize, collection: { tracks: collection, diff --git a/deemix/plugins/spotify.js b/deemix/plugins/spotify.js index 1a47a92..93c85cc 100644 --- a/deemix/plugins/spotify.js +++ b/deemix/plugins/spotify.js @@ -267,6 +267,25 @@ class Spotify extends Plugin { } if (cachedTrack.id !== "0") trackAPI = await dz.api.get_track(cachedTrack.id) } + if (!trackAPI){ + trackAPI = { + id: "0", + title: track.name, + duration: 0, + md5_origin: 0, + media_version: 0, + filesizes: {}, + album: { + title: track.album.name, + md5_image: "" + }, + artist: { + id: 0, + name: track.artists[0].name, + md5_image: "" + } + } + } trackAPI.position = pos+1 collection[pos] = trackAPI