Skip to content

Resolver & Sources

The resolver converts high-level page or platform URLs into direct playable media files (usually M4A or MP3) and stores them temporarily on disk.

Supported Platforms

PlatformMechanismNotes
YouTube / youtu.beyt-dlp download using chosen format codeFalls back to a broader format expression if preferred fails.
SoundCloudyt-dlp MP3 extraction or direct URL fetch (-g)Multiple strategies before error.
SpotifySpotify Web API (track metadata) + YouTube search via yt-dlpRequires credentials. Title fallback heuristics.

Flow

  1. Incoming URI checked with needs_resolve() (hostname pattern match)
  2. If resolver disabled: URI must already be a direct HTTP/file path
  3. If enabled: platform-specific logic attempts a direct download / search / extraction
  4. Temporary file path returned; decoding uses local path

Format Selection

preferred_format (default 140) is passed to yt-dlp -f. If that fails, a best-audio fallback is attempted: bestaudio[ext=m4a]/bestaudio/best.

Spotify Resolution

Two layers:

  1. Track ID extraction (URL path segments or spotify:track:<id> URI form). If credentials set, fetch metadata and form a ytsearch1:"Artist - Title" query.
  2. If metadata fetch fails and allow_spotify_title_search enabled: use yt-dlp -e (title) then search.

Caching Strategy

Currently: per-resolution temporary file (OS temp dir) without reuse. Future work aims to implement a LRU cache.

Source Allow/Block

Before resolving or accepting direct URIs, is_uri_allowed() enforces configured regex lists. Block patterns always override allow matches.

Operational Considerations

  • Resolver increases first-play latency (download+transcode)
  • Hosting requires adequate disk IO for temporary files
  • Observe logs for warnings (e.g., missing Spotify credentials on Spotify link)

Failure Modes

ConditionOutcome
Unsupported site400/Failure to create player
Resolver timeoutAbort with error (download canceled)
Missing Spotify credentials400 for Spotify URL when required
yt-dlp/ffmpeg absent & cannot auto-downloadStartup dependency check failure

Released under the BSD-3-Clause License.