mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Fixed convoluted old scrobbling functionality
This commit is contained in:
parent
034f8b32c7
commit
a64d3610d3
@ -95,7 +95,6 @@ class APIHandler:
|
|||||||
if time is None: time = int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
if time is None: time = int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
||||||
try:
|
try:
|
||||||
(artists,title) = cla.fullclean(artiststr,titlestr)
|
(artists,title) = cla.fullclean(artiststr,titlestr)
|
||||||
database.createScrobble(artists,title,time)
|
database.incoming_scrobble(artists,title,time)
|
||||||
database.sync()
|
|
||||||
except:
|
except:
|
||||||
raise ScrobblingException()
|
raise ScrobblingException()
|
||||||
|
@ -64,11 +64,6 @@ def waitfordb(func):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
MEDALS_ARTISTS = {} #literally only changes once per year, no need to calculate that on the fly
|
|
||||||
MEDALS_TRACKS = {}
|
|
||||||
WEEKLY_TOPTRACKS = {}
|
|
||||||
WEEKLY_TOPARTISTS = {}
|
|
||||||
|
|
||||||
ISSUES = {}
|
ISSUES = {}
|
||||||
|
|
||||||
cla = CleanerAgent()
|
cla = CleanerAgent()
|
||||||
@ -77,10 +72,19 @@ coa = CollectorAgent()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def createScrobble(artists,title,time,album=None,duration=None,volatile=False):
|
def incoming_scrobble(artists,title,album=None,albumartists=None,duration=None,time=None,fix=True):
|
||||||
|
if time is None:
|
||||||
|
time = int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
||||||
|
|
||||||
|
log("Incoming scrobble (): ARTISTS: " + str(artists) + ", TRACK: " + title,module="debug")
|
||||||
|
if fix:
|
||||||
|
(artists,title) = cla.fullclean(artists,title)
|
||||||
|
|
||||||
if len(artists) == 0 or title == "":
|
if len(artists) == 0 or title == "":
|
||||||
return {}
|
return {"status":"failure"}
|
||||||
|
|
||||||
|
if albumartists is None:
|
||||||
|
albumartists = artists
|
||||||
|
|
||||||
scrobbledict = {
|
scrobbledict = {
|
||||||
"time":time,
|
"time":time,
|
||||||
@ -89,7 +93,7 @@ def createScrobble(artists,title,time,album=None,duration=None,volatile=False):
|
|||||||
"title":title,
|
"title":title,
|
||||||
"album":{
|
"album":{
|
||||||
"name":album,
|
"name":album,
|
||||||
"artists":None
|
"artists":albumartists
|
||||||
},
|
},
|
||||||
"length":None
|
"length":None
|
||||||
},
|
},
|
||||||
@ -97,9 +101,11 @@ def createScrobble(artists,title,time,album=None,duration=None,volatile=False):
|
|||||||
"origin":"generic"
|
"origin":"generic"
|
||||||
}
|
}
|
||||||
|
|
||||||
add_scrobble(scrobbledict)
|
sqldb.add_scrobble(scrobbledict)
|
||||||
proxy_scrobble_all(artists,title,time)
|
proxy_scrobble_all(artists,title,time)
|
||||||
return scrobbledict
|
|
||||||
|
return {"status":"success","scrobble":scrobbledict}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -291,18 +297,7 @@ def track_info(track):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def incoming_scrobble(artists,title,album=None,duration=None,time=None,fix=True):
|
|
||||||
if time is None:
|
|
||||||
time = int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
|
||||||
|
|
||||||
log("Incoming scrobble (): ARTISTS: " + str(artists) + ", TRACK: " + title,module="debug")
|
|
||||||
if fix:
|
|
||||||
(artists,title) = cla.fullclean(artists,title)
|
|
||||||
trackdict = createScrobble(artists,title,time,album,duration)
|
|
||||||
|
|
||||||
sync()
|
|
||||||
|
|
||||||
return {"status":"success","track":trackdict}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2
maloja/thirdparty/__init__.py
vendored
2
maloja/thirdparty/__init__.py
vendored
@ -154,7 +154,7 @@ class ImportInterface(GenericInterface,abstract=True):
|
|||||||
|
|
||||||
def import_scrobbles(self):
|
def import_scrobbles(self):
|
||||||
for scrobble in self.get_remote_scrobbles():
|
for scrobble in self.get_remote_scrobbles():
|
||||||
database.createScrobble(
|
database.incoming_scrobble(
|
||||||
artists=scrobble['artists'],
|
artists=scrobble['artists'],
|
||||||
title=scrobble['title'],
|
title=scrobble['title'],
|
||||||
time=scrobble['time']
|
time=scrobble['time']
|
||||||
|
@ -83,8 +83,8 @@ function scrobble(artists,title) {
|
|||||||
|
|
||||||
function scrobbledone(req) {
|
function scrobbledone(req) {
|
||||||
result = req.response;
|
result = req.response;
|
||||||
txt = result["track"]["title"] + " by " + result["track"]["artists"][0];
|
txt = result["scrobble"]["track"]["title"] + " by " + result["scrobble"]["track"]["artists"][0];
|
||||||
if (result["track"]["artists"].length > 1) {
|
if (result["scrobble"]["track"]["artists"].length > 1) {
|
||||||
txt += " et al.";
|
txt += " et al.";
|
||||||
}
|
}
|
||||||
document.getElementById("notification").innerHTML = "Scrobbled " + txt + "!";
|
document.getElementById("notification").innerHTML = "Scrobbled " + txt + "!";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user