This commit is contained in:
@@ -4,7 +4,7 @@ Base resource with user handling and Spotify integration
|
||||
|
||||
__author__ = '@tormakris'
|
||||
__copyright__ = "Copyright 2020, onSpot Team"
|
||||
__module_name__ = "spotifyuserstoreresource"
|
||||
__module_name__ = "apiinteractionresource"
|
||||
__version__text__ = "1"
|
||||
|
||||
from flask import current_app
|
||||
@@ -22,9 +22,10 @@ class APIInteractionResource(UserStoreResource):
|
||||
|
||||
def queryspotifyinfo(self, mb_type: str, title: str = "", artist: str = "", album: str = "") -> tuple:
|
||||
querystring = f"{artist} {album} {title}"
|
||||
spotify_uri = "spotify:"
|
||||
if mb_type == "artist":
|
||||
spot_data = self.spotify.search(q=querystring, type="artist", limit=1)['artists']['items']
|
||||
spotify_uri = "spotify:artist:"
|
||||
spotify_uri += "artist:"
|
||||
if spot_data:
|
||||
imagedata = spot_data[0]['images']
|
||||
else:
|
||||
@@ -36,14 +37,14 @@ class APIInteractionResource(UserStoreResource):
|
||||
spot_data = spot_data['items']
|
||||
else:
|
||||
return None, None, None
|
||||
spotify_uri = "spotify:album:"
|
||||
spotify_uri += "album:"
|
||||
if spot_data:
|
||||
imagedata = spot_data[0]['images']
|
||||
else:
|
||||
return None, None, None
|
||||
elif mb_type == "work" or mb_type == "recording":
|
||||
spot_data = self.spotify.search(q=querystring, type="track", limit=1)['tracks']['items']
|
||||
spotify_uri = "spotify:track:"
|
||||
spotify_uri += "track:"
|
||||
if spot_data:
|
||||
imagedata = spot_data[0]['album']['images']
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user