Files
karaoke-gen/scripts
Andrew Beveridge ☄️andClaude Opus 5.5 4a23398c04 fix(youtube-backfill): check known video IDs the uploads playlist drops (v0.297.2) (#1269)
## Summary
Andrew got "[YouTube Descriptions] 5 updated, 0 remaining" on
2026-11-14. The cause: the channel's uploads playlist
(`playlistItems.list` on `UU…`) isn't a complete list of the channel.
- Its pages overlap: 1914 items, but 11 are duplicates.
- It leaves out public videos for weeks at a time. Five 2023 This Is Me
Smiling videos were missing for the whole Oct 22 template cycle, so the
backfill reported "complete" while they still had the old description.
They came back on 11-14 and were rewritten.
- `hSPiNfrqf5w` (Alive in the Chase) is still on the pre-10-22 template,
and `QP2lKxkfeqE` is missing from the playlist again right now.

## Changes
- `youtube_backfill.iter_all_video_ids` removes duplicate IDs.
- New `youtube_backfill.enumerate_channel(youtube, known_ids)`: lists
the playlist, then looks up known IDs it left out directly with
`videos.list` (about 1 unit per 50 IDs). Returns `recovered_ids` and
`gone_ids`.
- The worker keeps every ID it has seen in Firestore
`youtube_backfill/known_video_ids`.
- The first run seeds the set from the quota ledger's
`desc-backfill:<id>` entries (1800 IDs on prod, read-only check).
  - If seeding fails, nothing is saved, so the next run retries.
  - Deleted videos are dropped from the set.
  - A dry run saves nothing.
- The run summary and progress email report `recovered_from_known`. A
WARNING log names the IDs the playlist omitted.
- Docs: `scripts/youtube-descriptions/README.md`,
`docs/LESSONS-LEARNED.md`. Version 0.297.2.

## Testing
- `pytest backend/tests -k "youtube_comment or backfill"`: 114 passed.
- New tests cover duplicate removal, recovering videos the playlist
omits, gone IDs, seeding from the ledger, a failed seed being retried,
no saves on a dry run, and the email count.
- Seeding checked against prod Firestore (read-only): 1800 IDs,
including all 5 affected videos and Alive in the Chase.
- The first prod run after deploy should log "uploads playlist omitted N
known videos" and rewrite Alive in the Chase.

Local CodeRabbit: 2 rounds. Fixed 1 major (failed seed was never
retried) and 1 minor (loose test assertion).

@coderabbitai ignore

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

https://claude.ai/code/session_012RYLVVbErmEFhmiW48uuFK

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 14:03:13 -05:00
..
2026-01-05 01:33:17 +00:00