mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Made setup more interactive
This commit is contained in:
parent
58aae2643c
commit
b6f3791eac
50
maloja
50
maloja
@ -20,6 +20,10 @@ recommendedmodules = [
|
||||
SOURCE_URL = "https://github.com/krateng/maloja/archive/master.zip"
|
||||
|
||||
|
||||
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"
|
||||
|
||||
def gotodir():
|
||||
if os.path.exists("./server.py"):
|
||||
return True
|
||||
@ -32,9 +36,37 @@ def gotodir():
|
||||
|
||||
|
||||
def setup():
|
||||
print("Make sure to add your Last.FM api key in a file called 'apikey' to your main directory if you want to see images.")
|
||||
print("Visit http://localhost:42010 to see your web interface. If you get an error, you probably don't have any scrobbles yet. This will be fixed later.")
|
||||
|
||||
# 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:
|
||||
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"):
|
||||
pass
|
||||
else:
|
||||
print("Do you want to set up a key to enable scrobbling? Your scrobble extension needs that key so that only you can scrobble tracks to your database. [Y/n]")
|
||||
answer = input()
|
||||
if answer.lower() in ["y","yes","yea","1","positive","true",""]:
|
||||
import random
|
||||
key = ""
|
||||
for i in range(64):
|
||||
key += str(random.choice(list(range(10)) + list("abcdefghijklmnopqrstuvwxyz") + list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")))
|
||||
print("Your API Key: " + yellow(key))
|
||||
with open("./clients/authenticated_machines.tsv","w") as keyfile:
|
||||
keyfile.write(key + "\n" + "Default Generated Key")
|
||||
elif answer.lower() in ["n","no","nay","0","negative","false"]:
|
||||
pass
|
||||
#file is generated my server itself if not found
|
||||
|
||||
def install():
|
||||
toinstall = []
|
||||
@ -73,7 +105,7 @@ def install():
|
||||
print("Attempt to install required modules? [Y/n]")
|
||||
answer = input()
|
||||
|
||||
if answer.lower() in ["y","yes","yea","1","positive","true"]:
|
||||
if answer.lower() in ["y","yes","yea","1","positive","true",""]:
|
||||
for m in neededmodules:
|
||||
try:
|
||||
print("Installing " + m + " with pip...")
|
||||
@ -114,12 +146,10 @@ def install():
|
||||
|
||||
if fail: return False
|
||||
print("All modules successfully installed!")
|
||||
setup()
|
||||
return True
|
||||
|
||||
else:
|
||||
print("All necessary modules seem to be installed.")
|
||||
setup()
|
||||
return True
|
||||
|
||||
|
||||
@ -139,8 +169,14 @@ def start():
|
||||
if install():
|
||||
|
||||
if gotodir():
|
||||
setup()
|
||||
p = subprocess.Popen(["python3","server.py"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
||||
print("Maloja started! PID: " + str(p.pid))
|
||||
print(green("Maloja started!") + " PID: " + str(p.pid))
|
||||
|
||||
print("Visit your server address (Port 42010) to see your web interface. Visit /setup to get started.")
|
||||
print("If you're installing this on your local machine, these links should get you there:")
|
||||
print("\t" + blue("http://localhost:42010"))
|
||||
print("\t" + blue("http://localhost:42010/setup"))
|
||||
return True
|
||||
#else:
|
||||
# os.chdir("/opt/maloja/")
|
||||
@ -217,7 +253,7 @@ def update():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if sys.argv[1] == "start": start()
|
||||
if sys.argv[1] == "start": restart()
|
||||
elif sys.argv[1] == "restart": restart()
|
||||
elif sys.argv[1] == "stop": stop()
|
||||
elif sys.argv[1] == "update": update()
|
||||
|
@ -16,7 +16,7 @@
|
||||
<span>with your library</span>
|
||||
<p class="stats"><a href="/scrobbles?artist=KEY_ENC_ARTISTNAME">KEY_ISSUES Issues</a></p>
|
||||
|
||||
<p>Maloja can identify possible problems with consistency or redundancy in your library. After making any changes, you should <a onclick='fullrebuild()'>rebuild your library</a>.<br/>
|
||||
<p>Maloja can identify possible problems with consistency or redundancy in your library. After making any changes, you should <a class="textlink" onclick='fullrebuild()'>rebuild your library</a>.<br/>
|
||||
Your API key is required to make any changes to the server: <input id='apikey' onchange='checkAPIkey()' style='width:300px;'/></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -12,6 +12,10 @@ a {
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
a.textlink {
|
||||
color:gold;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
92
website/setup.html
Normal file
92
website/setup.html
Normal file
@ -0,0 +1,92 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - Setup</title>
|
||||
<link rel="stylesheet" href="maloja.css" />
|
||||
|
||||
<script>
|
||||
function replaceurls() {
|
||||
url = window.location.origin
|
||||
s = document.getElementsByName("serverurl")
|
||||
for (var i=0;i<s.length;i++) {
|
||||
s[i].innerHTML = url
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function replace() {
|
||||
replaceurls();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
|
||||
td {
|
||||
padding-right:20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="replace()">
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
<div style="background-image:url('/favicon.png')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>Maloja</h1><br/>
|
||||
|
||||
<p class="desc">Welcome to your own Maloja server!</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Start Scrobbling</h2>
|
||||
|
||||
If you use Vivaldi, Brave, Iridium or any other Chromium-based browser and listen to music on Plex, download the extension and simply enter the server URL as well as your API key in the relevant fields. They will turn green if the server is accessible.
|
||||
<br/><br/>
|
||||
If you use another browser or another music player, you could try to code your own extension. The API is super simple! Just send a POST HTTP request to
|
||||
|
||||
<span class="stats"><span name="serverurl">yourserver.tld</span>/db/newscrobble</span>
|
||||
|
||||
(make sure to use the public URL) with the key-value-pairs
|
||||
<br/>
|
||||
<br/>
|
||||
<span class="stats">
|
||||
<table>
|
||||
<tr> <td>artist</td> <td><i>Artist String</i></td> </tr>
|
||||
<tr> <td>title</td> <td><i>Title String</i></td> </tr>
|
||||
<tr> <td>key</td> <td><i>API Key</i></td> </tr>
|
||||
<tr> <td>seconds</td> <td><i>Duration of Scrobble - optional and currently not used</i></td> </tr>
|
||||
</table>
|
||||
</span>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<h2>Import your Last.FM data</h2>
|
||||
|
||||
Switching from Last.fm? <a class="textlink" href="https://benjaminbenben.com/lastfm-to-csv/">Download all your data</a> and place the resulting file in your Maloja main folder. Run the command <span class="stats">./lastfmconverter.py <i>(the file you just downloaded)</i> lastfmimport.tsv</span>.
|
||||
<br/><br/>
|
||||
|
||||
<h2>Set up some rules</h2>
|
||||
|
||||
After you've scrobbled for a bit, you might want to check the <a class="textlink" href="/issues">Issues page</a> to see if you need to set up some rules. You can also manually add rules in your server's "rules" directory - just add your own .tsv file and read the instructions on how to declare a rule.
|
||||
<br/><br/>
|
||||
|
||||
<h2>Say thanks</h2>
|
||||
|
||||
Coding open source projects is fun, but not really monetizable. If you like Maloja, I would appreciate a small donation via
|
||||
<a class="textlink" target="_blank" rel="noopener noreferrer" href="https://paypal.me/krateng">PayPal</a> or <a class="textlink" href="bitcoin:1krat8JMniJBTiHftMfR1LtF3Y1w5DAxx">Bitcoin</a>.
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<h2>View your stats</h2>
|
||||
|
||||
Done! Visit <a class="textlink" href="/"><span name="serverurl">yourserver.tld</span></a> (or your public / proxy URL) to look at your overview page. Almost everything is clickable!
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user