mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
logger stuff
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ class CustomFormatter(logging.Formatter):
|
|||||||
return formatter.format(record)
|
return formatter.format(record)
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger("swing")
|
log = logging.getLogger("SWING MUSIC")
|
||||||
log.propagate = False
|
log.propagate = False
|
||||||
log.setLevel(logging.DEBUG)
|
log.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from app.utils.auth import get_current_userid
|
|||||||
from app.utils.threading import background
|
from app.utils.threading import background
|
||||||
from app.plugins import Plugin, plugin_method
|
from app.plugins import Plugin, plugin_method
|
||||||
|
|
||||||
|
from app.logger import log
|
||||||
|
|
||||||
class LastFmPlugin(Plugin):
|
class LastFmPlugin(Plugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -60,7 +61,7 @@ class LastFmPlugin(Plugin):
|
|||||||
@plugin_method
|
@plugin_method
|
||||||
@background
|
@background
|
||||||
def scrobble(self, track: Track, timestamp: int):
|
def scrobble(self, track: Track, timestamp: int):
|
||||||
print("Last.fm: logging track: ", track.title, "-", track.artists[0]["name"])
|
log.info(f"Last.fm: logging track: {track.title} - {track.artists[0]['name']}")
|
||||||
data = {
|
data = {
|
||||||
"method": "track.scrobble",
|
"method": "track.scrobble",
|
||||||
"artist": track.artists[0]["name"],
|
"artist": track.artists[0]["name"],
|
||||||
@@ -70,11 +71,11 @@ class LastFmPlugin(Plugin):
|
|||||||
"albumArtist": track.albumartists[0]["name"],
|
"albumArtist": track.albumartists[0]["name"],
|
||||||
}
|
}
|
||||||
|
|
||||||
print("scrobble data:", data)
|
log.info(f"scrobble data: {data}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = self.post(data)
|
res = self.post(data)
|
||||||
print("scrobble response:", res.text)
|
log.info("scrobble response:" + str(res.text))
|
||||||
print("scrobble response json:", res.json())
|
log.info("scrobble response json:" + str(res.json()))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("scrobble error", e)
|
log.info("scrobble error" + str(e))
|
||||||
|
|||||||
Reference in New Issue
Block a user