fix spotify stuff
continuous-integration/drone Build is passing Details

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,10 +43,12 @@ 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']
if len(album_spot) > 0:
releasedata['spotify_id'] = f"spotify:album:{album_spot[0]['id']}"
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:
imgurl = musicbrainzngs.get_image_list(release['id'])['images']
if len(imgurl) > 0:
@ -70,7 +72,7 @@ class SingleListApi(SpotifyUserStoreResource):
artist_data['cover_url'] = artist_image[0]['url']
artist_data['cover_url_small'] = artist_image[len(artist_image) - 1]['url']
artistlist.append(artist_data)
flaskred.set(artist['id'], 'artist'.encode('UTF-8'))
flaskred.set(artist['id'], 'artist'.encode('UTF-8'))
retdata = {"id": currdata['id'], "element_count": currdata['artist-count'], "itemlist": artistlist}
elif list_type == 'work':
currdata = musicbrainzngs.get_works_in_collection(listid, limit, offset)['collection']
@ -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']