Skip to content

Add Yandex Station player provider#3605

Open
trudenboy wants to merge 81 commits intomusic-assistant:devfrom
trudenboy:upstream/yandex_station
Open

Add Yandex Station player provider#3605
trudenboy wants to merge 81 commits intomusic-assistant:devfrom
trudenboy:upstream/yandex_station

Conversation

@trudenboy
Copy link
Copy Markdown
Contributor

@trudenboy trudenboy commented Apr 7, 2026

Yandex Station Player Provider

Source: trudenboy/ma-provider-yandex-station — synced from v1.4.12.
Adapted from AlexxIT/YandexStation (MIT license).

Play music on Yandex Station smart speakers via the local Glagol WebSocket protocol, with an optional reverse-direction "intercept" mode that redirects native Station playback to another MA player.

Related PRs

Dependencies

  • ya-passport-auth==1.3.0 — Yandex Passport authentication (Device Flow, QR login, cookie login, token refresh, device tokens)

Features

Core

  • Local playback via Glagol WebSocket externalCommandBypass / radio_play
  • Auto-discovery via mDNS (_yandexio._tcp.local.)
  • Cloud discovery fallback via Quasar IoT API + Glagol device_list API
  • Real-time state updates from Glagol WebSocket

Authentication (via ya-passport-auth)

  • Device Flow — short user code on an MA-hosted page, polls Passport until confirmation (yields x_token + music_token + refresh_token for silent auto-refresh)
  • QR code — scan with the Yandex app (yields x_token + music_token)
  • Cookies fallback — advanced option, accepts JSON array or raw cookie string
  • Silent credential refresh cascade: music_token → x_token → refresh_token
  • Optional "Remember session" toggle — disabling immediately drops long-lived tokens

Transport Controls

  • Play / Pause / Stop / Resume
  • Next / Previous track
  • Seek (rewind)
  • Volume set / mute
  • Power on/off via Yandex scenarios

Playback

  • FLAC lossless streaming with Content-Length header
  • Track info display (title, artist, cover, duration)
  • Automatic track transitions on queue advancement
  • Pause via radio_play with unreachable URL (fully local, no cloud)
  • Resume via MA queue replay
  • Detect physical pause during external playback

Announcements

  • Audio announcement via stream URL — blocks until playback ends
  • Volume save/restore around announcements
  • 30s safety timeout

Voice Control (Experimental, off by default)

  • Detect Alice activation during bypass playback
  • Auto-resume after informational queries (weather, etc.)
  • Auto-resume after volume adjustments
  • Stay paused on control commands (стоп, пауза)
  • Accept native playback when Alice starts her own music

Intercept Mode (Experimental, off by default — new in v1.4.0)

Redirects native Station playback to a configured target MA player. When the Station starts native Yandex Music playback (typically via an Alice voice command, but also via a touch on the Station UI), the provider:

  1. Resolves the track via the yandex_music MA music provider.
  2. Stops the Station's native player.
  3. Starts the same track on the chosen target.

Volume / seek / pause / Alice-speech mirror from the Station to the target while intercept is active.

Gated by two switches (both default OFF):

  • Provider-level master toggle (intercept_feature_enabled).
  • Per-player toggle (intercept_enabled) + target dropdown filtered by required features (PLAY_MEDIA, PAUSE, VOLUME_SET, SEEK).

Hardened across four review rounds (PR #45 in source repo) for: serialised dispatch under _intercept_lock, debounced failure paths, target availability pre-validation, self-stop window, seek baseline anchored at play-start, idempotent Alice-pause, and decoupled session/debounce cleanup.


Architecture

MA Core ──play_media()──▶ YandexStationPlayer ──radio_play──▶ Glagol WS ──▶ Yandex Station
                                                                         ◀── state updates
              ◀──intercept handoff── (resolve via yandex_music) ──◀── Alice plays X
Module Purpose
__init__.py setup(), get_config_entries() — Device Flow / QR / cookies auth actions, remember-session toggle, intercept master switch
provider.py mDNS discovery, Quasar API fallback, player lifecycle, silent re-auth cascade
player.py Transport controls, state updates, play_media() via radio_play, announcements, voice-control, intercept dispatch and mirroring
glagol.py Persistent WebSocket client, auto-reconnect, command send/receive
quasar.py Cloud API for device list and config
session.py HTTP client with cookie persistence, delegates auth to injected PassportClient
auth.py Device Flow / QR / cookies login + refresh_music_token / refresh_credentials_via_passport / validate_x_token
protobuf.py Minimal protobuf encoder/decoder for externalCommandBypass
constants.py API URLs, config keys, protocol constants

Changed files

File Status Lines
music_assistant/providers/yandex_station/__init__.py added +249
music_assistant/providers/yandex_station/auth.py added +437
music_assistant/providers/yandex_station/constants.py added +43
music_assistant/providers/yandex_station/glagol.py added +315
music_assistant/providers/yandex_station/icon.svg added +9
music_assistant/providers/yandex_station/manifest.json added +16
music_assistant/providers/yandex_station/player.py added +925
music_assistant/providers/yandex_station/protobuf.py added +109
music_assistant/providers/yandex_station/provider.py added +568
music_assistant/providers/yandex_station/quasar.py added +101
music_assistant/providers/yandex_station/session.py added +215
tests/providers/yandex_station/__init__.py added +1
tests/providers/yandex_station/test_auth.py added +761
tests/providers/yandex_station/test_intercept.py added +788
tests/providers/yandex_station/test_player_state.py added +146
tests/providers/yandex_station/test_protobuf.py added +23
tests/providers/yandex_station/test_provider_cascade.py added +580

Total: 17 files, +5286 / -0 lines.


Tests (101 total)

  • test_auth.py (40) — Device Flow, QR, cookie login, token refresh, x_token validation, safe-session-id guard
  • test_provider_cascade.py (17) — silent auth cascade (music → x_token → refresh_token), session reuse, transient-failure handling, 401 retry
  • test_player_state.py (5) — physical pause detection, external-playback startup window, voice-interaction guard
  • test_protobuf.py (2) — protobuf encode/decode roundtrip
  • test_intercept.py (37) — intercept feature: track_id parser, both kill switches, missing yandex_music, missing/unavailable target, anti-loop, debounce (success and failure paths), volume/seek/pause mirroring, Alice handling (idempotency, debounce clearing, blocks new handoff in same tick), self-stop window, concurrent ticks serialised, cmd_pause-raise cleanup, dropdown feature filter, real-entrypoint integration through _on_glagol_update

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

🔒 Dependency Security Report

📦 Modified Dependencies

music_assistant/providers/yandex_station/manifest.json

Added:


🔍 Vulnerability Scan Results

No known vulnerabilities found

Name Skip Reason
torch Dependency not found on PyPI and could not be audited: torch (2.11.0+cpu)
torchaudio Dependency not found on PyPI and could not be audited: torchaudio (2.11.0+cpu)
✅ No known vulnerabilities found

Automated Security Checks

  • Vulnerability Scan: Passed - No known vulnerabilities
  • Trusted Sources: All packages have verified source repositories
  • Typosquatting Check: No suspicious package names detected
  • License Compatibility: All licenses are OSI-approved and compatible
  • Supply Chain Risk: Passed - packages appear mature and maintained

Manual Review

Maintainer approval required:

  • I have reviewed the changes above and approve these dependency updates

To approve: Comment /approve-dependencies or manually add the dependencies-reviewed label.

@trudenboy trudenboy changed the title feat(yandex_station): add yandex_station provider v1.0.0 feat(yandex_station): add Yandex Station player provider v1.0.0 Apr 7, 2026
@trudenboy trudenboy changed the title feat(yandex_station): add Yandex Station player provider v1.0.0 add Yandex Station player provider v1.0.0 Apr 7, 2026
@trudenboy trudenboy changed the title add Yandex Station player provider v1.0.0 feat(yandex_station): v1.0.0 — Local Glagol WebSocket playback, QR auth, voice control Apr 7, 2026
@trudenboy trudenboy force-pushed the upstream/yandex_station branch from 57ce2b1 to 5895b4d Compare April 7, 2026 13:33
@trudenboy trudenboy changed the title feat(yandex_station): v1.0.0 — Local Glagol WebSocket playback, QR auth, voice control add Yandex Station Player Provider v1.0.0 — Local Glagol WebSocket playback, QR auth, voice control Apr 7, 2026
@trudenboy trudenboy changed the title add Yandex Station Player Provider v1.0.0 — Local Glagol WebSocket playback, QR auth, voice control feat(yandex_station): add Yandex Station player provider v1.0.0 Apr 7, 2026
@trudenboy trudenboy changed the title feat(yandex_station): add Yandex Station player provider v1.0.0 Add Yandex Station player provider v1.0.0 Apr 7, 2026
@trudenboy trudenboy marked this pull request as ready for review April 7, 2026 13:58
Copilot AI review requested due to automatic review settings April 7, 2026 13:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Yandex Station player provider to Music Assistant, enabling local playback/control on Yandex smart speakers via the Glagol WebSocket protocol, including discovery and authentication flows.

Changes:

  • Introduces the yandex_station player provider (discovery via Quasar + mDNS, local Glagol WebSocket control, queue playback via radio_play bypass).
  • Adds Yandex authentication helpers (QR flow + cookies fallback) and an HTTP session wrapper for token/cookie/CSRF handling.
  • Adds a minimal protobuf wire encoder/decoder plus basic unit tests for protobuf roundtrips.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
music_assistant/providers/yandex_station/init.py Provider setup + config entries (QR/cookies auth actions, token storage).
music_assistant/providers/yandex_station/constants.py Provider constants for config keys and API/WS endpoints.
music_assistant/providers/yandex_station/glagol.py Glagol local WebSocket client (connect/reconnect, command send/receive, updates).
music_assistant/providers/yandex_station/icon.svg Provider icon asset.
music_assistant/providers/yandex_station/manifest.json Provider manifest (player provider metadata + mDNS discovery type).
music_assistant/providers/yandex_station/player.py Player implementation (transport controls, play_media via bypass, state updates, voice-control logic).
music_assistant/providers/yandex_station/protobuf.py Minimal protobuf encode/decode helpers for externalCommandBypass.
music_assistant/providers/yandex_station/provider.py Provider discovery/lifecycle (Quasar discovery + mDNS updates, player creation).
music_assistant/providers/yandex_station/quasar.py Quasar cloud API client for device discovery and config enrichment.
music_assistant/providers/yandex_station/session.py HTTP session wrapper (token refresh, cookie/CSRF management, throttling).
music_assistant/providers/yandex_station/yandex_auth.py QR + cookies authentication flows to obtain x_token/music_token.
tests/providers/yandex_station/init.py Test package marker for provider tests.
tests/providers/yandex_station/test_protobuf.py Unit tests for protobuf dumps/loads behavior.

Comment thread music_assistant/providers/yandex_station/session.py Outdated
Comment thread music_assistant/providers/yandex_station/session.py Outdated
Comment thread music_assistant/providers/yandex_station/provider.py Outdated
Comment thread music_assistant/providers/yandex_station/glagol.py Outdated
Comment thread music_assistant/providers/yandex_station/glagol.py Outdated
Comment thread music_assistant/providers/yandex_station/player.py
Comment thread music_assistant/providers/yandex_station/protobuf.py Outdated
Copilot AI review requested due to automatic review settings April 7, 2026 14:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 12 out of 13 changed files in this pull request and generated 9 comments.

Comment thread music_assistant/providers/yandex_station/session.py
Comment thread music_assistant/providers/yandex_station/session.py
Comment thread music_assistant/providers/yandex_station/glagol.py
Comment thread music_assistant/providers/yandex_station/glagol.py Outdated
Comment thread music_assistant/providers/yandex_station/player.py Outdated
Comment thread music_assistant/providers/yandex_station/provider.py Outdated
Comment thread music_assistant/providers/yandex_station/yandex_auth.py Outdated
Comment thread music_assistant/providers/yandex_station/yandex_auth.py Outdated
Comment thread tests/providers/yandex_station/test_protobuf.py Outdated
Copilot AI review requested due to automatic review settings April 7, 2026 14:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 12 out of 13 changed files in this pull request and generated 3 comments.

Comment thread music_assistant/providers/yandex_station/provider.py
Comment thread music_assistant/providers/yandex_station/provider.py
Comment thread music_assistant/providers/yandex_station/player.py Outdated
Copilot AI review requested due to automatic review settings April 7, 2026 15:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 12 out of 13 changed files in this pull request and generated 3 comments.

Comment thread music_assistant/providers/yandex_station/glagol.py Outdated
Comment thread music_assistant/providers/yandex_station/yandex_auth.py Outdated
Comment thread music_assistant/providers/yandex_station/constants.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 17 changed files in this pull request and generated 1 comment.

Comment thread music_assistant/providers/yandex_station/player.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 17 changed files in this pull request and generated 3 comments.

Comment thread music_assistant/providers/yandex_station/player.py Outdated
Comment thread music_assistant/providers/yandex_station/quasar.py Outdated
Comment thread music_assistant/providers/yandex_station/session.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 17 changed files in this pull request and generated 1 comment.

Comment thread music_assistant/providers/yandex_station/player.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 17 changed files in this pull request and generated 1 comment.

Comment thread music_assistant/providers/yandex_station/glagol.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 17 changed files in this pull request and generated 1 comment.

Comment thread music_assistant/providers/yandex_station/player.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 17 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 17 changed files in this pull request and generated 1 comment.

Comment thread music_assistant/providers/yandex_station/provider.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 17 changed files in this pull request and generated 4 comments.

Comment thread music_assistant/providers/yandex_station/quasar.py
Comment thread music_assistant/providers/yandex_station/quasar.py Outdated
Comment thread music_assistant/providers/yandex_station/quasar.py Outdated
Comment thread music_assistant/providers/yandex_station/player.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 17 changed files in this pull request and generated 4 comments.

Comment thread music_assistant/providers/yandex_station/player.py
Comment thread music_assistant/providers/yandex_station/player.py
Comment thread music_assistant/providers/yandex_station/player.py Outdated
Comment thread music_assistant/providers/yandex_station/player.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 17 out of 18 changed files in this pull request and generated 3 comments.

Comment thread tests/providers/yandex_station/test_quasar.py
Comment thread music_assistant/providers/yandex_station/provider.py
Comment thread music_assistant/providers/yandex_station/provider.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies-reviewed Indication that any added or modified/updated dependencies on a PR have been reviewed new-provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants