Commenting and slight Spotify search improvement

This commit is contained in:
krateng 2021-11-18 06:45:44 +01:00
parent e236cce86c
commit ff8e5ec8ff
2 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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"],