From d6c1819245b96ad7fac6177193e513aea4a2523f Mon Sep 17 00:00:00 2001 From: thesebas Date: Thu, 3 Nov 2016 09:35:48 +0100 Subject: [PATCH] * fix album parsing error * add some more logging --- default.py | 1 + resources/lib/bc/__init__.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/default.py b/default.py index 6176283..8e9a583 100644 --- a/default.py +++ b/default.py @@ -174,6 +174,7 @@ def albumlist(params, parts, route): album_url = urllib.unquote(params["url"][0]) print "getting album: %s" % album_url tracks = bc.get_album_tracks(album_url) + print tracks return [track_to_listitem(track) for track in tracks] diff --git a/resources/lib/bc/__init__.py b/resources/lib/bc/__init__.py index 7e2d80f..339d11e 100644 --- a/resources/lib/bc/__init__.py +++ b/resources/lib/bc/__init__.py @@ -161,11 +161,11 @@ def get_collection(user): @MeasureTime def get_album_tracks(url): body = load_url(url) - m = re.search("trackinfo : (.*),", body, re.M) - #print m + m = re.search("trackinfo: (.*),", body, re.M) + print "trackinfo body", m if m: data = json.loads(m.group(1)) - #print data + print "parsed data", data m = re.search('artist: "(.*)"', body, re.M) artist = m.group(1) tracks = [track for track in [tralbumdata_to_track(track) for track in data] if track is not None] @@ -233,9 +233,11 @@ def get_album_data_by_url(url): def get_album_by_url(url): album_data = get_album_data_by_url(url) - album = Album(title=album_data['title'], cover=album_data["artFullsizeUrl"]) - - return album + try: + return Album(title=album_data['title'], cover=album_data["artFullsizeUrl"]) + except KeyError as e: + print e.message + return Album(title=album_data['title']) @MeasureTime