HellZEras / SpotifyWaybar

A Spotify Script for Waybar that allows full control through ctlplayer and updates fast(check the end of .jsonc)
1 stars 0 forks source link

Songs with "&" don't work #1

Open KaptenLada opened 3 months ago

KaptenLada commented 3 months ago

Hey Songs with "&" doesn't work, managed to fix it with chatgpt tho XD. here is the explanation:

Chatgpt: "One common reason for this issue is that the & symbol has a special meaning in certain contexts, particularly in HTML or some other markup languages where it represents the start of an HTML entity. To ensure that it displays correctly, you might need to escape it properly before displaying it.

You can do this by replacing & with & in your output string before displaying it. Here's how you can modify your get_current_song function to include this:"

`def get_current_song(sp): try: current_song = sp.currently_playing() song_name = current_song['item']['name'] song_artist = current_song['item']['artists'][0]['name']

Replace '&' with '&'

    song_name = song_name.replace('&', '&')
    song_artist = song_artist.replace('&', '&')
    return "🎵 {} by {}".format(song_name, song_artist)
except Exception:
    return "Spotify Online"

`

this modification worked perfectly for me

HellZEras commented 3 months ago

Appreciate u bro, didnt pay much attention <3