youtube_helper.gui module
YouTube Helper — minimal single-page GUI (“download bench”).
Module summary
This module holds the self-contained HTML document served by the FastAPI app
at GET /gui (see youtube_helper.api). It is deliberately
build-step-free: one string of HTML + Tailwind (via CDN) + vanilla ES-module
JavaScript. There is no bundler, no framework, no npm.
Where the words live
In the markup, in English. Each one is wrapped as {{_("…")}} in the HTML,
or listed in _JS_NAME_TO_SOURCE for the script, and
os_helper.Catalog translates it through the compiled gettext
catalogues under locales/ (CODING.md 21.3).
English is the msgid, so it needs no catalogue and cannot fall out of sync with
one; a string the French catalogue has not caught up with renders as readable
English instead of as a key. The cost is the mirror image: rewording the
English here orphans its French entry, and gettext would quietly serve the
English. tests/test_i18n.py exists to catch that — it hands every source
string to os_helper.Catalog.problems(), so an orphaned translation is a
red build rather than a half-reverted page.
render_gui() resolves a language and returns the finished page.
Why a separate module
Keeping the (long) HTML out of youtube_helper.api keeps the route
definitions readable and mirrors the AI Helpers suite convention. Other repos
copy this file almost verbatim: swap the form fields and the target endpoints,
keep the plumbing.
What the page does
Paste a YouTube (or any yt-dlp-supported) URL — kept client-side until Run.
Choose audio or video, and (for audio) a target sample rate.
POST a JSON request to the SAME FastAPI endpoints the CLI surface uses (
/audio//video) — the GUI adds zero new server logic.Show a progress indicator while the (potentially long) download runs, then a download link and an inline
<audio>/<video>player for the result.
Local-first
Everything runs against the local FastAPI app. youtube-helper fetches only the media the user asks for from the source site; nothing is uploaded to a third party, there is no telemetry and no account.
- youtube_helper.gui.default_language()[source]
The language an unknown or absent
?lang=falls back to.- Return type:
- youtube_helper.gui.render_gui(lang='')[source]
Render the single-page GUI in the requested language.
- Parameters:
lang (str) – Two-letter language code. Anything outside the locale file’s a compiled catalogue — including the empty string — falls back to
meta.default_locale, so an unknown?lang=never 500s.- Returns:
The complete HTML document for that language.
- Return type:
Examples
>>> "<!doctype html>" in render_gui("en") True >>> render_gui("tlh") == render_gui(default_language()) True