From 69b456dc73e1108e374091cddd07337a7390463e Mon Sep 17 00:00:00 2001 From: krateng Date: Tue, 28 Mar 2023 18:41:49 +0200 Subject: [PATCH] Scrobbling fixes --- maloja/apis/native_v1.py | 10 +++++++--- maloja/database/__init__.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index 4e9c49f..cd031a2 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -494,19 +494,23 @@ def post_scrobble( 'artists':result['track']['artists'], 'title':result['track']['title'] }, - 'desc':f"Scrobbled {result['track']['title']} by {', '.join(result['track']['artists'])}" + 'desc':f"Scrobbled {result['track']['title']} by {', '.join(result['track']['artists'])}", + 'warnings':[] } if extra_kwargs: - responsedict['warnings'] = [ + responsedict['warnings'] += [ {'type':'invalid_keyword_ignored','value':k, 'desc':"This key was not recognized by the server and has been discarded."} for k in extra_kwargs ] if artist and artists: - responsedict['warnings'] = [ + responsedict['warnings'] += [ {'type':'mixed_schema','value':['artist','artists'], 'desc':"These two fields are meant as alternative methods to submit information. Use of both is discouraged, but works at the moment."} ] + + if len(responsedict['warnings']) == 0: del responsedict['warnings'] + return responsedict diff --git a/maloja/database/__init__.py b/maloja/database/__init__.py index fb9f48b..9204367 100644 --- a/maloja/database/__init__.py +++ b/maloja/database/__init__.py @@ -143,7 +143,7 @@ def rawscrobble_to_scrobbledict(rawscrobble, fix=True, client=None): "artists":scrobbleinfo.get('track_artists'), "title":scrobbleinfo.get('track_title'), "album":{ - "title":scrobbleinfo.get('album_title') or scrobbleinfo.get('album_name'), + "albumtitle":scrobbleinfo.get('album_title'), "artists":scrobbleinfo.get('album_artists') }, "length":scrobbleinfo.get('track_length') @@ -152,7 +152,7 @@ def rawscrobble_to_scrobbledict(rawscrobble, fix=True, client=None): "origin":f"client:{client}" if client else "generic", "extra":{ k:scrobbleinfo[k] for k in scrobbleinfo if k not in - ['scrobble_time','track_artists','track_title','track_length','scrobble_duration','album_title','album_name','album_artists'] + ['scrobble_time','track_artists','track_title','track_length','scrobble_duration','album_title','album_artists'] }, "rawscrobble":rawscrobble }