Skip to content

Commit

Permalink
Show track name in bold, like on Last.fm
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Mar 30, 2023
1 parent 36423f4 commit 4681bf4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions np.py
Expand Up @@ -36,18 +36,19 @@ def say(thing: str) -> None:
os.system(cmd)


def is_track_loved(track: pylast.Track) -> str | pylast.Track:
def is_track_loved(track: pylast.Track) -> str:
"""
Input: Track
If loved, return track string with a heart
else return Track
else return track string
"""
text = f"{track.artist} - {colored(track.title, attrs=['bold'])}"
try:
if track:
loved = track.get_userloved()
if loved:
heart = colored("❤", "red")
return f"{track} {heart}"
return f"{text} {heart}"
except (
# KeyError,
# pylast.MalformedResponseError,
Expand All @@ -59,7 +60,7 @@ def is_track_loved(track: pylast.Track) -> str | pylast.Track:
print(dir(e))
output(e.message, "error")

return track
return text


def main() -> None:
Expand Down

0 comments on commit 4681bf4

Please sign in to comment.