youtube_helper.cli module
YouTube Helper — the command line.
youtube-helper <subcommand>: download a video, its audio track or its
thumbnail, resolve a page URL to a direct ffmpeg-ready media URL, browse or
pick among the stream formats yt-dlp reports, and pull public engagement
metadata (channel, video, comments, subtitles) without any platform API key.
Works on YouTube, Vimeo, DailyMotion, Twitch VOD, SoundCloud, and every other
site yt-dlp supports.
Design notes
One command line, built with
click. There is no second parser: the subcommand names and flag names here are the contract, and the FastAPI surface (youtube_helper.api) mirrors them one-to-one.Flags are named (
--url/--output/ …) rather than positional, so a long download command stays readable and the HTTP surface can reuse the same parameter names.A library exception is caught by the
main()entry point (not click’s own error handling, which only special-casesClickException/Abort) and printed as a cleanError: ...line + exit 1, instead of a raw Python traceback.
Usage Example
>>> # youtube-helper metadata --url https://www.youtube.com/watch?v=YE7VzlLtp-4
>>> # youtube-helper audio --url https://www.youtube.com/watch?v=YE7VzlLtp-4 --output out.mp3
>>> # youtube-helper resolve --url https://www.youtube.com/watch?v=YE7VzlLtp-4 --prefer audio
>>> # youtube-helper channel-info --url https://www.youtube.com/@blender
- youtube_helper.cli.main()[source]
Console entry point (
youtube-helper).click’s own
main()only special-casesClickException/Abort(and a broken pipe); a plain library exception (e.g.AssertionErrorfrom an invalid URL) would otherwise propagate as a raw Python traceback instead of a clean CLI error. This wraps the whole invocation and translates that last case into a one-line stderr message + exit 1 — click’s own control flow (usage errors,--help, an explicitsys.exit(1)in a subcommand) already raisesSystemExit, aBaseExceptionthis does not catch, so it passes through untouched.- Return type:
None