Skip to content

Commit

Permalink
* fix album parsing error
Browse files Browse the repository at this point in the history
* add some more logging
  • Loading branch information
thesebas committed Nov 3, 2016
1 parent c4606a4 commit d6c1819
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down
14 changes: 8 additions & 6 deletions resources/lib/bc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d6c1819

Please sign in to comment.