Fixed download of spotify playlists with null tracks

This fixes #8
This commit is contained in:
RemixDev 2020-07-30 18:46:34 +02:00
parent 7409fce337
commit e9418c8433
3 changed files with 15 additions and 11 deletions

View File

@ -1,3 +1,3 @@
#!/usr/bin/env python3
__version__ = "1.1.23"
__version__ = "1.1.24"

View File

@ -195,11 +195,15 @@ class SpotifyHelper:
'cover'] = "https://e-cdns-images.dzcdn.net/images/cover/d41d8cd98f00b204e9800998ecf8427e/75x75-000000-80-0-0.jpg"
playlistAPI = self._convert_playlist_structure(spotify_playlist)
playlistAPI['various_artist'] = dz.get_artist(5080)
tracklist = spotify_playlist['tracks']['items']
tracklistTmp = spotify_playlist['tracks']['items']
result['collection'] = []
tracklist = []
while spotify_playlist['tracks']['next']:
spotify_playlist['tracks'] = self.sp.next(spotify_playlist['tracks'])
tracklist += spotify_playlist['tracks']['items']
tracklistTmp += spotify_playlist['tracks']['items']
for item in tracklistTmp:
if item['track']:
tracklist.append(item['track'])
totalSize = len(tracklist)
if path.isfile(path.join(self.configFolder, 'spotifyCache.json')):
with open(path.join(self.configFolder, 'spotifyCache.json'), 'r') as spotifyCache:
@ -207,23 +211,23 @@ class SpotifyHelper:
else:
cache = {'tracks': {}, 'albums': {}}
for pos, track in enumerate(tracklist, start=1):
if str(track['track']['id']) in cache['tracks']:
trackID = cache['tracks'][str(track['track']['id'])]
if str(track['id']) in cache['tracks']:
trackID = cache['tracks'][str(track['id'])]
else:
trackID = self.get_trackid_spotify(dz, 0, settings['fallbackSearch'], track['track'])
cache['tracks'][str(track['track']['id'])] = trackID
trackID = self.get_trackid_spotify(dz, 0, settings['fallbackSearch'], track)
cache['tracks'][str(track['id'])] = trackID
if trackID == 0:
deezerTrack = {
'SNG_ID': 0,
'SNG_TITLE': track['track']['name'],
'SNG_TITLE': track['name'],
'DURATION': 0,
'MD5_ORIGIN': 0,
'MEDIA_VERSION': 0,
'FILESIZE': 0,
'ALB_TITLE': track['track']['album']['name'],
'ALB_TITLE': track['album']['name'],
'ALB_PICTURE': "",
'ART_ID': 0,
'ART_NAME': track['track']['artists'][0]['name']
'ART_NAME': track['artists'][0]['name']
}
else:
deezerTrack = dz.get_track_gw(trackID)

View File

@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
setup(
name="deemix",
version="1.1.23",
version="1.1.24",
description="A barebone deezer downloader library",
long_description=README,
long_description_content_type="text/markdown",