ViralFlow: an AI pipeline that turns a trending topic into a published YouTube Short

November 10, 2026

Live demo: viralflow.nomannazir.com · Source: github.com/Nomannazir/viral-flow

The problem

Short-form video channels need a steady stream of new content. Doing it by hand means researching topics, writing scripts, finding footage, recording narration, editing and uploading every single video. I wanted to see how much of that an AI pipeline could do reliably on its own, every day, on a small budget.

What I built

A Python pipeline with seven stages. Each stage is its own module, so any one of them (the LLM, the image model, the voice provider, the upload target) can be swapped without touching the rest.

  1. Trends: pulls topics from YouTube Shorts and Reddit, with an evergreen fallback list.
  2. Score: Claude Haiku rates each topic 1–10 for viral potential.
  3. Storyboard: Claude writes a strict JSON storyboard: hook, steps, on-screen text, visual keywords, image prompts, voiceover lines and call to action.
  4. Visuals: FLUX generates the hook and reveal images; Pexels supplies a real stock clip for each step.
  5. Voice: ElevenLabs or Kokoro TTS narrates the script.
  6. Assemble: FFmpeg and Pillow trim clips, burn in text overlays, mix audio and render a 1080×1920 Short.
  7. Publish: uploads to YouTube with title, description and thumbnail through OAuth.

Engineering decisions

  • Cost-aware model routing. Topics scoring 8+ get Claude Sonnet and ElevenLabs. Everything else uses Claude Haiku and Kokoro. Premium spend goes only to the topics most likely to perform.
  • Graceful degradation. If thumbnail generation fails, the pipeline reuses the "after" image. If voiceover fails, the video ships with music only. If one topic fails, it's logged and the run moves on to the next.
  • No duplicate content. Every produced topic is recorded and filtered out of future runs, so a daily schedule never publishes the same idea twice.
  • Cheap to test. --dry-run prints storyboards without spending on media, --no-publish builds the video without uploading, and --topic skips trend discovery.
  • Optional persistence. With Supabase configured, each video's topic, score, title, status and YouTube URL is stored for analytics. Without it, everything still runs from local files.

Stack

Python · Claude API (Sonnet + Haiku) · FLUX via fal.ai · Pexels API · ElevenLabs / Kokoro TTS · FFmpeg · Pillow · YouTube Data API · Reddit API · Supabase

What this means for your project

The same pattern (an LLM making decisions, deterministic code doing the heavy lifting, and fallbacks at every step) works for any content or data automation: reports, product descriptions, social posts, document processing.

LinkedIn
GitHub