works have cover and smol cover added
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-11-26 18:15:09 +01:00
parent e4cf442f7d
commit 410cef1106
2 changed files with 15 additions and 4 deletions

View File

@ -38,7 +38,8 @@ class ItemApi(SpotifyUserStoreResource):
try: try:
imgurl = musicbrainzngs.get_image_list(currrelease['id'])['images'] imgurl = musicbrainzngs.get_image_list(currrelease['id'])['images']
if len(imgurl) > 0: if len(imgurl) > 0:
retdata['cover_url'] = imgurl[0]['image'] retdata['cover_url_small'] = imgurl[0]['thumbnails']['small']
retdata['cover_url'] = imgurl[0]['thumbnails']['large']
except Exception as e: except Exception as e:
current_app.logger.warning(e) current_app.logger.warning(e)
if len(album_spot) > 0: if len(album_spot) > 0:
@ -54,6 +55,7 @@ class ItemApi(SpotifyUserStoreResource):
artist_image = artist_spot[0]['images'] artist_image = artist_spot[0]['images']
if len(artist_image) > 0: if len(artist_image) > 0:
retdata['cover_url'] = artist_image[0]['url'] retdata['cover_url'] = artist_image[0]['url']
retdata['cover_url_small'] = artist_image[len(artist_image)-1]['url']
elif item_type == 'work': elif item_type == 'work':
currwork = musicbrainzngs.get_work_by_id(itemid)['work'] currwork = musicbrainzngs.get_work_by_id(itemid)['work']
work_spot = self.spotify.search(q=currwork['title'], type="track", limit=1)['tracks']['items'] work_spot = self.spotify.search(q=currwork['title'], type="track", limit=1)['tracks']['items']
@ -63,6 +65,7 @@ class ItemApi(SpotifyUserStoreResource):
work_image = work_spot[0]['images'] work_image = work_spot[0]['images']
if len(work_image) > 0: if len(work_image) > 0:
retdata['cover_url'] = work_image[0]['url'] retdata['cover_url'] = work_image[0]['url']
workdata['cover_url_small'] = work_image[len(work_image)-1]['url']
elif item_type == 'recording': elif item_type == 'recording':
currrecording = musicbrainzngs.get_recording_by_id(itemid, includes=['artists', 'releases'])['recording'] currrecording = musicbrainzngs.get_recording_by_id(itemid, includes=['artists', 'releases'])['recording']
recording_spot = self.spotify.search(q=currrecording['title'], type="track", limit=1)['tracks']['items'] recording_spot = self.spotify.search(q=currrecording['title'], type="track", limit=1)['tracks']['items']
@ -76,7 +79,8 @@ class ItemApi(SpotifyUserStoreResource):
try: try:
imgurl = musicbrainzngs.get_image_list(currrlease['id'])['images'] imgurl = musicbrainzngs.get_image_list(currrlease['id'])['images']
if len(imgurl) > 0: if len(imgurl) > 0:
retdata['cover_url'] = imgurl[0]['image'] retdata['cover_url_small'] = imgurl[0]['thumbnails']['small']
retdata['cover_url'] = imgurl[0]['thumbnails']['large']
except Exception as e: except Exception as e:
current_app.logger.warning(e) current_app.logger.warning(e)
if len(recording_spot) > 0: if len(recording_spot) > 0:

View File

@ -48,7 +48,8 @@ class SingleListApi(SpotifyUserStoreResource):
try: try:
imgurl = musicbrainzngs.get_image_list(release['id'])['images'] imgurl = musicbrainzngs.get_image_list(release['id'])['images']
if len(imgurl) > 0: if len(imgurl) > 0:
releasedata['cover_url'] = imgurl[0]['image'] releasedata['cover_url'] = imgurl[0]['thumbnails']['large']
releasedata['cover_url_small'] = imgurl[0]['thumbnails']['small']
except Exception as e: except Exception as e:
current_app.logger.warning(e) current_app.logger.warning(e)
releaselist.append(releasedata) releaselist.append(releasedata)
@ -65,6 +66,7 @@ class SingleListApi(SpotifyUserStoreResource):
artist_image = artist_spot[0]['images'] artist_image = artist_spot[0]['images']
if len(artist_image) > 0: if len(artist_image) > 0:
artist_data['cover_url'] = artist_image[0]['url'] artist_data['cover_url'] = artist_image[0]['url']
artist_data['cover_url_small'] = artist_image[len(artist_image)-1]['url']
artistlist.append(artist_data) 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} retdata = {"id": currdata['id'], "element_count": currdata['artist-count'], "itemlist": artistlist}
@ -76,6 +78,10 @@ class SingleListApi(SpotifyUserStoreResource):
work_spot = self.spotify.search(q=work['title'], type="track", limit=1)['tracks']['items'] work_spot = self.spotify.search(q=work['title'], type="track", limit=1)['tracks']['items']
if len(work_spot) > 0: if len(work_spot) > 0:
workdata['spotify_id'] = f"spotify:track:{work_spot[0]['id']}" workdata['spotify_id'] = f"spotify:track:{work_spot[0]['id']}"
work_image = work_spot[0]['images']
if len(work_image) > 0:
workdata['cover_url'] = work_image[0]['url']
workdata['cover_url_small'] = work_image[len(work_image)-1]['url']
worklist.append(workdata) worklist.append(workdata)
flaskred.set(work['id'], 'recording'.encode('UTF-8')) flaskred.set(work['id'], 'recording'.encode('UTF-8'))
retdata = {"id": currdata['id'], "element_count": currdata['work-count'], "itemlist": worklist} retdata = {"id": currdata['id'], "element_count": currdata['work-count'], "itemlist": worklist}
@ -94,7 +100,8 @@ class SingleListApi(SpotifyUserStoreResource):
try: try:
imgurl = musicbrainzngs.get_image_list(currrlease['id'])['images'] imgurl = musicbrainzngs.get_image_list(currrlease['id'])['images']
if len(imgurl) > 0: if len(imgurl) > 0:
currrec['cover_url'] = imgurl[0]['image'] currrec['cover_url_small'] = imgurl[0]['thumbnails']['small']
currrec['cover_url'] = imgurl[0]['thumbnails']['large']
except Exception as e: except Exception as e:
current_app.logger.warning(e) current_app.logger.warning(e)
recording_spot = self.spotify.search(q=recording['title'], type="track", limit=1)['tracks']['items'] recording_spot = self.spotify.search(q=recording['title'], type="track", limit=1)['tracks']['items']