From 85e9caccb0b266c9d961a35f29854c0918fe3c5f Mon Sep 17 00:00:00 2001 From: haskal Date: Sat, 26 Jun 2021 00:33:54 -0400 Subject: [PATCH] encode --- np.10s.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/np.10s.py b/np.10s.py index 6841c7f..be02287 100755 --- a/np.10s.py +++ b/np.10s.py @@ -6,6 +6,10 @@ import sys bus = SessionBus() all_names = bus.get("org.freedesktop.DBus", "/org/freedesktop/DBus").ListNames() +def writepart(s): + sys.stdout.write(s.replace("&", "&").replace("<", "<").replace(">", ">") + .replace("|", "|")) + for name in all_names: if name.startswith("org.mpris.MediaPlayer2."): mpris = bus.get(name, "/org/mpris/MediaPlayer2") @@ -27,15 +31,15 @@ for name in all_names: album = None if artist is not None: - sys.stdout.write(artist) + writepart(artist) if title is not None: if artist is not None: sys.stdout.write(" - ") - sys.stdout.write(title) + writepart(title) if album is not None: if artist is not None or title is not None: sys.stdout.write(" / ") - sys.stdout.write(album) + writepart(album) if artist is not None or album is not None or title is not None: sys.stdout.write(" | iconName=multimedia-audio-player-symbolic\n")