Respect get_recent_tracks' limit when there's a now playing track (#310)
Respect get_recent_tracks' limit when there's a now playing track
This commit is contained in:
commit
695a11a4cd
|
@ -2381,7 +2381,7 @@ class User(_BaseObject, _Chartable):
|
||||||
|
|
||||||
params = self._get_params()
|
params = self._get_params()
|
||||||
if limit:
|
if limit:
|
||||||
params["limit"] = limit
|
params["limit"] = limit + 1 # in case we remove the now playing track
|
||||||
if time_from:
|
if time_from:
|
||||||
params["from"] = time_from
|
params["from"] = time_from
|
||||||
if time_to:
|
if time_to:
|
||||||
|
@ -2389,7 +2389,7 @@ class User(_BaseObject, _Chartable):
|
||||||
|
|
||||||
seq = []
|
seq = []
|
||||||
for track in _collect_nodes(
|
for track in _collect_nodes(
|
||||||
limit, self, self.ws_prefix + ".getRecentTracks", cacheable, params
|
limit + 1, self, self.ws_prefix + ".getRecentTracks", cacheable, params
|
||||||
):
|
):
|
||||||
|
|
||||||
if track.hasAttribute("nowplaying"):
|
if track.hasAttribute("nowplaying"):
|
||||||
|
@ -2405,7 +2405,8 @@ class User(_BaseObject, _Chartable):
|
||||||
PlayedTrack(Track(artist, title, self.network), album, date, timestamp)
|
PlayedTrack(Track(artist, title, self.network), album, date, timestamp)
|
||||||
)
|
)
|
||||||
|
|
||||||
return seq
|
# Slice, in case we didn't remove a now playing track
|
||||||
|
return seq[:limit]
|
||||||
|
|
||||||
def get_country(self):
|
def get_country(self):
|
||||||
"""Returns the name of the country of the user."""
|
"""Returns the name of the country of the user."""
|
||||||
|
|
Loading…
Reference in a new issue