diff --git a/maloja/thirdparty/__init__.py b/maloja/thirdparty/__init__.py index 3989f39..d9faaa2 100644 --- a/maloja/thirdparty/__init__.py +++ b/maloja/thirdparty/__init__.py @@ -72,6 +72,9 @@ class GenericInterface: self.settings[key] = get_settings(self.settings[key]) self.authorize() + # this makes sure that of every class we define, we immediately create an + # instance (de facto singleton). then each instance checks if the requirements + # are met to use that service in each particular role and registers as such def __init_subclass__(cls,abstract=False): if not abstract: s = cls() @@ -97,6 +100,8 @@ class ProxyScrobbleInterface(GenericInterface,abstract=True): "activated_setting":None } + # service provides this role only if the setting is active AND all + # necessary auth settings exist def active_proxyscrobble(self): return ( all(self.settings[key] not in [None,"ASK"] for key in self.proxyscrobble["required_settings"]) and @@ -120,6 +125,8 @@ class ImportInterface(GenericInterface,abstract=True): "activated_setting":None } + # service provides this role only if the setting is active AND all + # necessary auth settings exist def active_import(self): return ( all(self.settings[key] not in [None,"ASK"] for key in self.scrobbleimport["required_settings"]) and @@ -135,6 +142,8 @@ class MetadataInterface(GenericInterface,abstract=True): "activated_setting":None } + # service provides this role only if the setting is active AND all + # necessary auth settings exist def active_metadata(self): return ( all(self.settings[key] not in [None,"ASK"] for key in self.metadata["required_settings"]) and diff --git a/maloja/thirdparty/spotify.py b/maloja/thirdparty/spotify.py index 35c6ec1..0d7f951 100644 --- a/maloja/thirdparty/spotify.py +++ b/maloja/thirdparty/spotify.py @@ -14,8 +14,8 @@ class Spotify(MetadataInterface): } metadata = { - "trackurl": "https://api.spotify.com/v1/search?q={artist}%20{title}&type=track&access_token={token}", - "artisturl": "https://api.spotify.com/v1/search?q={artist}&type=artist&access_token={token}", + "trackurl": "https://api.spotify.com/v1/search?q=artist:{artist}%20track:{title}&type=track&access_token={token}", + "artisturl": "https://api.spotify.com/v1/search?q=artist:{artist}&type=artist&access_token={token}", "response_type":"json", "response_parse_tree_track": ["tracks","items",0,"album","images",0,"url"], "response_parse_tree_artist": ["artists","items",0,"images",0,"url"],