mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added requirements.txt and fixed error when not using API keys
This commit is contained in:
parent
410eee4a4d
commit
dbba4ed671
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,7 +1,7 @@
|
|||||||
# generic temporary / dev files
|
# generic temporary / dev files
|
||||||
*.pyc
|
*.pyc
|
||||||
*.sh
|
*.sh
|
||||||
*.txt
|
*.note
|
||||||
*.xcf
|
*.xcf
|
||||||
nohup.out
|
nohup.out
|
||||||
/.dev
|
/.dev
|
||||||
|
11
README.md
11
README.md
@ -21,6 +21,7 @@ Also neat: You can use your **custom artist or track images**.
|
|||||||
* [waitress](https://docs.pylonsproject.org/projects/waitress/) - [GitHub](https://github.com/Pylons/waitress)
|
* [waitress](https://docs.pylonsproject.org/projects/waitress/) - [GitHub](https://github.com/Pylons/waitress)
|
||||||
* [doreah](https://pypi.org/project/doreah/) - [GitHub](https://github.com/krateng/doreah) (at least Version 0.7.2)
|
* [doreah](https://pypi.org/project/doreah/) - [GitHub](https://github.com/krateng/doreah) (at least Version 0.7.2)
|
||||||
* [nimrodel](https://pypi.org/project/nimrodel/) - [GitHub](https://github.com/krateng/nimrodel) (at least Version 0.4.4)
|
* [nimrodel](https://pypi.org/project/nimrodel/) - [GitHub](https://github.com/krateng/nimrodel) (at least Version 0.4.4)
|
||||||
|
* [setproctitle](https://pypi.org/project/setproctitle/) - [GitHub](https://github.com/dvarrazzo/py-setproctitle)
|
||||||
* If you'd like to display images, you will need API keys for [Last.fm](https://www.last.fm/api/account/create) and [Fanart.tv](https://fanart.tv/get-an-api-key/). These are free of charge!
|
* If you'd like to display images, you will need API keys for [Last.fm](https://www.last.fm/api/account/create) and [Fanart.tv](https://fanart.tv/get-an-api-key/). These are free of charge!
|
||||||
|
|
||||||
## How to install
|
## How to install
|
||||||
@ -29,13 +30,15 @@ Also neat: You can use your **custom artist or track images**.
|
|||||||
|
|
||||||
./maloja install
|
./maloja install
|
||||||
|
|
||||||
2) Start the server with
|
2) Install required packages with
|
||||||
|
|
||||||
|
pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
3) Start the server with
|
||||||
|
|
||||||
maloja start
|
maloja start
|
||||||
|
|
||||||
If you're missing packages, the console output will tell you so. Install them.
|
4) (Recommended) Put your server behind a reverse proxy for SSL encryption.
|
||||||
|
|
||||||
2) (Recommended) Put your server behind a reverse proxy for SSL encryption.
|
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
|
47
external.py
47
external.py
@ -5,53 +5,60 @@ from doreah.settings import get_settings
|
|||||||
from doreah.logging import log
|
from doreah.logging import log
|
||||||
|
|
||||||
|
|
||||||
apis_artists = [
|
apis_artists = []
|
||||||
{
|
|
||||||
|
if get_settings("LASTFM_API_KEY") not in [None,"ASK"] and get_settings("FANARTTV_API_KEY") not in [None,"ASK"]:
|
||||||
|
apis_artists.append({
|
||||||
"name":"LastFM + Fanart.tv",
|
"name":"LastFM + Fanart.tv",
|
||||||
"check":get_settings("LASTFM_API_KEY") not in [None,"ASK"] and get_settings("FANARTTV_API_KEY") not in [None,"ASK"],
|
#"check":get_settings("LASTFM_API_KEY") not in [None,"ASK"] and get_settings("FANARTTV_API_KEY") not in [None,"ASK"],
|
||||||
"steps":[
|
"steps":[
|
||||||
("get","http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist={artiststring}&api_key=" + get_settings("LASTFM_API_KEY") + "&format=json"),
|
("get","http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist={artiststring}&api_key=" + str(get_settings("LASTFM_API_KEY")) + "&format=json"),
|
||||||
("parse",["artist","mbid"]),
|
("parse",["artist","mbid"]),
|
||||||
("get","http://webservice.fanart.tv/v3/music/{var}?api_key=" + get_settings("FANARTTV_API_KEY")),
|
("get","http://webservice.fanart.tv/v3/music/{var}?api_key=" + str(get_settings("FANARTTV_API_KEY"))),
|
||||||
("parse",["artistthumb",0,"url"])
|
("parse",["artistthumb",0,"url"])
|
||||||
]
|
]
|
||||||
},
|
})
|
||||||
{
|
|
||||||
|
if get_settings("SPOTIFY_API_ID") not in [None,"ASK"] and get_settings("SPOTIFY_API_SECRET") not in [None,"ASK"]:
|
||||||
|
apis_artists.append({
|
||||||
"name":"Spotify",
|
"name":"Spotify",
|
||||||
"check":get_settings("SPOTIFY_API_ID") not in [None,"ASK"] and get_settings("SPOTIFY_API_SECRET") not in [None,"ASK"],
|
#"check":get_settings("SPOTIFY_API_ID") not in [None,"ASK"] and get_settings("SPOTIFY_API_SECRET") not in [None,"ASK"],
|
||||||
"steps":[
|
"steps":[
|
||||||
("post","https://accounts.spotify.com/api/token",{"Authorization":"Basic " + base64.b64encode(bytes(get_settings("SPOTIFY_API_ID") + ":" + get_settings("SPOTIFY_API_SECRET"),encoding="utf-8")).decode("utf-8")},{"grant_type":"client_credentials"}),
|
("post","https://accounts.spotify.com/api/token",{"Authorization":"Basic " + base64.b64encode(bytes(get_settings("SPOTIFY_API_ID") + ":" + get_settings("SPOTIFY_API_SECRET"),encoding="utf-8")).decode("utf-8")},{"grant_type":"client_credentials"}),
|
||||||
("parse",["access_token"]),
|
("parse",["access_token"]),
|
||||||
("get","https://api.spotify.com/v1/search?q={artiststring}&type=artist&access_token={var}"),
|
("get","https://api.spotify.com/v1/search?q={artiststring}&type=artist&access_token={var}"),
|
||||||
("parse",["artists","items",0,"images",0,"url"])
|
("parse",["artists","items",0,"images",0,"url"])
|
||||||
]
|
]
|
||||||
}
|
})
|
||||||
]
|
|
||||||
|
|
||||||
apis_tracks = [
|
apis_tracks = []
|
||||||
{
|
|
||||||
|
if get_settings("LASTFM_API_KEY") not in [None,"ASK"]:
|
||||||
|
apis_tracks.append({
|
||||||
"name":"LastFM",
|
"name":"LastFM",
|
||||||
"check":get_settings("LASTFM_API_KEY") not in [None,"ASK"],
|
#"check":get_settings("LASTFM_API_KEY") not in [None,"ASK"],
|
||||||
"steps":[
|
"steps":[
|
||||||
("get","https://ws.audioscrobbler.com/2.0/?method=track.getinfo&track={titlestring}&artist={artiststring}&api_key=" + get_settings("LASTFM_API_KEY") + "&format=json"),
|
("get","https://ws.audioscrobbler.com/2.0/?method=track.getinfo&track={titlestring}&artist={artiststring}&api_key=" + get_settings("LASTFM_API_KEY") + "&format=json"),
|
||||||
("parse",["track","album","image",3,"#text"])
|
("parse",["track","album","image",3,"#text"])
|
||||||
]
|
]
|
||||||
},
|
})
|
||||||
{
|
|
||||||
|
if get_settings("SPOTIFY_API_ID") not in [None,"ASK"] and get_settings("SPOTIFY_API_SECRET") not in [None,"ASK"]:
|
||||||
|
apis_tracks.append({
|
||||||
"name":"Spotify",
|
"name":"Spotify",
|
||||||
"check":get_settings("SPOTIFY_API_ID") not in [None,"ASK"] and get_settings("SPOTIFY_API_SECRET") not in [None,"ASK"],
|
#"check":get_settings("SPOTIFY_API_ID") not in [None,"ASK"] and get_settings("SPOTIFY_API_SECRET") not in [None,"ASK"],
|
||||||
"steps":[
|
"steps":[
|
||||||
("post","https://accounts.spotify.com/api/token",{"Authorization":"Basic " + base64.b64encode(bytes(get_settings("SPOTIFY_API_ID") + ":" + get_settings("SPOTIFY_API_SECRET"),encoding="utf-8")).decode("utf-8")},{"grant_type":"client_credentials"}),
|
("post","https://accounts.spotify.com/api/token",{"Authorization":"Basic " + base64.b64encode(bytes(get_settings("SPOTIFY_API_ID") + ":" + get_settings("SPOTIFY_API_SECRET"),encoding="utf-8")).decode("utf-8")},{"grant_type":"client_credentials"}),
|
||||||
("parse",["access_token"]),
|
("parse",["access_token"]),
|
||||||
("get","https://api.spotify.com/v1/search?q={artiststring}%20{titlestring}&type=track&access_token={var}"),
|
("get","https://api.spotify.com/v1/search?q={artiststring}%20{titlestring}&type=track&access_token={var}"),
|
||||||
("parse",["tracks","items",0,"album","images",0,"url"])
|
("parse",["tracks","items",0,"album","images",0,"url"])
|
||||||
]
|
]
|
||||||
}
|
})
|
||||||
]
|
|
||||||
|
|
||||||
def api_request_artist(artist):
|
def api_request_artist(artist):
|
||||||
for api in apis_artists:
|
for api in apis_artists:
|
||||||
if api["check"]:
|
if True:
|
||||||
log("API: " + api["name"] + "; Image request: " + artist,module="external")
|
log("API: " + api["name"] + "; Image request: " + artist,module="external")
|
||||||
try:
|
try:
|
||||||
artiststring = urllib.parse.quote(artist)
|
artiststring = urllib.parse.quote(artist)
|
||||||
@ -85,7 +92,7 @@ def api_request_artist(artist):
|
|||||||
def api_request_track(track):
|
def api_request_track(track):
|
||||||
artists, title = track
|
artists, title = track
|
||||||
for api in apis_tracks:
|
for api in apis_tracks:
|
||||||
if api["check"]:
|
if True:
|
||||||
log("API: " + api["name"] + "; Image request: " + "/".join(artists) + " - " + title,module="external")
|
log("API: " + api["name"] + "; Image request: " + "/".join(artists) + " - " + title,module="external")
|
||||||
try:
|
try:
|
||||||
artiststring = urllib.parse.quote(", ".join(artists))
|
artiststring = urllib.parse.quote(", ".join(artists))
|
||||||
|
6
maloja
6
maloja
@ -118,10 +118,10 @@ def install():
|
|||||||
|
|
||||||
if toinstall != [] or toinstallr != []:
|
if toinstall != [] or toinstallr != []:
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
print("Installing python modules should be fairly straight-forward, but Maloja can try to install them automatically. For this, you need to run this script as a root user.")
|
print("You can install them with",yellow("pip install -r requirements.txt"),"or Maloja can try to install them automatically. For this, you need to run this script as a root user.")
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print("Installing python modules should be fairly straight-forward, but Maloja can try to install them automatically, This might or might not work / bloat your system / cause a nuclear war.")
|
print("You can install them with",yellow("pip install -r requirements.txt"),"or Maloja can try to install them automatically, This might or might not work / bloat your system / cause a nuclear war.")
|
||||||
fail = False
|
fail = False
|
||||||
if toinstall != []:
|
if toinstall != []:
|
||||||
print("Attempt to install required modules? [Y/n]")
|
print("Attempt to install required modules? [Y/n]")
|
||||||
@ -284,7 +284,7 @@ def update():
|
|||||||
|
|
||||||
os.chmod("./maloja",os.stat("./maloja").st_mode | stat.S_IXUSR)
|
os.chmod("./maloja",os.stat("./maloja").st_mode | stat.S_IXUSR)
|
||||||
|
|
||||||
print("Make sure to install the latest version of doreah! (" + yellow("pip3 install --upgrade --no-cache-dir doreah") + ")")
|
print("Make sure to update required modules! (" + yellow("pip3 install -r requirements.txt --upgrade --no-cache-dir") + ")")
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
bottle>=0.12.16
|
||||||
|
waitress>=1.3
|
||||||
|
doreah>=0.7.2
|
||||||
|
nimrodel>=0.4.4
|
||||||
|
setproctitle>=1.1.10
|
Loading…
Reference in New Issue
Block a user