diff --git a/backend/tests/test_youtube_queue_processor.py b/backend/tests/test_youtube_queue_processor.py index 3f0523cd..f93abc27 100644 --- a/backend/tests/test_youtube_queue_processor.py +++ b/backend/tests/test_youtube_queue_processor.py @@ -178,8 +178,10 @@ class TestDownloadVideoFromGCS: mock_job = Mock() mock_job.file_urls = { - "final_video_mkv": "gs://bucket/job/final.mkv", - "final_video": "gs://bucket/job/final.mp4", + "finals": { + "lossless_4k_mkv": "jobs/job-123/finals/lossless_4k_mkv.mkv", + "lossless_4k_mp4": "jobs/job-123/finals/lossless_4k_mp4.mp4", + } } mock_storage = Mock() @@ -191,7 +193,7 @@ class TestDownloadVideoFromGCS: assert result is not None assert result.endswith(".mkv") - mock_storage.download_file.assert_called_once_with("gs://bucket/job/final.mkv", "/tmp/test/video.mkv") + mock_storage.download_file.assert_called_once_with("jobs/job-123/finals/lossless_4k_mkv.mkv", "/tmp/test/video.mkv") def test_falls_back_to_mp4(self): """Should fall back to MP4 when MKV not available.""" @@ -199,7 +201,9 @@ class TestDownloadVideoFromGCS: mock_job = Mock() mock_job.file_urls = { - "final_video": "gs://bucket/job/final.mp4", + "finals": { + "lossless_4k_mp4": "jobs/job-123/finals/lossless_4k_mp4.mp4", + } } mock_storage = Mock() @@ -229,7 +233,7 @@ class TestDownloadVideoFromGCS: from backend.workers.youtube_queue_processor import _download_video_from_gcs mock_job = Mock() - mock_job.file_urls = {"final_video_mkv": "gs://bucket/job/final.mkv"} + mock_job.file_urls = {"finals": {"lossless_4k_mkv": "jobs/job-123/finals/lossless_4k_mkv.mkv"}} mock_storage = Mock() mock_storage.download_file.side_effect = Exception("Download failed") diff --git a/backend/workers/youtube_queue_processor.py b/backend/workers/youtube_queue_processor.py index d3fcb953..120cfc22 100644 --- a/backend/workers/youtube_queue_processor.py +++ b/backend/workers/youtube_queue_processor.py @@ -207,22 +207,22 @@ def _download_video_from_gcs( job_id: str, job, storage: StorageService, temp_dir: str ) -> Optional[str]: """Download the best available video file from GCS.""" - # Check file_urls in job data for GCS paths file_urls = job.file_urls or {} + finals = file_urls.get("finals", {}) if isinstance(file_urls.get("finals"), dict) else {} - # Priority order: MKV (FLAC audio) > lossless MP4 > lossy MP4 + # Priority order: MKV (FLAC audio) > lossless MP4 > lossy 4K MP4 > lossy 720p MP4 candidates = [ - ("final_video_mkv", ".mkv"), - ("final_video", ".mp4"), - ("final_video_lossy", ".mp4"), + (finals.get("lossless_4k_mkv"), "lossless_4k_mkv", ".mkv"), + (finals.get("lossless_4k_mp4"), "lossless_4k_mp4", ".mp4"), + (finals.get("lossy_4k_mp4"), "lossy_4k_mp4", ".mp4"), + (finals.get("lossy_720p_mp4"), "lossy_720p_mp4", ".mp4"), ] - for key, ext in candidates: - gcs_url = file_urls.get(key) - if gcs_url: + for gcs_path, key, ext in candidates: + if gcs_path: local_path = os.path.join(temp_dir, f"video{ext}") try: - storage.download_file(gcs_url, local_path) + storage.download_file(gcs_path, local_path) if os.path.isfile(local_path) and os.path.getsize(local_path) > 0: logger.info(f"Downloaded {key} from GCS for job {job_id}") return local_path @@ -237,7 +237,8 @@ def _download_thumbnail_from_gcs( ) -> Optional[str]: """Download the thumbnail from GCS if available.""" file_urls = job.file_urls or {} - thumbnail_url = file_urls.get("title_jpg") + screens = file_urls.get("screens", {}) if isinstance(file_urls.get("screens"), dict) else {} + thumbnail_url = screens.get("title_jpg") if not thumbnail_url: return None diff --git a/docs/README.md b/docs/README.md index 9f91d558..f1df05ec 100644 --- a/docs/README.md +++ b/docs/README.md @@ -50,6 +50,7 @@ - **Song Lookup Autocomplete & Community Version Detection** (2026-03-03): Added song catalog integration to the job creation flow. Two features: (1) **Track autocomplete** on the title field provides canonical artist/title names from MusicBrainz + Spotify data via the karaoke-decide catalog API, improving text consistency for YouTube releases. Autocomplete activates when the artist field has a value; selecting a suggestion overwrites both artist and title with canonical names. (2) **Community version detection** checks karaokenerds.com for existing high-quality karaoke versions — if found, a dismissible green banner suggests the user check those versions first before spending credits. New backend: 3 endpoints (`/api/catalog/artists`, `/api/catalog/tracks`, `/api/catalog/community-check`) with per-user rate limiting (20 req/min) and in-memory TTL caching. New services: `catalog_proxy_service.py` (proxies to karaoke-decide), `karaokenerds_service.py` (scrapes karaokenerds.com). New frontend components: `AutocompleteInput` (reusable), `CommunityVersionBanner`. See [API.md](API.md#catalog-song-lookup). + - **Feedback-for-Credits** (2026-03-01): Added a feedback-for-credits mechanism available to all users (replaces the old beta-only feedback flow). Users who complete 2+ karaoke videos can submit product feedback (star ratings + text) to earn 2 free credits (total possible free credits: 4 — 2 welcome + 2 feedback). New endpoints: `GET /api/users/feedback/eligibility`, `POST /api/users/feedback`. The `/api/users/me` response includes `feedback_eligible: bool` so the frontend can show/hide prompts without an extra API call. Frontend shows a dismissible banner on the dashboard and a "Earn 2 Free Credits" menu item in the user dropdown when eligible. Feedback stored in `user_feedback` Firestore collection with duplicate prevention via `has_submitted_feedback` flag on user model. Welcome email updated with credit-focused messaging and feedback teaser. See [API.md](API.md#user-feedback-for-credits). - **Remove Beta Program from Homepage** (2026-03-01): Removed beta enrollment from landing page and replaced with prominent "2 Free Credits" messaging. Beta enrollment endpoint preserved for backward compatibility but no longer actively promoted. See PR #430.