Merge pull request #5088 from cogwheel/cogwheel/fix-untitled

custom_modules: Fix mediaplayer.py handling untitled track
This commit is contained in:
Alexis Rouillard
2026-07-03 21:39:13 +02:00
committed by GitHub
+6 -4
View File
@@ -105,24 +105,26 @@ class PlayerManager:
current_player = self.get_first_playing_player()
if current_player is not None:
self.on_metadata_changed(current_player, current_player.props.metadata)
else:
else:
self.clear_output()
def on_metadata_changed(self, player, metadata, _=None):
logger.debug(f"Metadata changed for player {player.props.player_name}")
player_name = player.props.player_name
artist = player.get_artist()
artist = artist.replace("&", "&")
artist = artist and artist.replace("&", "&")
title = player.get_title()
title = title.replace("&", "&")
title = title and title.replace("&", "&")
track_info = ""
if player_name == "spotify" and "mpris:trackid" in metadata.keys() and ":ad:" in player.props.metadata["mpris:trackid"]:
track_info = "Advertisement"
elif artist is not None and title is not None:
track_info = f"{artist} - {title}"
else:
elif title is not None:
track_info = title
elif artist is not None:
track_info = artist
if track_info:
if player.props.status == "Playing":