From 284028bb1fc75058b59491fbc754700f96e8d170 Mon Sep 17 00:00:00 2001 From: Woody Date: Sat, 9 May 2026 15:53:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Phase=203.1=20+=203.2=20=E2=80=94=20You?= =?UTF-8?q?Tube=20config=20infra=20and=20URL=20extraction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 3.1 — Configuration & Infrastructure: - Add youtube_proxy_enabled, yt_dlp_timeout, yt_dlp_cache_ttl config fields - Add yt-dlp and hls.js dependencies - Create models/youtube.py (request/response schemas) - Create service stubs (youtube_service, hls_proxy) - Create router stub and register in main.py - 11 config tests Phase 3.2 — YouTube URL Extraction: - yt-dlp wrapper with async extraction (run_in_executor) - Format selection: ≤480p video-only + highest-bitrate audio (VOD) - Combined format fallback: same URL for live streams - In-memory URL cache: 5min TTL live, 30min VOD - lru_cache singleton service for cache persistence - Error handling: DownloadError → 200 with error field - 18 extract tests, 82/82 total pass (zero regressions) Real-URL verified: VOD (5bF3tkO5jAA) 24 formats, Live (fN9uYWCjQaw) 6 HLS --- .plans/phase3_youtube_proxy_plan.md | 228 +++++---- backend/.env.example | 5 + backend/app/core/config.py | 5 + backend/app/main.py | 3 +- backend/app/models/youtube.py | 28 ++ backend/app/routers/youtube.py | 83 ++++ backend/app/services/hls_proxy.py | 21 + backend/app/services/youtube_service.py | 128 +++++ backend/app/test/test_phase3_config.py | 177 +++++++ .../app/test/test_phase3_youtube_extract.py | 446 ++++++++++++++++++ backend/requirements.txt | 1 + frontend/package.json | 1 + 12 files changed, 1036 insertions(+), 90 deletions(-) create mode 100644 backend/app/models/youtube.py create mode 100644 backend/app/routers/youtube.py create mode 100644 backend/app/services/hls_proxy.py create mode 100644 backend/app/services/youtube_service.py create mode 100644 backend/app/test/test_phase3_config.py create mode 100644 backend/app/test/test_phase3_youtube_extract.py diff --git a/.plans/phase3_youtube_proxy_plan.md b/.plans/phase3_youtube_proxy_plan.md index 81b326f..3b1daed 100644 --- a/.plans/phase3_youtube_proxy_plan.md +++ b/.plans/phase3_youtube_proxy_plan.md @@ -1,15 +1,15 @@ # Phase 3: YouTube Live Stream Proxy → ASR → RAG — Implementation Plan **Created:** 2026-05-09 -**Updated:** 2026-05-09 (user decisions incorporated) -**Status:** Planning +**Updated:** 2026-05-09 (Phase 3.1 + 3.2 implemented) +**Status:** In Progress (3.1 Complete, 3.2 Complete) **Depends on:** Phase 1 (Complete), Phase 2 (Complete) --- ## 1. Overview -Phase 3 adds YouTube live stream (and VOD) playback as an alternative to file upload. User pastes a YouTube URL → backend extracts separate video-only and audio-only HLS streams via yt-dlp → backend proxies HLS manifests and .ts segments (zero re-encoding) → frontend plays video in `