1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Easier installation

This commit is contained in:
Krateng 2019-04-11 13:36:26 +02:00
parent 5c8dddc8a7
commit 27e7083281
2 changed files with 26 additions and 23 deletions

View File

@ -31,7 +31,7 @@ There are only two scrobblers (YouTube Music and Plex, both for Chromium), but a
1) Either install Maloja with a package, or download the repository to some arbitrary location. If you pick the manual installation, every command needs to be executed from the Maloja directory and led with `./`. You can also only download the file `maloja` instead of the whole repository and fetch the rest with 1) Either install Maloja with a package, or download the repository to some arbitrary location. If you pick the manual installation, every command needs to be executed from the Maloja directory and led with `./`. You can also only download the file `maloja` instead of the whole repository and fetch the rest with
./maloja update ./maloja install
2) Start the server with 2) Start the server with

47
maloja
View File

@ -5,6 +5,7 @@ import sys
import signal import signal
import os import os
import stat import stat
import pathlib
@ -27,6 +28,16 @@ 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"
## GOTODIR goes to directory that seems to have a maloja install
## SETUP assumes correct directory. sets settings and key
## INSTALL ignores local files, just installs prerequisites
## START INSTALL - GOTODIR - SETUP - starts process
## RESTART STOP - START
## STOP Stops process
## UPDATE GOTODIR - updates from repo
## LOADLASTFM GOTODIR - imports csv data
## INSTALLHERE makes this directory valid - UPDATE - INSTALL - SETUP
def gotodir(): def gotodir():
if os.path.exists("./server.py"): if os.path.exists("./server.py"):
return True return True
@ -37,7 +48,6 @@ def gotodir():
print("Maloja installation could not be found.") print("Maloja installation could not be found.")
return False return False
def setup(): def setup():
from doreah import settings from doreah import settings
@ -55,18 +65,6 @@ def setup():
else: else:
print("Last.FM API key found.") 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"):
pass pass
@ -167,8 +165,6 @@ def install():
print("All necessary modules seem to be installed.") print("All necessary modules seem to be installed.")
return True return True
def getInstance(): def getInstance():
try: try:
output = subprocess.check_output(["pidof","Maloja"]) output = subprocess.check_output(["pidof","Maloja"])
@ -177,9 +173,6 @@ def getInstance():
except: except:
return None return None
def start(): def start():
if install(): if install():
@ -205,8 +198,6 @@ def start():
print("Error while starting Maloja.") print("Error while starting Maloja.")
return False return False
def restart(): def restart():
#pid = getInstance() #pid = getInstance()
#if pid == None: #if pid == None:
@ -283,7 +274,6 @@ def update():
if stop(): start() #stop returns whether it was running before, in which case we restart it if stop(): start() #stop returns whether it was running before, in which case we restart it
def loadlastfm(): def loadlastfm():
try: try:
@ -304,6 +294,18 @@ def loadlastfm():
os.system("python3 ./lastfmconverter.py " + filename + " ./scrobbles/lastfmimport.tsv") os.system("python3 ./lastfmconverter.py " + filename + " ./scrobbles/lastfmimport.tsv")
print("Successfully imported your Last.FM scrobbles!") print("Successfully imported your Last.FM scrobbles!")
def installhere():
if len(os.listdir()) > 1:
print("You should install Maloja in an empty directory.")
return False
else:
open("server.py","w").close()
# if it's cheese, but it works, it ain't cheese
update()
install()
setup()
print("Maloja installed! Start with " + yellow("./maloja start"))
if __name__ == "__main__": if __name__ == "__main__":
@ -312,4 +314,5 @@ if __name__ == "__main__":
elif sys.argv[1] == "stop": stop() elif sys.argv[1] == "stop": stop()
elif sys.argv[1] == "update": update() elif sys.argv[1] == "update": update()
elif sys.argv[1] == "import": loadlastfm() elif sys.argv[1] == "import": loadlastfm()
else: print("Valid commands: start restart stop update") elif sys.argv[1] == "install": installhere()
else: print("Valid commands: start restart stop update import install")