mpris-status: Escape artist, album, and title metadata

This commit is contained in:
Adam Goldsmith 2023-06-07 17:37:27 -04:00
parent 674fd01d5c
commit 1ede31280f

View File

@ -2,6 +2,7 @@
from textwrap import shorten
from typing import Optional
from xml.sax.saxutils import escape
from dbus.exceptions import DBusException
from mpris2 import Player, get_players_uri
@ -53,9 +54,9 @@ def format_player(player: Player, short: bool = False) -> str:
"Stopped": "⏹️",
}.get(player.PlaybackStatus, "") + " "
artist = ",".join(metadata.artist)
album = metadata.album
title = metadata.title
artist = escape(",".join(metadata.artist))
album = escape(metadata.album)
title = escape(metadata.title)
if short:
# TODO: could be a bit more clever here to use the whole space
artist = shorten(artist, 40, placeholder="")