Updated setup of API secrets

This commit is contained in:
krateng 2021-11-27 20:04:13 +01:00
parent a41aa0962b
commit 6d5b306d93
3 changed files with 10 additions and 15 deletions

View File

@ -32,12 +32,6 @@ METADATA_PROVIDERS = [lastfm,spotify,deezer,musicbrainz]
# whether to proxy scrobble to other services # whether to proxy scrobble to other services
SCROBBLE_LASTFM = false SCROBBLE_LASTFM = false
LASTFM_API_KEY = "ASK" # 'ASK' signifies that the user has not yet indicated to not use any key at all.
LASTFM_API_SECRET = "ASK"
FANARTTV_API_KEY = "ASK"
SPOTIFY_API_ID = "ASK"
SPOTIFY_API_SECRET = "ASK"
CACHE_EXPIRE_NEGATIVE = 30 # after how many days negative results should be tried again CACHE_EXPIRE_NEGATIVE = 30 # after how many days negative results should be tried again
CACHE_EXPIRE_POSITIVE = 300 # after how many days positive results should be refreshed CACHE_EXPIRE_POSITIVE = 300 # after how many days positive results should be refreshed
THUMBOR_SERVER = None THUMBOR_SERVER = None

View File

@ -11,9 +11,10 @@ from ..globalconf import data_dir, dir_settings
# EXTERNAL API KEYS # EXTERNAL API KEYS
apikeys = { apikeys = {
"LASTFM_API_KEY":"Last.fm API Key", "LASTFM_API_KEY":"Last.fm API Key",
"FANARTTV_API_KEY":"Fanart.tv API Key", #"FANARTTV_API_KEY":"Fanart.tv API Key",
"SPOTIFY_API_ID":"Spotify Client ID", "SPOTIFY_API_ID":"Spotify Client ID",
"SPOTIFY_API_SECRET":"Spotify Client Secret" "SPOTIFY_API_SECRET":"Spotify Client Secret",
"AUDIODB_API_KEY":"TheAudioDB API Key"
} }
@ -36,11 +37,11 @@ def setup():
print("Various external services can be used to display images. If not enough of them are set up, only local images will be used.") print("Various external services can be used to display images. If not enough of them are set up, only local images will be used.")
for k in apikeys: for k in apikeys:
key = settings.get_settings(k) key = settings.get_settings(k)
if key is None: if key is False:
print("\t" + "Currently not using a " + apikeys[k] + " for image display.") print("\t" + "Currently not using a " + apikeys[k] + " for image display.")
elif key == "ASK": elif key is None or key == "ASK":
print("\t" + "Please enter your " + apikeys[k] + ". If you do not want to use one at this moment, simply leave this empty and press Enter.") print("\t" + "Please enter your " + col['gold'](apikeys[k]) + ". If you do not want to use one at this moment, simply leave this empty and press Enter.")
key = prompt("",types=(str,),default=None,skip=SKIP) key = prompt("",types=(str,),default=False,skip=SKIP)
settings.update_settings(data_dir['settings']("settings.ini"),{k:key},create_new=True) settings.update_settings(data_dir['settings']("settings.ini"),{k:key},create_new=True)
else: else:
print("\t" + apikeys[k] + " found.") print("\t" + apikeys[k] + " found.")

View File

@ -104,7 +104,7 @@ class ProxyScrobbleInterface(GenericInterface,abstract=True):
# necessary auth settings exist # necessary auth settings exist
def active_proxyscrobble(self): def active_proxyscrobble(self):
return ( return (
all(self.settings[key] not in [None,"ASK"] for key in self.proxyscrobble["required_settings"]) and all(self.settings[key] not in [None,"ASK",False] for key in self.proxyscrobble["required_settings"]) and
get_settings(self.proxyscrobble["activated_setting"]) get_settings(self.proxyscrobble["activated_setting"])
) )
@ -129,7 +129,7 @@ class ImportInterface(GenericInterface,abstract=True):
# necessary auth settings exist # necessary auth settings exist
def active_import(self): def active_import(self):
return ( return (
all(self.settings[key] not in [None,"ASK"] for key in self.scrobbleimport["required_settings"]) and all(self.settings[key] not in [None,"ASK",False] for key in self.scrobbleimport["required_settings"]) and
get_settings(self.scrobbleimport["activated_setting"]) get_settings(self.scrobbleimport["activated_setting"])
) )
@ -146,7 +146,7 @@ class MetadataInterface(GenericInterface,abstract=True):
# necessary auth settings exist # necessary auth settings exist
def active_metadata(self): def active_metadata(self):
return ( return (
all(self.settings[key] not in [None,"ASK"] for key in self.metadata["required_settings"]) and all(self.settings[key] not in [None,"ASK",False] for key in self.metadata["required_settings"]) and
self.identifier in get_settings("METADATA_PROVIDERS") self.identifier in get_settings("METADATA_PROVIDERS")
) )