Skip to content

Commit

Permalink
Add extra album info to the recent track
Browse files Browse the repository at this point in the history
  • Loading branch information
vervaekejonathan committed Jun 1, 2020
1 parent 898a8b5 commit a12a00a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/pylast/__init__.py
Expand Up @@ -547,7 +547,6 @@ def scrobble(
context=None,
mbid=None,
):

"""Used to add a track-play to a user's profile.
Parameters:
Expand Down Expand Up @@ -2128,16 +2127,17 @@ def is_fulltrack_available(self):

def get_album(self):
"""Returns the album object of this track."""
if "album" not in self.info:
doc = self._request(self.ws_prefix + ".getInfo", True)

doc = self._request(self.ws_prefix + ".getInfo", True)

albums = doc.getElementsByTagName("album")
albums = doc.getElementsByTagName("album")

if len(albums) == 0:
return
if len(albums) == 0:
return

node = doc.getElementsByTagName("album")[0]
return Album(_extract(node, "artist"), _extract(node, "title"), self.network)
node = doc.getElementsByTagName("album")[0]
return Album(_extract(node, "artist"), _extract(node, "title"), self.network)
return Album(self.artist, self.info["album"], self.network)

def love(self):
"""Adds the track to the user's loved tracks. """
Expand Down Expand Up @@ -2338,8 +2338,9 @@ def get_now_playing(self):

artist = _extract(e, "artist")
title = _extract(e, "name")
info = {"image": _extract_all(e, "image"), "album": _extract(e, 'album')}

return Track(artist, title, self.network, self.name)
return Track(artist, title, self.network, self.name, info=info)

def get_recent_tracks(self, limit=10, cacheable=True, time_from=None, time_to=None):
"""
Expand Down

0 comments on commit a12a00a

Please sign in to comment.