1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Saving additional info for Listenbrainz API, fix GH-149

This commit is contained in:
krateng 2022-05-17 16:34:09 +02:00
parent 084c7d5a1e
commit 1eaba888c7
2 changed files with 15 additions and 1 deletions

View File

@ -23,6 +23,10 @@ minor_release_name: "Soyeon"
- "[Bugfix] Fixed leftover whitespaces when parsing titles" - "[Bugfix] Fixed leftover whitespaces when parsing titles"
- "[Bugfix] Fixed handling of fallthrough values in config file" - "[Bugfix] Fixed handling of fallthrough values in config file"
3.1.3: 3.1.3:
commit: "f3a04c79b1c37597cdf3cafcd95e3c923cd6a53f"
notes: notes:
- "[Bugfix] Fixed infinite recursion with capitalized featuring delimiters" - "[Bugfix] Fixed infinite recursion with capitalized featuring delimiters"
- "[Bugfix] Fixed favicon display" - "[Bugfix] Fixed favicon display"
3.1.4:
notes:
- "[Feature] Expanded information saved from Listenbrainz API"

View File

@ -55,6 +55,7 @@ class Listenbrainz(APIHandler):
try: try:
metadata = listen["track_metadata"] metadata = listen["track_metadata"]
artiststr, titlestr = metadata["artist_name"], metadata["track_name"] artiststr, titlestr = metadata["artist_name"], metadata["track_name"]
additional = metadata.get("additional_info",{})
try: try:
timestamp = int(listen["listened_at"]) timestamp = int(listen["listened_at"])
except Exception: except Exception:
@ -62,10 +63,19 @@ class Listenbrainz(APIHandler):
except Exception: except Exception:
raise MalformedJSONException() raise MalformedJSONException()
extrafields = {
# fields that will not be consumed by regular scrobbling
# will go into 'extra'
k:additional[k]
for k in ['release_mbid','artist_mbids','recording_mbid','tags']
if k in additional
}
self.scrobble({ self.scrobble({
'track_artists':[artiststr], 'track_artists':[artiststr],
'track_title':titlestr, 'track_title':titlestr,
'scrobble_time':timestamp 'scrobble_time':timestamp,
**extrafields
},client=client) },client=client)
return 200,{"status":"ok"} return 200,{"status":"ok"}