mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Last FM key is now handled by settings as well
This commit is contained in:
37
maloja
37
maloja
@@ -5,6 +5,7 @@ import sys
|
||||
import signal
|
||||
import os
|
||||
import stat
|
||||
from doreah import settings
|
||||
|
||||
|
||||
neededmodules = [
|
||||
@@ -20,6 +21,9 @@ recommendedmodules = [
|
||||
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 green(txt): return "\033[92m" + txt + "\033[0m"
|
||||
def yellow(txt): return "\033[93m" + txt + "\033[0m"
|
||||
@@ -37,18 +41,33 @@ def gotodir():
|
||||
|
||||
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.")
|
||||
key = input()
|
||||
if key == "": key = "NONE"
|
||||
with open("apikey","w") as keyfile:
|
||||
keyfile.write(key)
|
||||
if key == "": key = None
|
||||
settings.update_settings("settings/settings.ini",{"LASTFM_API_KEY":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
|
||||
if os.path.exists("./clients/authenticated_machines.tsv"):
|
||||
|
||||
Reference in New Issue
Block a user