mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Minor cleanup and better logging
This commit is contained in:
parent
817d98e467
commit
26dfdfb569
@ -5,7 +5,7 @@ author = {
|
||||
"email":"maloja@dev.krateng.ch",
|
||||
"github": "krateng"
|
||||
}
|
||||
version = 2,12,15
|
||||
version = 2,12,16
|
||||
versionstr = ".".join(str(n) for n in version)
|
||||
links = {
|
||||
"pypi":"malojaserver",
|
||||
|
7
maloja/thirdparty/__init__.py
vendored
7
maloja/thirdparty/__init__.py
vendored
@ -36,7 +36,7 @@ def get_image_track_all(track):
|
||||
else:
|
||||
log("Could not get track image for " + str(track) + " from " + service.name)
|
||||
except Exception as e:
|
||||
log("Error getting track image from " + service.name + ": " + str(e))
|
||||
log("Error getting track image from " + service.name + ": " + repr(e))
|
||||
def get_image_artist_all(artist):
|
||||
for service in services["metadata"]:
|
||||
try:
|
||||
@ -47,7 +47,7 @@ def get_image_artist_all(artist):
|
||||
else:
|
||||
log("Could not get artist image for " + str(artist) + " from " + service.name)
|
||||
except Exception as e:
|
||||
log("Error getting artist image from " + service.name + ": " + str(e))
|
||||
log("Error getting artist image from " + service.name + ": " + repr(e))
|
||||
|
||||
|
||||
|
||||
@ -70,8 +70,7 @@ class GenericInterface:
|
||||
# avoid constant disk access, restart on adding services is acceptable
|
||||
for key in self.settings:
|
||||
self.settings[key] = get_settings(self.settings[key])
|
||||
try: self.authorize()
|
||||
except: pass
|
||||
self.authorize()
|
||||
|
||||
def __init_subclass__(cls,abstract=False):
|
||||
if not abstract:
|
||||
|
3
maloja/thirdparty/lastfm.py
vendored
3
maloja/thirdparty/lastfm.py
vendored
@ -21,9 +21,8 @@ class LastFM(MetadataInterface, ProxyScrobbleInterface):
|
||||
metadata = {
|
||||
"trackurl": "https://ws.audioscrobbler.com/2.0/?method=track.getinfo&track={title}&artist={artist}&api_key={apikey}&format=json",
|
||||
"response_type":"json",
|
||||
"response_parse_tree_track": ["track","album","image",3,"#text"],
|
||||
"response_parse_tree_track": ["track","album","image",-1,"#text"],
|
||||
"required_settings": ["apikey"],
|
||||
"activated_setting": "METADATA_LASTFM"
|
||||
}
|
||||
|
||||
def get_image_artist(self,artist):
|
||||
|
1
maloja/thirdparty/musicbrainz.py
vendored
1
maloja/thirdparty/musicbrainz.py
vendored
@ -20,7 +20,6 @@ class MusicBrainz(MetadataInterface):
|
||||
"response_type":"json",
|
||||
"response_parse_tree_track": ["images",0,"image"],
|
||||
"required_settings": [],
|
||||
"activated_setting": "METADATA_MUSICBRAINZ"
|
||||
}
|
||||
|
||||
def get_image_artist(self,artist):
|
||||
|
10
maloja/thirdparty/spotify.py
vendored
10
maloja/thirdparty/spotify.py
vendored
@ -2,6 +2,7 @@ from . import MetadataInterface, utf, b64
|
||||
import urllib.parse, urllib.request
|
||||
import json
|
||||
from threading import Timer
|
||||
from doreah.logging import log
|
||||
|
||||
class Spotify(MetadataInterface):
|
||||
name = "Spotify"
|
||||
@ -19,7 +20,6 @@ class Spotify(MetadataInterface):
|
||||
"response_parse_tree_track": ["tracks","items",0,"album","images",0,"url"],
|
||||
"response_parse_tree_artist": ["artists","items",0,"images",0,"url"],
|
||||
"required_settings": ["apiid","secret"],
|
||||
"activated_setting": "METADATA_SPOTIFY"
|
||||
}
|
||||
|
||||
def authorize(self):
|
||||
@ -32,10 +32,18 @@ class Spotify(MetadataInterface):
|
||||
},
|
||||
"data":bytes(urllib.parse.urlencode({"grant_type":"client_credentials"}),encoding="utf-8")
|
||||
}
|
||||
try:
|
||||
req = urllib.request.Request(**keys)
|
||||
response = urllib.request.urlopen(req)
|
||||
responsedata = json.loads(response.read())
|
||||
if "error" in responsedata:
|
||||
log("Error authenticating with Spotify: " + responsedata['error_description'])
|
||||
expire = 3600
|
||||
else:
|
||||
expire = responsedata.get("expires_in",3600)
|
||||
self.settings["token"] = responsedata["access_token"]
|
||||
except Exception as e:
|
||||
log("Error while authenticating with Spotify: " + str(e))
|
||||
expire = 3600
|
||||
Timer(expire,self.authorize).start()
|
||||
return True
|
||||
|
@ -614,7 +614,7 @@ table.list td.chart div {
|
||||
height:4px;
|
||||
*/
|
||||
height:20px;
|
||||
background-color: var(--text-color-tertiary);
|
||||
background-color: var(--base-color-dark);
|
||||
border-radius: 0px 30px 30px 0px;
|
||||
background-image:url("/media/chartpos_normal.png");
|
||||
background-position: right;
|
||||
|
Loading…
Reference in New Issue
Block a user