debugModerate
YouTube thumbnail backfill from video IDs when yt-dlp fast mode skips thumbnails
Viewed 0 times
thumbnail_url NULLyoutube thumbnail patterni.ytimg.comhqdefaultmaxresdefaultfast_mode thumbnailsbulk update thumbnails
Error Messages
Problem
After bulk syncing YouTube interviews using yt-dlp in fast_mode, all thumbnail_url fields are NULL in the database. Feed cards show placeholder icons instead of video thumbnails because the frontend checks for thumbnail_url before rendering images.
Solution
YouTube thumbnails follow a predictable URL pattern based on video ID. Backfill all missing thumbnails with a single SQL UPDATE:
UPDATE interviews SET thumbnail_url = 'https://i.ytimg.com/vi/' || youtube_id || '/hqdefault.jpg', thumbnail_high_url = 'https://i.ytimg.com/vi/' || youtube_id || '/maxresdefault.jpg' WHERE youtube_id IS NOT NULL AND thumbnail_url IS NULL; This works for all YouTube videos. hqdefault.jpg is 480x360 and always available. maxresdefault.jpg is 1280x720 but may 404 for older videos. Remember to flush Redis cache after the update if feed responses are cached.Why
yt-dlp fast mode (search-only, no detail fetch) returns video ID, title, and view count but skips thumbnail URLs. The thumbnail URL is not included in search results because it requires a separate detail API call. However, YouTube uses a deterministic URL scheme for thumbnails based on video ID, making backfill trivial.
Gotchas
- maxresdefault.jpg may 404 for older or lower-quality videos - hqdefault.jpg is always available
- Must flush Redis cache after update or stale cached responses will still show no thumbnails
- next.config.js must have i.ytimg.com in remotePatterns for Next.js Image component to load them
Revisions (0)
No revisions yet.