Include album title in proxy scrobbles

This commit is contained in:
Sunny 2025-03-05 17:22:57 +01:00
parent 3ba27ffc37
commit 5c7ba632e0
No known key found for this signature in database
GPG Key ID: 6C809239719866E4
3 changed files with 18 additions and 8 deletions

View File

@ -114,8 +114,13 @@ def incoming_scrobble(rawscrobble,fix=True,client=None,api=None,dbconn=None):
if scrobbledict:
if 'album' in scrobbledict['track'] and 'albumtitle' in scrobbledict['track']['album']:
albumtitle = scrobbledict['track']['album']['albumtitle']
else:
albumtitle = None
sqldb.add_scrobble(scrobbledict,update_album=albumupdate,dbconn=dbconn)
proxy_scrobble_all(scrobbledict['track']['artists'],scrobbledict['track']['title'],scrobbledict['time'])
proxy_scrobble_all(scrobbledict['track']['artists'],scrobbledict['track']['title'],albumtitle,scrobbledict['time'])
dbcache.invalidate_caches(scrobbledict['time'])

View File

@ -45,9 +45,9 @@ def import_scrobbles(identifier):
return service.import_scrobbles()
return False
def proxy_scrobble_all(artists,title,timestamp):
def proxy_scrobble_all(artists,title,album,timestamp):
for service in services["proxyscrobble"]:
service.scrobble(artists,title,timestamp)
service.scrobble(artists,title,album,timestamp)
def get_image_track_all(track):
with thirdpartylock:
@ -153,10 +153,10 @@ class ProxyScrobbleInterface(GenericInterface,abstract=True):
malojaconfig[self.proxyscrobble["activated_setting"]]
)
def scrobble(self,artists,title,timestamp):
def scrobble(self,artists,title,album,timestamp):
response = requests.post(
url=self.proxyscrobble["scrobbleurl"],
data=self.proxyscrobble_postdata(artists,title,timestamp),
data=self.proxyscrobble_postdata(artists,title,album,timestamp),
headers={
"User-Agent":self.useragent
}

View File

@ -44,15 +44,20 @@ class LastFM(MetadataInterface, ProxyScrobbleInterface):
def proxyscrobble_parse_response(self,data):
return data.attrib.get("status") == "ok" and data.find("scrobbles").attrib.get("ignored") == "0"
def proxyscrobble_postdata(self,artists,title,timestamp):
return self.query_compose({
def proxyscrobble_postdata(self,artists,title,album,timestamp):
parameters = {
"method":"track.scrobble",
"artist[0]":", ".join(artists),
"track[0]":title,
"timestamp":timestamp,
"api_key":self.settings["apikey"],
"sk":self.settings["sk"]
})
}
if album is not None:
parameters["album[0]"] = album
return self.query_compose(parameters)
def authorize(self):
if all(self.settings[key] not in [None,"ASK",False] for key in ["username","password","apikey","secret"]):