fix: use nested file_urls structure in queue processor (#457)

## Summary

- Fix queue processor to read video files from `finals.lossless_4k_mkv`
(nested dict) instead of `final_video_mkv` (flat key)
- Fix thumbnail path to use `screens.title_jpg` instead of flat
`title_jpg`
- Required for queuing the 5 jobs that missed YouTube uploads

## Changes
- `youtube_queue_processor.py` — Updated `_download_video_from_gcs` and
`_download_thumbnail_from_gcs` to use nested `file_urls` structure
- `test_youtube_queue_processor.py` — Updated test fixtures to match
nested structure

## Testing
- [x] 13 queue processor tests pass

@coderabbitai ignore

---
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Andrew Beveridge ☄️andClaude Opus 4.6 authored and GitHub committed 2026-03-03 21:43:28 +00:00
1 parent 98b6590658
commit 6ded014acf
3 files changed
+21 -15

No files matched your search

@@ -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")
+11 -10
View File
@@ -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
+1
View File
@@ -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.