This commit is contained in:
parent
9da9e685bf
commit
3efaa34b94
@ -37,9 +37,12 @@ class ItemApi(SpotifyUserStoreResource):
|
|||||||
if 'artist-credit' in currrelease['release'] and currrelease['release']['artist-credit']:
|
if 'artist-credit' in currrelease['release'] and currrelease['release']['artist-credit']:
|
||||||
retdata['artist'] = currrelease['artist-credit'][0]['artist']['name']
|
retdata['artist'] = currrelease['artist-credit'][0]['artist']['name']
|
||||||
album_spot = \
|
album_spot = \
|
||||||
self.spotify.search(q=f"{retdata.get('artist', '')} {retdata['title']}", limit=1)[
|
self.spotify.search(q=f"{retdata.get('artist', '')} {retdata['title']}", limit=1).get(
|
||||||
'albums'][
|
'albums')
|
||||||
'items']
|
if album_spot:
|
||||||
|
album_spot = album_spot['items']
|
||||||
|
if len(album_spot) > 0:
|
||||||
|
retdata['spotify_id'] = f"spotify:album:{album_spot[0]['id']}"
|
||||||
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:
|
||||||
@ -65,7 +68,7 @@ class ItemApi(SpotifyUserStoreResource):
|
|||||||
retdata = {"id": itemid, "title": currwork['title']}
|
retdata = {"id": itemid, "title": currwork['title']}
|
||||||
if len(work_spot) > 0:
|
if len(work_spot) > 0:
|
||||||
retdata['spotify_id'] = f"spotify:track:{work_spot[0]['id']}"
|
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:
|
if len(work_image) > 0:
|
||||||
retdata['cover_url'] = work_image[0]['url']
|
retdata['cover_url'] = work_image[0]['url']
|
||||||
retdata['cover_url_small'] = work_image[len(work_image) - 1]['url']
|
retdata['cover_url_small'] = work_image[len(work_image) - 1]['url']
|
||||||
|
@ -43,10 +43,12 @@ class SingleListApi(SpotifyUserStoreResource):
|
|||||||
currartist = currrelease['release']['artist-credit'][0]['artist']
|
currartist = currrelease['release']['artist-credit'][0]['artist']
|
||||||
releasedata['artist'] = currartist['name']
|
releasedata['artist'] = currartist['name']
|
||||||
album_spot = \
|
album_spot = \
|
||||||
self.spotify.search(q=f"{releasedata.get('artist', '')} {release['title']}", limit=1)[
|
self.spotify.search(q=f"{releasedata.get('artist', '')} {release['title']}", limit=1).get(
|
||||||
'albums']['items']
|
'albums')
|
||||||
if len(album_spot) > 0:
|
if album_spot:
|
||||||
releasedata['spotify_id'] = f"spotify:album:{album_spot[0]['id']}"
|
album_spot = album_spot['items']
|
||||||
|
if len(album_spot) > 0:
|
||||||
|
releasedata['spotify_id'] = f"spotify:album:{album_spot[0]['id']}"
|
||||||
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:
|
||||||
@ -70,7 +72,7 @@ class SingleListApi(SpotifyUserStoreResource):
|
|||||||
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']
|
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}
|
||||||
elif list_type == 'work':
|
elif list_type == 'work':
|
||||||
currdata = musicbrainzngs.get_works_in_collection(listid, limit, offset)['collection']
|
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']
|
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']
|
work_image = work_spot[0]['album']['images']
|
||||||
if len(work_image) > 0:
|
if len(work_image) > 0:
|
||||||
workdata['cover_url'] = work_image[0]['url']
|
workdata['cover_url'] = work_image[0]['url']
|
||||||
workdata['cover_url_small'] = work_image[len(work_image) - 1]['url']
|
workdata['cover_url_small'] = work_image[len(work_image) - 1]['url']
|
||||||
|
Loading…
Reference in New Issue
Block a user