Skip to content

Commit

Permalink
Support showing mpris:artUrl if provided
Browse files Browse the repository at this point in the history
Partially implements #19 for players that provide a world-accessible URL
using HTTP(S). Automatic image upload for local files will be
implemented later.
  • Loading branch information
FichteFoll committed May 9, 2023
1 parent 2834993 commit cc11257
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion discordrp_mpris/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,17 @@ async def tick(self) -> None:
activity['state'] = self.format_details("{state}", replacements)

# set icons and hover texts
if player.name in PLAYER_ICONS:
show_art = self.config.player_get(player, 'show_art', True)
if (
show_art
and (art_url := metadata.get("mpris:artUrl"))
and (art_url.startswith("http://") or art_url.startswith("https://"))
):
activity['assets'] = {'large_text': player.name,
'large_image': art_url,
'small_image': state.lower(),
'small_text': state}
elif player.name in PLAYER_ICONS:
activity['assets'] = {'large_text': player.name,
'large_image': PLAYER_ICONS[player.name],
'small_image': state.lower(),
Expand Down
4 changes: 4 additions & 0 deletions discordrp_mpris/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ show_paused = true
show_stopped = false
# Available values are: "elapsed", "remaining" or "none".
show_time = "elapsed"
# Include the embedded album art.
# For now, this requires the art URL to be publicly accessible,
# e.g. for YouTube thumbnails.
show_art = true
# Whether to ignore a player. Supposed to be overridden.
ignore = false
# Maximum number of bytes in the title field
Expand Down

0 comments on commit cc11257

Please sign in to comment.