fix stuff lol

This commit is contained in:
xenia 2022-09-06 01:56:47 -04:00
parent 85e9caccb0
commit 7614c05b64
1 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,8 @@
from pydbus import SessionBus from pydbus import SessionBus
import sys import sys
import urllib.parse
import os.path
bus = SessionBus() bus = SessionBus()
all_names = bus.get("org.freedesktop.DBus", "/org/freedesktop/DBus").ListNames() 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") metadata = mpris.Get("org.mpris.MediaPlayer2.Player", "Metadata")
if status == "Playing": if status == "Playing":
title = metadata.get("xesam:title", None) 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) artist = metadata.get("xesam:artist", None)
if artist is None: if artist is None:
artist = metadata.get("xesam:albumArtist", None) artist = metadata.get("xesam:albumArtist", None)
@ -27,7 +37,7 @@ for name in all_names:
artist = None artist = None
if len(title.strip()) == 0: if len(title.strip()) == 0:
title = None title = None
if len(album.strip()) == 0: if album is not None and len(album.strip()) == 0:
album = None album = None
if artist is not None: if artist is not None: