fix spotify stuff
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Torma Kristóf 2020-11-26 21:13:37 +01:00
parent 9da9e685bf
commit 3efaa34b94
2 changed files with 15 additions and 10 deletions

View File

@ -37,9 +37,12 @@ class ItemApi(SpotifyUserStoreResource):
if 'artist-credit' in currrelease['release'] and currrelease['release']['artist-credit']:
retdata['artist'] = currrelease['artist-credit'][0]['artist']['name']
album_spot = \
self.spotify.search(q=f"{retdata.get('artist', '')} {retdata['title']}", limit=1)[
'albums'][
'items']
self.spotify.search(q=f"{retdata.get('artist', '')} {retdata['title']}", limit=1).get(
'albums')
if album_spot:
album_spot = album_spot['items']
if len(album_spot) > 0:
retdata['spotify_id'] = f"spotify:album:{album_spot[0]['id']}"
try:
imgurl = musicbrainzngs.get_image_list(currrelease['id'])['images']
if len(imgurl) > 0:
@ -65,7 +68,7 @@ class ItemApi(SpotifyUserStoreResource):
retdata = {"id": itemid, "title": currwork['title']}
if len(work_spot) > 0:
retdata['spotify_id'] = f"spotify:track:{work_spot[0]['id']}"
work_image = work_spot[0]['images']
work_image = work_spot[0]['album']['images']
if len(work_image) > 0:
retdata['cover_url'] = work_image[0]['url']
retdata['cover_url_small'] = work_image[len(work_image) - 1]['url']

View File

@ -43,8 +43,10 @@ class SingleListApi(SpotifyUserStoreResource):
currartist = currrelease['release']['artist-credit'][0]['artist']
releasedata['artist'] = currartist['name']
album_spot = \
self.spotify.search(q=f"{releasedata.get('artist', '')} {release['title']}", limit=1)[
'albums']['items']
self.spotify.search(q=f"{releasedata.get('artist', '')} {release['title']}", limit=1).get(
'albums')
if album_spot:
album_spot = album_spot['items']
if len(album_spot) > 0:
releasedata['spotify_id'] = f"spotify:album:{album_spot[0]['id']}"
try:
@ -80,7 +82,7 @@ class SingleListApi(SpotifyUserStoreResource):
work_spot = self.spotify.search(q=work['title'], type="track", limit=1)['tracks']['items']
if len(work_spot) > 0:
workdata['spotify_id'] = f"spotify:track:{work_spot[0]['id']}"
work_image = work_spot[0]['images']
work_image = work_spot[0]['album']['images']
if len(work_image) > 0:
workdata['cover_url'] = work_image[0]['url']
workdata['cover_url_small'] = work_image[len(work_image) - 1]['url']