# ECP-0025: yt-dlp adapter + bundled runtime

Status: Draft

## Problem / context

We want to paste a YouTube Live (or other supported site) URL into the app and ingest it as a stream. This requires resolving the URL to an HLS playlist or direct stream URL. We also want the app to be self-contained (no external Python install).

## Decision

Ship a bundled yt-dlp runtime inside the Tauri app and expose a Tauri command that resolves a URL to a stream URL via yt-dlp. The resolved URL is then treated like any other ingest source and sent through our ffmpeg-based pipeline.

## Details

### Bundling

- Bundle a Python runtime + `yt-dlp` inside the app resources directory.
- Prefer the bundled runtime at runtime; fallback to a system `yt-dlp` only if explicitly configured.
- Use a `scripts/vendor-yt-dlp.sh` helper to build the bundled environment per platform.

### Tauri integration

- Add a `add_ytdlp_source` command that:
  - Executes `python -m yt_dlp -J --no-playlist <url>`.
  - Selects a suitable HLS URL from the JSON.
  - Creates a `StreamDescriptor` and `StreamSource`.
- The UI provides a URL input in the “Add source” menu.

### Security / policy

- The app only resolves URLs; it does not automate login or cookie handling.
- The resolved URL is treated as untrusted; playback uses existing safeguards.

## Alternatives considered

- External yt-dlp dependency: rejected (not self-contained).
- Browser-based extraction: rejected (too brittle).

## Rollout / teardown plan

1. Add bundling layout and helper script.
2. Add backend command and UI input.
3. Add docs for building the bundled runtime.

Teardown: remove the command and UI input, keep HLS ingest via direct URLs.
