diff --git a/src/resources/itemapi.py b/src/resources/itemapi.py index b6bf061..9493e84 100644 --- a/src/resources/itemapi.py +++ b/src/resources/itemapi.py @@ -38,7 +38,8 @@ class ItemApi(SpotifyUserStoreResource): try: imgurl = musicbrainzngs.get_image_list(currrelease['id'])['images'] 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: current_app.logger.warning(e) if len(album_spot) > 0: @@ -54,6 +55,7 @@ class ItemApi(SpotifyUserStoreResource): artist_image = artist_spot[0]['images'] if len(artist_image) > 0: retdata['cover_url'] = artist_image[0]['url'] + retdata['cover_url_small'] = artist_image[len(artist_image)-1]['url'] elif item_type == 'work': currwork = musicbrainzngs.get_work_by_id(itemid)['work'] 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'] if len(work_image) > 0: retdata['cover_url'] = work_image[0]['url'] + workdata['cover_url_small'] = work_image[len(work_image)-1]['url'] elif item_type == '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'] @@ -76,7 +79,8 @@ class ItemApi(SpotifyUserStoreResource): try: imgurl = musicbrainzngs.get_image_list(currrlease['id'])['images'] 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: current_app.logger.warning(e) if len(recording_spot) > 0: diff --git a/src/resources/singlelistapi.py b/src/resources/singlelistapi.py index 1b9ed5f..a7432e8 100644 --- a/src/resources/singlelistapi.py +++ b/src/resources/singlelistapi.py @@ -48,7 +48,8 @@ class SingleListApi(SpotifyUserStoreResource): try: imgurl = musicbrainzngs.get_image_list(release['id'])['images'] 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: current_app.logger.warning(e) releaselist.append(releasedata) @@ -65,6 +66,7 @@ class SingleListApi(SpotifyUserStoreResource): artist_image = artist_spot[0]['images'] if len(artist_image) > 0: 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')) 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'] if len(work_spot) > 0: 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) flaskred.set(work['id'], 'recording'.encode('UTF-8')) retdata = {"id": currdata['id'], "element_count": currdata['work-count'], "itemlist": worklist} @@ -94,7 +100,8 @@ class SingleListApi(SpotifyUserStoreResource): try: imgurl = musicbrainzngs.get_image_list(currrlease['id'])['images'] 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: current_app.logger.warning(e) recording_spot = self.spotify.search(q=recording['title'], type="track", limit=1)['tracks']['items']