This commit is contained in:
parent
d0de7cb3c0
commit
9e212216a3
@ -51,7 +51,7 @@ class LoginApi(UserStoreResource):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
musicbrainzngs.auth(userobj['name'], userobj['password'])
|
musicbrainzngs.auth(userobj['name'], userobj['password'])
|
||||||
print(musicbrainzngs.get_collections())
|
musicbrainzngs.get_collections()
|
||||||
musicbrainzngs.auth(None, None)
|
musicbrainzngs.auth(None, None)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
current_app.logger.warning(e)
|
current_app.logger.warning(e)
|
||||||
@ -160,6 +160,12 @@ class SingleListApi(SpotifyUserStoreResource):
|
|||||||
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']
|
||||||
|
try:
|
||||||
|
imgurl = musicbrainzngs.get_image_list(currrelease['id'])['images']
|
||||||
|
if imgurl > 0:
|
||||||
|
releasedata['cover_url'] = imgurl[0]['image']
|
||||||
|
except Exception as e:
|
||||||
|
current_app.logger.warning(e)
|
||||||
releaselist.append(releasedata)
|
releaselist.append(releasedata)
|
||||||
flaskred.set(release['id'], 'release'.encode('UTF-8'))
|
flaskred.set(release['id'], 'release'.encode('UTF-8'))
|
||||||
retdata = {"id": currdata['id'], "element_count": currdata['release-count'], "itemlist": releaselist}
|
retdata = {"id": currdata['id'], "element_count": currdata['release-count'], "itemlist": releaselist}
|
||||||
@ -171,6 +177,9 @@ class SingleListApi(SpotifyUserStoreResource):
|
|||||||
artist_spot = self.spotify.search(q=artist['name'], type="artist", limit=1)['artists']['items']
|
artist_spot = self.spotify.search(q=artist['name'], type="artist", limit=1)['artists']['items']
|
||||||
if len(artist_spot) > 0:
|
if len(artist_spot) > 0:
|
||||||
artist_data['spotify_id'] = f"spotify:artist:{artist_spot[0]['id']}"
|
artist_data['spotify_id'] = f"spotify:artist:{artist_spot[0]['id']}"
|
||||||
|
artist_image = artist_spot[0]['images']
|
||||||
|
if len(artist_image) > 0:
|
||||||
|
artist_data['cover_url'] = artist_image[0]['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}
|
||||||
@ -197,6 +206,12 @@ class SingleListApi(SpotifyUserStoreResource):
|
|||||||
if 'release-list' in currrecording['recording'] and currrecording['recording']['release-list']:
|
if 'release-list' in currrecording['recording'] and currrecording['recording']['release-list']:
|
||||||
currrlease = currrecording['recording']['release-list'][0]
|
currrlease = currrecording['recording']['release-list'][0]
|
||||||
currrec['album'] = currrlease['title']
|
currrec['album'] = currrlease['title']
|
||||||
|
try:
|
||||||
|
imgurl = musicbrainzngs.get_image_list(currrlease['id'])['images']
|
||||||
|
if imgurl > 0:
|
||||||
|
currrec['cover_url'] = imgurl[0]['image']
|
||||||
|
except Exception as 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']
|
||||||
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']}"
|
||||||
@ -231,6 +246,12 @@ class ItemApi(SpotifyUserStoreResource):
|
|||||||
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']
|
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']}
|
||||||
|
try:
|
||||||
|
imgurl = musicbrainzngs.get_image_list(currrelease['id'])['images']
|
||||||
|
if imgurl > 0:
|
||||||
|
retdata['cover_url'] = imgurl[0]['image']
|
||||||
|
except Exception as 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']:
|
if 'artist-credit' in currrelease and currrelease['artist-credit']:
|
||||||
@ -241,6 +262,9 @@ class ItemApi(SpotifyUserStoreResource):
|
|||||||
retdata = {"id": itemid, "artist": currartist['name']}
|
retdata = {"id": itemid, "artist": currartist['name']}
|
||||||
if len(artist_spot) > 0:
|
if len(artist_spot) > 0:
|
||||||
retdata['spotify_id'] = f"spotify:artist:{artist_spot[0]['id']}"
|
retdata['spotify_id'] = f"spotify:artist:{artist_spot[0]['id']}"
|
||||||
|
artist_image = artist_spot[0]['images']
|
||||||
|
if len(artist_image) > 0:
|
||||||
|
retdata['cover_url'] = artist_image[0]['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']
|
||||||
@ -257,6 +281,12 @@ class ItemApi(SpotifyUserStoreResource):
|
|||||||
if 'release-list' in currrecording and currrecording['release-list']:
|
if 'release-list' in currrecording and currrecording['release-list']:
|
||||||
currrlease = currrecording['release-list'][0]
|
currrlease = currrecording['release-list'][0]
|
||||||
retdata['album'] = currrlease['title']
|
retdata['album'] = currrlease['title']
|
||||||
|
try:
|
||||||
|
imgurl = musicbrainzngs.get_image_list(currrlease['id'])['images']
|
||||||
|
if imgurl > 0:
|
||||||
|
retdata['cover_url'] = imgurl[0]['image']
|
||||||
|
except Exception as e:
|
||||||
|
current_app.logger.warning(e)
|
||||||
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:
|
||||||
|
Loading…
Reference in New Issue
Block a user