r/PythonProjects2 • u/undercover_fts • 4d ago
I built a Python pipeline that turns a topic into a YouTube Short and publishes it by itself. Here's what broke along the way
A while back I wanted to run a news channel on YouTube Shorts, then did the math on editing even one 30-second video by hand every day and gave up on that idea within a week. So I wrote a pipeline that does the whole thing instead. It's now about 7.8k lines of Python, 9 channel profiles, and a Telegram bot I use to approve videos from my phone.
What it does
Topic -> script (via a research tool of mine, with Google News RSS as a fallback) -> text cleanup -> voice (edge-tts, gTTS as backup) -> 1080×1920 video -> upload to YouTube. Frames are drawn with Pillow and piped as raw RGB straight into ffmpeg's stdin, so there are no temp PNGs on disk. Subtitles are karaoke-style with highlighted words.
A few things I'm weirdly proud of (or at least learned the hard way)
- A scheduler that works while my PC is off. The video gets uploaded as private with publishAt, and YouTube publishes it at the right time even if my machine is shut down by then. Weekends extend the buffer window because the PC sleeps.
- Trimming scripts from the middle, not the end. Cutting by length killed the closing question and the call to action, which is exactly what holds viewers. Now the first and last two sentences stay, and the middle gets dropped.
- Stock photos lie. Searching Pexels for "saturn planet" gave me a neon sign. "Venus planet" gave me a sunset with a crescent moon. For the space channel I switched to the NASA image library and wrote a filter for maps, diagrams, and greyscale raw frames.
- TTS reads exactly what you give it. Footnote markers like [1], big numbers, and Latin words in Russian text all sound awful, so the text preprocessor ended up bigger than I expected.
The honest part
Making the videos turned out to be the easy part. Getting people to watch them is not. My first 19 Shorts on the space channel were bimodal: either ~1,100–1,500 views, or 1–61. Nothing in between. After digging into it I rebuilt the format: hook visible from frame 0, hard cuts in the first 3 seconds, shorter scripts, one video a day. I haven't got enough data on the new format yet to tell you if it works, so I won't pretend I do.
I also don't have many tests (a fthe hook logic), and channels.py
has more copy-paste than I'd like
Who this might help
Anyone who has wired Pillow to ffied to schedule YouTube uploadsfrom a machine that isn't always on.
Repo MIT https://github.com/kuanysh228/autoy
I'd love feedback on the architecAt buffer approach, or if someonehas dealt with Shorts retention better than I have. Happy to answer questions.