everything is working
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-11-26 07:32:45 +01:00
parent d0de7cb3c0
commit 9e212216a3

View File

@ -51,7 +51,7 @@ class LoginApi(UserStoreResource):
try:
musicbrainzngs.auth(userobj['name'], userobj['password'])
print(musicbrainzngs.get_collections())
musicbrainzngs.get_collections()
musicbrainzngs.auth(None, None)
except Exception as e:
current_app.logger.warning(e)
@ -160,6 +160,12 @@ class SingleListApi(SpotifyUserStoreResource):
if 'artist-credit' in currrelease['release'] and currrelease['release']['artist-credit']:
currartist = currrelease['release']['artist-credit'][0]['artist']
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)
flaskred.set(release['id'], 'release'.encode('UTF-8'))
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']
if len(artist_spot) > 0:
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)
flaskred.set(artist['id'], 'artist'.encode('UTF-8'))
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']:
currrlease = currrecording['recording']['release-list'][0]
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']
if len(recording_spot) > 0:
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']
album_spot = self.spotify.search(q=currrelease['title'], type="album", limit=1)['albums']['items']
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:
retdata['spotify_id'] = f"spotify:album:{album_spot[0]['id']}"
if 'artist-credit' in currrelease and currrelease['artist-credit']:
@ -241,6 +262,9 @@ class ItemApi(SpotifyUserStoreResource):
retdata = {"id": itemid, "artist": currartist['name']}
if len(artist_spot) > 0:
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':
currwork = musicbrainzngs.get_work_by_id(itemid)['work']
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']:
currrlease = currrecording['release-list'][0]
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:
retdata['spotify_id'] = f"spotify:track:{recording_spot[0]['id']}"
else: