fix KeyError in convertTrack and generateTrackItem

in Spotify class
This commit is contained in:
J0J0 T 2021-08-08 22:41:34 +02:00
parent 01bcd9ce37
commit c4f11aef7c
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: