From 7614c05b64669dee13ea9a450166ed156c2bd6ed Mon Sep 17 00:00:00 2001 From: haskal Date: Tue, 6 Sep 2022 01:56:47 -0400 Subject: [PATCH] fix stuff lol --- np.10s.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/np.10s.py b/np.10s.py index be02287..e506324 100755 --- a/np.10s.py +++ b/np.10s.py @@ -2,6 +2,8 @@ from pydbus import SessionBus import sys +import urllib.parse +import os.path bus = SessionBus() all_names = bus.get("org.freedesktop.DBus", "/org/freedesktop/DBus").ListNames() @@ -17,6 +19,14 @@ for name in all_names: metadata = mpris.Get("org.mpris.MediaPlayer2.Player", "Metadata") if status == "Playing": title = metadata.get("xesam:title", None) + if title is None: + url = metadata.get("xesam:url", None) + if url is None: + continue + url = urllib.parse.urlparse(url) + path = url.path + title = os.path.basename(path) + title = os.path.splitext(title)[0] artist = metadata.get("xesam:artist", None) if artist is None: artist = metadata.get("xesam:albumArtist", None) @@ -27,7 +37,7 @@ for name in all_names: artist = None if len(title.strip()) == 0: title = None - if len(album.strip()) == 0: + if album is not None and len(album.strip()) == 0: album = None if artist is not None: