Skip to content

Add UPnP album art fallback#127

Open
MagicMicky wants to merge 1 commit into
Velleman:mainfrom
MagicMicky:upnp-metadata-fallback
Open

Add UPnP album art fallback#127
MagicMicky wants to merge 1 commit into
Velleman:mainfrom
MagicMicky:upnp-metadata-fallback

Conversation

@MagicMicky

Copy link
Copy Markdown

What this does

Many LinkPlay devices don't expose album art through the HTTP API. On these
devices getMetaInfo returns unknown command and getPlayerStatus(Ex) has
no art field, so player.album_art is always empty and downstream consumers
(e.g. the Home Assistant integration) show no cover.

The art is available through the device's UPnP AVTransport service. This adds a
fallback: when album_art is empty after the normal HTTP update, it queries
AVTransport.GetMediaInfo and reads albumArtURI from the returned DIDL-Lite
metadata, storing it in the existing metainfo structure so album_art keeps
working unchanged.

Details

  • New linkplay/upnp.py with a small LinkPlayUPnP helper built on
    async_upnp_client (already an install dependency). The UpnpDevice is
    created once and reused.
  • The trigger is manufacturer-agnostic: it fires whenever album art is missing,
    so it also helps WiiM devices that occasionally omit it, rather than
    hard-coding a WiiM / non-WiiM split.
  • The DIDL is parsed with defusedxml (added to install_requires) to avoid
    XXE and entity-expansion attacks on the device response.
  • Non-URL placeholders (devices report un_known when nothing is playing or on
    followers) are validated away to None.
  • Adds host and session accessors on LinkPlayApiEndpoint for the UPnP
    client.

Testing

  • New tests/linkplay/test_upnp.py covers DIDL parsing (a real Spotify
    albumArtURI, the un_known placeholder, and malformed input) and the
    GetMediaInfo paths.
  • New bridge tests assert album art is fetched via UPnP when missing and that
    UPnP is skipped when the HTTP API already provides it.
  • ruff, mypy and the full test suite pass.

Verified against real hardware: Arylic Up2Stream Pro V4 and Audio Pro C10, both
playing Spotify, where the Spotify cover URL is exposed via albumArtURI.

Scope

Relates to #68. This intentionally does not close it: using UPnP as a full
replacement for devices that don't support getPlayerStatusEx at all (transport
state, position, volume via RenderingControl) is a larger change. The
properties dict would be empty and the numeric and enum accessors (int(""),
LoopMode("")) would raise, so it needs seeded defaults and additional UPnP
actions. That is left as a follow-up. This builds on the exploration in the
draft #102 by @silamon.

Many LinkPlay devices (e.g. Arylic and Audio Pro models) do not expose
album art through the HTTP API; the art is only available through the
device's UPnP AVTransport service. When getPlayerStatusEx does not provide
album art, fall back to UPnP GetMediaInfo and read the albumArtURI, keeping
the value in the existing metainfo structure so album_art works unchanged.

The fallback is manufacturer-agnostic: it triggers whenever album art is
missing, which also helps WiiM devices that occasionally omit it. Non-URL
placeholders (e.g. "un_known") are discarded.

Relates to Velleman#68. UPnP as a full replacement for devices without
getPlayerStatusEx (including transport state and volume) is left as a
follow-up. Builds on the exploration in the draft Velleman#102.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant