Skip to content

Fix Yandex Station credential borrowing and stream playback - #5605

Open
trudenboy wants to merge 5 commits into
music-assistant:devfrom
trudenboy:upstream/yandex_station
Open

Fix Yandex Station credential borrowing and stream playback#5605
trudenboy wants to merge 5 commits into
music-assistant:devfrom
trudenboy:upstream/yandex_station

Conversation

@trudenboy

@trudenboy trudenboy commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

What does this implement/fix?

Synchronizes the Yandex Station provider from v1.5.6 to v1.5.6 and fixes two
regressions affecting current Music Assistant and Yandex Station installations.

Authentication borrowing

  • Reads linked Yandex Music credentials from guided setup data, while retaining
    the legacy provider-config fallback.
  • Waits briefly when the linked Yandex Music provider has not finished loading,
    avoiding a startup-order race that previously left the Station provider
    unavailable.
  • Updates the shared authentication dependency to
    ya-passport-auth[ma]==1.8.0.

Stream playback on current Station firmware

  • Detects the advertised audio_client capability and sends audio_play with
    track/HLS metadata on current firmware.
  • Retains radio_play as a fallback for older firmware.
  • Uses the matching pause/stop behavior for each playback mode and consumes
    progress reported by audio_play.
  • Attributes Glagol state transitions to the requested track, so stale state
    from the previous source cannot turn a normal track handoff into a reported
    physical pause.
  • Uses the same firmware-aware stream command for announcements and preserves
    compatibility with cores that do not expose the announcement-duration
    resolver.

The PR also includes the corresponding authentication, setup-flow,
announcement, protobuf, player-state, and project-consistency tests, plus a
small return-type normalization for generated QR data URIs.

Source provider: trudenboy/ma-provider-yandex-station, version 1.5.6

Related issue (if applicable):

  • N/A

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • New music/player/metadata/plugin provider — new-provider
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — documentation
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Checklist

  • The code change is tested and works locally.
  • pre-commit run --all-files passes.
  • pytest passes, and tests have been added/updated under tests/ where applicable.
  • For changes to shared models, the companion PR in music-assistant/models is linked.
  • For changes affecting the UI, the companion PR in music-assistant/frontend is linked.
  • I have read and complied with the project's AI Policy for any AI-assisted contributions.

Co-authored-by: Administrator <admin@example.com>
Co-authored-by: marcelveldt <marcelveldt@users.noreply.github.com>
@trudenboy trudenboy changed the title Update Yandex Station provider to v1.5.5 Fix Yandex Station credential borrowing and stream playback Aug 12, 2026
@trudenboy
trudenboy marked this pull request as ready for review August 12, 2026 07:25
@MarvinSchenkel
MarvinSchenkel requested a balanced review from Copilot August 12, 2026 13:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Yandex Station authentication borrowing and firmware-aware stream playback.

Changes:

  • Reads linked Yandex Music setup credentials with startup retries.
  • Adds audio_play support while retaining legacy radio_play.
  • Expands authentication, playback, announcement, and setup tests.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
music_assistant/providers/yandex_station/VERSION Updates provider version.
music_assistant/providers/yandex_station/borrow.py Adds setup-data credential borrowing.
music_assistant/providers/yandex_station/manifest.json Updates authentication dependency.
music_assistant/providers/yandex_station/player.py Adds firmware-aware playback and state handling.
music_assistant/providers/yandex_station/provider.py Adds borrowed-token startup retries.
music_assistant/providers/yandex_station/setup_flow.py Normalizes QR URI type.
tests/providers/yandex_station/test_announcements.py Tests announcement playback.
tests/providers/yandex_station/test_auth_wrappers.py Tests authentication wrappers.
tests/providers/yandex_station/test_borrow_mode.py Tests borrowing and startup retries.
tests/providers/yandex_station/test_borrow_setup_data.py Tests setup-data account selection.
tests/providers/yandex_station/test_player_state.py Tests playback commands and state transitions.
tests/providers/yandex_station/test_project_consistency.py Checks standalone dependency consistency.
tests/providers/yandex_station/test_protobuf.py Tests stream command payloads.
tests/providers/yandex_station/test_provider_cascade.py Updates cascade test persistence.
tests/providers/yandex_station/test_setup_flow_unit.py Tests interactive setup paths.
tests/providers/yandex_station/test_setup_script.py Tests standalone setup safety.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread music_assistant/providers/yandex_station/VERSION
Copilot AI review requested due to automatic review settings August 17, 2026 09:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.

Suppressed comments (3)

music_assistant/providers/yandex_station/borrow.py:39

  • [CRITICAL] This early return gives legacy config precedence whenever either old token remains, so guided-flow setup data—including rotated or deliberately cleared credentials—is ignored and borrowing can authenticate with stale credentials; retain super().read_tokens() for validation/fallback but prefer owner.get_setup_value() when available.
        music_token, x_token = super().read_tokens()
        if music_token is not None or x_token is not None:
            return music_token, x_token

music_assistant/providers/yandex_station/provider.py:474

  • [PROBLEM] resolve_music_token() also raises ResourceTemporarilyUnavailable for Passport network/rate-limit failures, so this loop can retry an external call 40 times at 250 ms instead of only waiting for provider load; poll the non-networked read_tokens() readiness first, then resolve once so the normal retry/backoff handles Passport outages.
            except ResourceTemporarilyUnavailable:
                if attempt == _BORROW_SOURCE_LOAD_ATTEMPTS - 1:
                    raise
                await asyncio.sleep(_BORROW_SOURCE_LOAD_DELAY)

music_assistant/providers/yandex_station/player.py:1212

  • [PROBLEM] This applies progress even when external_media_matches is False, so the stale old-track update explicitly handled above is exposed as the newly requested track's elapsed position; ignore progress from known-mismatched player state.
            if self._external_audio_client:
                self._attr_elapsed_time = progress
                self._attr_elapsed_time_last_updated = time.time()

@OzGav OzGav added this to the 2.11.0 milestone Aug 19, 2026
Copilot AI review requested due to automatic review settings August 24, 2026 10:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Comment on lines +465 to +474
for attempt in range(_BORROW_SOURCE_LOAD_ATTEMPTS):
try:
music_token = await self._borrow_source.resolve_music_token()
_, x_token = self._borrow_source.read_tokens()
return music_token, x_token
except ResourceTemporarilyUnavailable:
if attempt == _BORROW_SOURCE_LOAD_ATTEMPTS - 1:
raise
await asyncio.sleep(_BORROW_SOURCE_LOAD_DELAY)
raise RuntimeError("Borrowed credential wait exhausted unexpectedly")
Comment on lines +1093 to 1100
elif (
self._external_play_confirmed
and alice_state in ("IDLE", "")
and external_media_matches is not False
):
# Stream was playing, now stopped without voice trigger →
# user pressed physical pause/stop on the speaker.
self._handle_physical_pause()
Comment on lines +1084 to +1088
if self._external_audio_client:
if external_media_matches is True or (
external_media_matches is None and self._external_stop_observed
):
self._external_play_confirmed = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants