From 6decde66b9ffb2041dc15559d8e5028b7a6df2c5 Mon Sep 17 00:00:00 2001 From: Andrew Beveridge Date: Wed, 4 Nov 2026 10:55:55 -0500 Subject: [PATCH] infra: give audio-download-job the Tornado key That job does most YouTube downloads, and it gets its secrets from Pulumi rather than CI's API deploy. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012RYLVTvqXyL4QyA2EjzQMG --- docs/ARCHITECTURE.md | 2 +- infrastructure/modules/cloud_run.py | 12 ++++++++++++ pyproject.toml | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 0d8697b7..68d49169 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -705,7 +705,7 @@ Audio can come from file upload or remote search (YouTube, torrents). All YouTub 2026-09-26; the backend and `audio-download-job` / `bulk-search-job` have no VPC egress, so every dependency they call must be reachable on a public address. - `FLACFETCH_API_KEY` - API key for authentication -- `TORNADO_API_KEY` - TornadoAPI key (secret `tornado-api-key`). When set, YouTube downloads and availability checks try Tornado first and fall back to flacfetch: WARNING per failed download, ERROR if the account is rejected. CI wires the secret once it has a version. It covers downloads only, so YouTube search still uses flacfetch's cookies. +- `TORNADO_API_KEY` - TornadoAPI key (secret `tornado-api-key`). When set, YouTube downloads and availability checks try Tornado first and fall back to flacfetch: WARNING per failed download, ERROR if the account is rejected. The secret was created by hand (not in `secrets.py`). CI wires it on the API service once it has a version; Pulumi wires it on `audio-download-job`, which does most YouTube downloads. It covers downloads only, so YouTube search still uses flacfetch's cookies. - `YOUTUBE_DOWNLOAD_PROVIDER` - set to `flacfetch` to switch Tornado off, e.g. `gcloud run services update karaoke-backend --update-env-vars YOUTUBE_DOWNLOAD_PROVIDER=flacfetch` (default `tornado`; the next CI deploy resets it, so also change the workflow to make it permanent). ## Worker Execution diff --git a/infrastructure/modules/cloud_run.py b/infrastructure/modules/cloud_run.py index 9162d6e9..a812dd67 100644 --- a/infrastructure/modules/cloud_run.py +++ b/infrastructure/modules/cloud_run.py @@ -516,6 +516,18 @@ def create_audio_download_job( ), ), ), + # TornadoAPI key: YouTube downloads try Tornado first, flacfetch is + # the fallback (backend/services/youtube_download_service.py). This job + # does most YouTube downloads; CI wires the same secret on the API service. + cloudrunv2.JobTemplateTemplateContainerEnvArgs( + name="TORNADO_API_KEY", + value_source=cloudrunv2.JobTemplateTemplateContainerEnvValueSourceArgs( + secret_key_ref=cloudrunv2.JobTemplateTemplateContainerEnvValueSourceSecretKeyRefArgs( + secret=f"projects/{PROJECT_ID}/secrets/tornado-api-key", + version="latest", + ), + ), + ), # Flacfetch API URL (public HTTPS endpoint; no VPC egress) cloudrunv2.JobTemplateTemplateContainerEnvArgs( name="FLACFETCH_API_URL", diff --git a/pyproject.toml b/pyproject.toml index 1552119a..9ed0c60a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "karaoke-gen" -version = "0.291.0" +version = "0.291.1" description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens." authors = ["Andrew Beveridge "] license = "MIT"