From 0d4c226da100d842813df829a30574f9a83b70e4 Mon Sep 17 00:00:00 2001 From: John Alberts Date: Wed, 1 May 2024 16:07:43 -0500 Subject: [PATCH 1/2] Check now_playing type to see if no track is currently playing --- np.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/np.py b/np.py index 5b09d02..546ab15 100755 --- a/np.py +++ b/np.py @@ -80,9 +80,13 @@ def main() -> None: if not args.loop: now_playing = lastfm_network.get_user(args.username).get_now_playing() - output(is_track_loved(now_playing)) - if args.say: - say(now_playing) + if type(now_playing) is pylast.Track: + output(is_track_loved(now_playing)) + if args.say: + say(now_playing) + else: + output("No track currently playing") + else: last_played = None while True: From b5251c8fa226a273416b6bef32c942c5a40c3635 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Thu, 2 May 2024 17:16:45 +0300 Subject: [PATCH 2/2] Return early if no track --- np.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/np.py b/np.py index 546ab15..0a3fc10 100755 --- a/np.py +++ b/np.py @@ -80,13 +80,9 @@ def main() -> None: if not args.loop: now_playing = lastfm_network.get_user(args.username).get_now_playing() - if type(now_playing) is pylast.Track: - output(is_track_loved(now_playing)) - if args.say: - say(now_playing) - else: - output("No track currently playing") - + if not now_playing: + return + output(is_track_loved(now_playing)) else: last_played = None while True: