mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Last FM key is now handled by settings as well
This commit is contained in:
parent
1dcaa1c24d
commit
03efd4fa62
@ -17,7 +17,7 @@ def config(defaultextension=".ini",files=["settings.ini","settings.conf","config
|
|||||||
_onlytext = onlytext
|
_onlytext = onlytext
|
||||||
|
|
||||||
|
|
||||||
global Settings, get_settings, set_settings, update
|
global Settings, get_settings, update_settings, update
|
||||||
|
|
||||||
|
|
||||||
# manager object so we can read settings once and retain them
|
# manager object so we can read settings once and retain them
|
||||||
@ -116,11 +116,11 @@ def config(defaultextension=".ini",files=["settings.ini","settings.conf","config
|
|||||||
|
|
||||||
# specific keys requested
|
# specific keys requested
|
||||||
else:
|
else:
|
||||||
if len(keys) == 1: return allsettings[keys[0]]
|
if len(keys) == 1: return allsettings.get(keys[0])
|
||||||
else: return [allsettings[k] for k in keys]
|
else: return [allsettings.get(k) for k in keys]
|
||||||
|
|
||||||
|
|
||||||
def set_settings(file,settings):
|
def update_settings(file,settings):
|
||||||
|
|
||||||
if not os.path.exists(file): return
|
if not os.path.exists(file): return
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ def config(defaultextension=".ini",files=["settings.ini","settings.conf","config
|
|||||||
else:
|
else:
|
||||||
usersettings = get_settings(files=[target],raw=True)
|
usersettings = get_settings(files=[target],raw=True)
|
||||||
shutil.copyfile(source,target)
|
shutil.copyfile(source,target)
|
||||||
set_settings(target,usersettings)
|
update_settings(target,usersettings)
|
||||||
|
|
||||||
|
|
||||||
# initial config on import, set everything to default
|
# initial config on import, set everything to default
|
||||||
|
37
maloja
37
maloja
@ -5,6 +5,7 @@ import sys
|
|||||||
import signal
|
import signal
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
|
from doreah import settings
|
||||||
|
|
||||||
|
|
||||||
neededmodules = [
|
neededmodules = [
|
||||||
@ -20,6 +21,9 @@ recommendedmodules = [
|
|||||||
SOURCE_URL = "https://github.com/krateng/maloja/archive/master.zip"
|
SOURCE_URL = "https://github.com/krateng/maloja/archive/master.zip"
|
||||||
|
|
||||||
|
|
||||||
|
settings.config(files=["settings/default.ini","settings/settings.ini"])
|
||||||
|
|
||||||
|
|
||||||
def blue(txt): return "\033[94m" + txt + "\033[0m"
|
def blue(txt): return "\033[94m" + txt + "\033[0m"
|
||||||
def green(txt): return "\033[92m" + txt + "\033[0m"
|
def green(txt): return "\033[92m" + txt + "\033[0m"
|
||||||
def yellow(txt): return "\033[93m" + txt + "\033[0m"
|
def yellow(txt): return "\033[93m" + txt + "\033[0m"
|
||||||
@ -37,18 +41,33 @@ def gotodir():
|
|||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
|
|
||||||
# LASTFM API KEY
|
|
||||||
if os.path.exists("./apikey"):
|
|
||||||
with open("apikey","r") as keyfile:
|
|
||||||
apikey = keyfile.read().replace("\n","")
|
|
||||||
|
|
||||||
if apikey == "NONE": print("Currently not using an API key for image display. Only local images will be used.")
|
|
||||||
else:
|
# LASTFM API KEY
|
||||||
|
key = settings.get_settings("LASTFM_API_KEY")
|
||||||
|
if key is None:
|
||||||
|
print("Currently not using an API key for image display. Only local images will be used.")
|
||||||
|
elif key == "ASK":
|
||||||
print("Please enter your Last.FM API key. If you do not want to display artist and track images, simply leave this empty and press Enter.")
|
print("Please enter your Last.FM API key. If you do not want to display artist and track images, simply leave this empty and press Enter.")
|
||||||
key = input()
|
key = input()
|
||||||
if key == "": key = "NONE"
|
if key == "": key = None
|
||||||
with open("apikey","w") as keyfile:
|
settings.update_settings("settings/settings.ini",{"LASTFM_API_KEY":key})
|
||||||
keyfile.write(key)
|
# TODO: Make sure we set the setting even if file doesnt exist
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Last.FM API key found.")
|
||||||
|
|
||||||
|
# if os.path.exists("./apikey"):
|
||||||
|
# with open("apikey","r") as keyfile:
|
||||||
|
# apikey = keyfile.read().replace("\n","")
|
||||||
|
#
|
||||||
|
# if apikey == "NONE": print("Currently not using an API key for image display. Only local images will be used.")
|
||||||
|
# else:
|
||||||
|
# print("Please enter your Last.FM API key. If you do not want to display artist and track images, simply leave this empty and press Enter.")
|
||||||
|
# key = input()
|
||||||
|
# if key == "": key = "NONE"
|
||||||
|
# with open("apikey","w") as keyfile:
|
||||||
|
# keyfile.write(key)
|
||||||
|
|
||||||
# OWN API KEY
|
# OWN API KEY
|
||||||
if os.path.exists("./clients/authenticated_machines.tsv"):
|
if os.path.exists("./clients/authenticated_machines.tsv"):
|
||||||
|
@ -5,4 +5,4 @@ API_PORT = 42011
|
|||||||
|
|
||||||
[Third Party Services]
|
[Third Party Services]
|
||||||
|
|
||||||
LASTFM_API_KEY = None
|
LASTFM_API_KEY = "ASK"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user