New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User.get_now_playing: Add album and cover image to info #330
Conversation
Codecov Report
@@ Coverage Diff @@
## master #330 +/- ##
==========================================
+ Coverage 94.44% 94.93% +0.48%
==========================================
Files 1 1
Lines 1261 1264 +3
==========================================
+ Hits 1191 1200 +9
+ Misses 70 64 -6
Continue to review full report at Codecov.
|
I've tested this, and it adds the cover-art images, but not the album. Is it possible that this function needs to be replaced with the code below: https://github.com/pylast/pylast/blob/add-album-and-image-to-get_now_playing/src/pylast/__init__.py#L2129 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)
albums = doc.getElementsByTagName("album")
if len(albums) == 0:
return
node = doc.getElementsByTagName("album")[0]
return Album(_extract(node, "artist"), _extract(node, "title"), self.network)
return Album(self.artist, self.info["album"], self.network) |
Ah yes, something like that would be useful too. I had checked like: current_track = lastfm_user.get_now_playing()
from pprint import pprint
pprint(current_track.info)
print(current_track.info["image"][pylast.SIZE_LARGE])
print(current_track.info["album"]) But it would be good to check if we already saved So something like the below, which flips the if and returns early But also, So return early def get_album(self):
"""Returns the album object of this track."""
# THESE TWO LINES ARE NEW
if "album" in self.info and self.info["album"] is not None:
return Album(self.artist, self.info["album"], self.network)
doc = self._request(self.ws_prefix + ".getInfo", True)
albums = doc.getElementsByTagName("album")
if len(albums) == 0:
return
node = doc.getElementsByTagName("album")[0]
return Album(_extract(node, "artist"), _extract(node, "title"), self.network) What do you think? |
Fixes #329.
Changes proposed in this pull request:
User.get_now_playing
: Addalbum
name and cover artworkimage
URLs toinfo
user.get_top_albums