diff --git a/maloja/database/sqldb.py b/maloja/database/sqldb.py index a19954d..28256fa 100644 --- a/maloja/database/sqldb.py +++ b/maloja/database/sqldb.py @@ -485,7 +485,7 @@ def get_artist_id(artistname,create_new=True,dbconn=None): @connection_provider def get_album_id(albumdict,create_new=True,ignore_albumartists=False,dbconn=None): ntitle = normalize_name(albumdict['albumtitle']) - artist_ids = [get_artist_id(a,dbconn=dbconn) for a in albumdict.get('artists') or []] + artist_ids = [get_artist_id(a,dbconn=dbconn) for a in (albumdict.get('artists') or [])] artist_ids = list(set(artist_ids)) op = DB['albums'].select( diff --git a/maloja/proccontrol/tasks/import_scrobbles.py b/maloja/proccontrol/tasks/import_scrobbles.py index 1bab1c6..5a194db 100644 --- a/maloja/proccontrol/tasks/import_scrobbles.py +++ b/maloja/proccontrol/tasks/import_scrobbles.py @@ -80,9 +80,6 @@ def import_scrobbles(inputf): # extra info extrainfo = {} - if scrobble.get('album_name'): extrainfo['album_name'] = scrobble['album_name'] - # saving this in the scrobble instead of the track because for now it's not meant - # to be authorative information, just payload of the scrobble scrobblebuffer.append({ "time":scrobble['scrobble_time'], @@ -90,6 +87,11 @@ def import_scrobbles(inputf): "artists":scrobble['track_artists'], "title":scrobble['track_title'], "length":scrobble['track_length'], + "album":{ + "albumtitle":scrobble.get('album_name') or None, + "artists":scrobble.get('album_artists') or scrobble['track_artists'] or None + # TODO: use same heuristics as with parsing to determine album? + } }, "duration":scrobble['scrobble_duration'], "origin":"import:" + typeid,