From 11d955dd89d1597110bf6752016682451b267541 Mon Sep 17 00:00:00 2001 From: kvanzuijlen Date: Sun, 12 Jul 2020 12:21:40 +0200 Subject: [PATCH] Now playing shouldn't count as a recently played track --- src/pylast/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pylast/__init__.py b/src/pylast/__init__.py index f3a61f6..938cc7b 100644 --- a/src/pylast/__init__.py +++ b/src/pylast/__init__.py @@ -2385,6 +2385,7 @@ class User(_BaseObject, _Chartable): if time_to: params["to"] = time_to + track_count = 0 for track_node in _collect_nodes( limit + 1 if limit else None, self, @@ -2396,7 +2397,10 @@ class User(_BaseObject, _Chartable): if track_node.hasAttribute("nowplaying"): continue # to prevent the now playing track from sneaking in + if limit and track_count >= limit: + break yield self._extract_played_track(track_node=track_node) + track_count += 1 return _get_recent_tracks() if stream else list(_get_recent_tracks())