This commit is contained in:
parent
410cef1106
commit
9da9e685bf
@ -33,8 +33,13 @@ class ItemApi(SpotifyUserStoreResource):
|
|||||||
|
|
||||||
if item_type == 'release':
|
if item_type == 'release':
|
||||||
currrelease = musicbrainzngs.get_release_by_id(itemid, includes=['artists'])['release']
|
currrelease = musicbrainzngs.get_release_by_id(itemid, includes=['artists'])['release']
|
||||||
album_spot = self.spotify.search(q=currrelease['title'], type="album", limit=1)['albums']['items']
|
|
||||||
retdata = {"id": itemid, "album": currrelease['title']}
|
retdata = {"id": itemid, "album": currrelease['title']}
|
||||||
|
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']
|
||||||
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:
|
||||||
@ -44,8 +49,6 @@ class ItemApi(SpotifyUserStoreResource):
|
|||||||
current_app.logger.warning(e)
|
current_app.logger.warning(e)
|
||||||
if len(album_spot) > 0:
|
if len(album_spot) > 0:
|
||||||
retdata['spotify_id'] = f"spotify:album:{album_spot[0]['id']}"
|
retdata['spotify_id'] = f"spotify:album:{album_spot[0]['id']}"
|
||||||
if 'artist-credit' in currrelease and currrelease['artist-credit']:
|
|
||||||
retdata['artist'] = currrelease['artist-credit'][0]['artist']['name']
|
|
||||||
elif item_type == 'artist':
|
elif item_type == 'artist':
|
||||||
currartist = musicbrainzngs.get_artist_by_id(itemid)['artist']
|
currartist = musicbrainzngs.get_artist_by_id(itemid)['artist']
|
||||||
artist_spot = self.spotify.search(q=currartist['name'], type="artist", limit=1)['artists']['items']
|
artist_spot = self.spotify.search(q=currartist['name'], type="artist", limit=1)['artists']['items']
|
||||||
@ -55,7 +58,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']
|
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']
|
||||||
@ -65,10 +68,9 @@ 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']
|
retdata['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']
|
|
||||||
retdata = {"id": itemid, "title": currrecording['title']}
|
retdata = {"id": itemid, "title": currrecording['title']}
|
||||||
if 'artist-credit' in currrecording and currrecording['artist-credit']:
|
if 'artist-credit' in currrecording and currrecording['artist-credit']:
|
||||||
currartist = currrecording['artist-credit'][0]['artist']
|
currartist = currrecording['artist-credit'][0]['artist']
|
||||||
@ -83,6 +85,9 @@ class ItemApi(SpotifyUserStoreResource):
|
|||||||
retdata['cover_url'] = imgurl[0]['thumbnails']['large']
|
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)
|
||||||
|
recording_spot = \
|
||||||
|
self.spotify.search(q=f"{retdata.get('artist', '')} {retdata.get('album', '')} {retdata['title']}",
|
||||||
|
limit=1)['tracks']['items']
|
||||||
if len(recording_spot) > 0:
|
if len(recording_spot) > 0:
|
||||||
retdata['spotify_id'] = f"spotify:track:{recording_spot[0]['id']}"
|
retdata['spotify_id'] = f"spotify:track:{recording_spot[0]['id']}"
|
||||||
else:
|
else:
|
||||||
|
@ -39,12 +39,14 @@ class SingleListApi(SpotifyUserStoreResource):
|
|||||||
for release in currdata['release-list']:
|
for release in currdata['release-list']:
|
||||||
releasedata = {"id": release['id'], "album": release['title']}
|
releasedata = {"id": release['id'], "album": release['title']}
|
||||||
currrelease = musicbrainzngs.get_release_by_id(release['id'], includes=['artists'])
|
currrelease = musicbrainzngs.get_release_by_id(release['id'], includes=['artists'])
|
||||||
album_spot = self.spotify.search(q=release['title'], type="album", limit=1)['albums']['items']
|
|
||||||
if len(album_spot) > 0:
|
|
||||||
releasedata['spotify_id'] = f"spotify:album:{album_spot[0]['id']}"
|
|
||||||
if 'artist-credit' in currrelease['release'] and currrelease['release']['artist-credit']:
|
if 'artist-credit' in currrelease['release'] and currrelease['release']['artist-credit']:
|
||||||
currartist = currrelease['release']['artist-credit'][0]['artist']
|
currartist = currrelease['release']['artist-credit'][0]['artist']
|
||||||
releasedata['artist'] = currartist['name']
|
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']}"
|
||||||
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:
|
||||||
@ -66,7 +68,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']
|
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}
|
||||||
@ -81,7 +83,7 @@ class SingleListApi(SpotifyUserStoreResource):
|
|||||||
work_image = work_spot[0]['images']
|
work_image = work_spot[0]['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']
|
||||||
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}
|
||||||
@ -104,7 +106,9 @@ class SingleListApi(SpotifyUserStoreResource):
|
|||||||
currrec['cover_url'] = imgurl[0]['thumbnails']['large']
|
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=f"{currrec.get('artist', '')} {currrec.get('album', '')} {currrec['title']}",
|
||||||
|
limit=1)['tracks']['items']
|
||||||
if len(recording_spot) > 0:
|
if len(recording_spot) > 0:
|
||||||
currrec['spotify_id'] = f"spotify:track:{recording_spot[0]['id']}"
|
currrec['spotify_id'] = f"spotify:track:{recording_spot[0]['id']}"
|
||||||
recordinglist.append(currrec)
|
recordinglist.append(currrec)
|
||||||
|
Loading…
Reference in New Issue
Block a user