Add support for chart artists/tracks.
This commit is contained in:
parent
ad525bdd8b
commit
79a43919cc
1
AUTHORS
1
AUTHORS
|
@ -1 +1,2 @@
|
||||||
Amr Hassan <amr.hassan@gmail.com>
|
Amr Hassan <amr.hassan@gmail.com>
|
||||||
|
Lukas Lipka <lukaslipka@gmail.com>
|
||||||
|
|
31
pylast.py
31
pylast.py
|
@ -313,6 +313,37 @@ class _Network(object):
|
||||||
|
|
||||||
return Playlist(user, e_id, self)
|
return Playlist(user, e_id, self)
|
||||||
|
|
||||||
|
def get_top_artists(self, limit=None):
|
||||||
|
"""Returns a sequence of the most played artists."""
|
||||||
|
|
||||||
|
doc = _Request(self, "chart.getTopArtists").execute(True)
|
||||||
|
seq = []
|
||||||
|
for node in doc.getElementsByTagName("artist"):
|
||||||
|
title = _extract(node, "name")
|
||||||
|
artist = Artist(title, self)
|
||||||
|
seq.append(artist)
|
||||||
|
|
||||||
|
if limit:
|
||||||
|
seq = seq[:limit]
|
||||||
|
|
||||||
|
return seq
|
||||||
|
|
||||||
|
def get_top_tracks(self, limit=None):
|
||||||
|
"""Returns a sequence of the most played tracks."""
|
||||||
|
|
||||||
|
doc = _Request(self, "chart.getTopTracks").execute(True)
|
||||||
|
seq = []
|
||||||
|
for node in doc.getElementsByTagName("track"):
|
||||||
|
title = _extract(node, "name")
|
||||||
|
artist = _extract(node, "name", 1)
|
||||||
|
track = Track(artist, title, self)
|
||||||
|
seq.append(track)
|
||||||
|
|
||||||
|
if limit:
|
||||||
|
seq = seq[:limit]
|
||||||
|
|
||||||
|
return seq
|
||||||
|
|
||||||
def get_top_tags(self, limit=None):
|
def get_top_tags(self, limit=None):
|
||||||
"""Returns a sequence of the most used tags as a sequence of TopItem objects."""
|
"""Returns a sequence of the most used tags as a sequence of TopItem objects."""
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue