Skip to content

Commit

Permalink
mpris module: implement track number support (#2280)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmiont authored Jan 24, 2025
1 parent c2d623a commit 51eb2df
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion py3status/modules/mpris.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
{state} playback status of the player
{time} played time of the song
{title} name of the song
{tracknumber} track number of the song
{nowplaying} now playing field provided by VLC for stream info
Button placeholders:
Expand Down Expand Up @@ -278,6 +279,10 @@ def metadata(self, metadata=None):

self._metadata["length"] = self._get_time_str(metadata.get(Metadata_Map.LENGTH))

# we are converting the attribute name to lowercase because although the spec
# says it's `xesam:trackNumber`, VLC exposes it as `xesam:tracknumber`
self._metadata["tracknumber"] = metadata.get(Metadata_Map.TRACK_NUMBER.lower())

self._metadata["nowplaying"] = metadata.get("vlc:nowplaying", None)

if not self._metadata.get("title"):
Expand Down Expand Up @@ -407,6 +412,7 @@ def post_config_hook(self):
"artist": None,
"length": None,
"title": None,
"tracknumber": None,
"nowplaying": None,
"time": None,
"state": None,
Expand Down Expand Up @@ -477,7 +483,7 @@ def post_config_hook(self):
self._color_inactive = self.py3.COLOR_CONTROL_INACTIVE or self.py3.COLOR_BAD

self._format_contains_metadata = False
self._metadata_keys = ["album", "artist", "title", "nowplaying", "length"]
self._metadata_keys = ["album", "artist", "title", "nowplaying", "length", "tracknumber"]
for key in self._metadata_keys:
if self.py3.format_contains(self.format, key):
self._format_contains_metadata = True
Expand Down

0 comments on commit 51eb2df

Please sign in to comment.