Merge pull request 'fix KeyError in convertTrack and generateTrackItem' (#20) from jojo/deemix-py:spotify_fix into main

Reviewed-on: https://git.freezer.life/RemixDev/deemix-py/pulls/20
This commit is contained in:
RemixDev 2021-08-11 06:22:36 -04:00
commit caee30f37c
1 changed files with 7 additions and 2 deletions

View File

@ -93,7 +93,10 @@ class Spotify(Plugin):
cachedTrack['id'] = trackID cachedTrack['id'] = trackID
cache['tracks'][link_id] = cachedTrack cache['tracks'][link_id] = cachedTrack
self.saveCache(cache) self.saveCache(cache)
if cachedTrack['id'] != "0": return generateTrackItem(dz, cachedTrack['id'], bitrate)
if 'id' in cachedTrack and cachedTrack['id'] != "0":
return generateTrackItem(dz, cachedTrack['id'], bitrate)
raise TrackNotOnDeezer(f"https://open.spotify.com/track/{link_id}") raise TrackNotOnDeezer(f"https://open.spotify.com/track/{link_id}")
def generateAlbumItem(self, dz, link_id, bitrate): def generateAlbumItem(self, dz, link_id, bitrate):
@ -209,7 +212,9 @@ class Spotify(Plugin):
cachedTrack['id'] = trackID cachedTrack['id'] = trackID
cache['tracks'][track['id']] = cachedTrack cache['tracks'][track['id']] = cachedTrack
self.saveCache(cache) self.saveCache(cache)
if cachedTrack['id'] != "0": trackAPI = dz.api.get_track(cachedTrack['id'])
if 'id' in cachedTrack and cachedTrack['id'] != "0":
trackAPI = dz.api.get_track(cachedTrack['id'])
deezerTrack = None deezerTrack = None
if not trackAPI: if not trackAPI: