From 924d4718db8f1bf3c91733a2160dd33cf87e59b4 Mon Sep 17 00:00:00 2001 From: krateng Date: Fri, 31 Mar 2023 14:47:30 +0200 Subject: [PATCH] Fixed album parsing from raw scrobble, GH-207 --- maloja/database/sqldb.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/maloja/database/sqldb.py b/maloja/database/sqldb.py index c39ba5a..b6fd6e1 100644 --- a/maloja/database/sqldb.py +++ b/maloja/database/sqldb.py @@ -1513,7 +1513,7 @@ def guess_albums(track_ids=None,replace=False,dbconn=None): # get all scrobbles of the respective tracks that have some info conditions = [ - DB['scrobbles'].c.extra.isnot(None) + DB['scrobbles'].c.extra.isnot(None) | DB['scrobbles'].c.rawscrobble.isnot(None) ] if track_ids is not None: # only do these tracks @@ -1537,10 +1537,13 @@ def guess_albums(track_ids=None,replace=False,dbconn=None): # for each track, count what album info appears how often possible_albums = {} for row in result: - extrainfo = json.loads(row.extra) - albumtitle = extrainfo.get("album_name") or extrainfo.get("album_title") - albumartists = extrainfo.get("album_artists",[]) + albumtitle, albumartists = None, None + if row.extra: + extrainfo = json.loads(row.extra) + albumtitle = extrainfo.get("album_name") or extrainfo.get("album_title") + albumartists = extrainfo.get("album_artists",[]) if not albumtitle: + # either we didn't have info in the exta col, or there was no albumtitle # try the raw scrobble extrainfo = json.loads(row.rawscrobble) albumtitle = extrainfo.get("album_name") or extrainfo.get("album_title")