1) Uses textuals CSS_PATH and an external tcss file to bundle all DEFAULT_CSS into one file

2) Added keyboard shortcut bindings for switching the language (Ctrl-T) and showing the help (Ctrl-A) The help should use a markdown viewer
3) Include a test folder containing all the tests
This commit is contained in:
2026-09-19 14:28:40 +02:00
parent 701ff3a6d3
commit fccd2def59
20 changed files with 1118 additions and 107 deletions
+38 -2
View File
@@ -25,12 +25,45 @@ they come as separate streams).
python main.py
```
### Keyboard shortcuts
* **Ctrl+T** — switch language (currently English/German; shows a picker).
* **Ctrl+A** — show help, rendered from `i18n/<lang>/help.md` in a Markdown
viewer. Works even while the Url/Name input is focused (it overrides
`Input`'s own "select all" binding on that key).
## Tests
```bash
pip install -r requirements-dev.txt
pytest
```
`tests/` covers:
* `test_models.py` — the format-filtering / split-vs-combined detection
logic, run against both worked examples from the requirements document
(copied into `tests/fixtures/`), plus a couple of edge cases (no
survivable formats, missing `formats` key).
* `test_subprocess_clients.py` — the `yt-dlp`/`ffmpeg` async wrappers, with
`asyncio.create_subprocess_exec` monkeypatched to a fake process so no
real binaries or network access are needed.
* `test_i18n_integration.py` — the bundled i18n library against this app's
own translation data: fallback behaviour, language switching, listener
notification, `get_help()`.
* `test_app_workflow.py` — full end-to-end runs of the Textual UI via
`Pilot`: the split and combined selection flows, the error paths (empty
URL, cancelled selection), download + merge + temp-file cleanup, and the
Ctrl+T / Ctrl+A shortcuts.
## Project layout
```
main.py Entry point; wires up i18n, then starts the app
app/
tui_app.py The Textual App: layout + all screen wiring
styles.tcss External stylesheet for the app and every modal
screen (loaded via DownloadManagerApp.CSS_PATH)
models.py FormatEntry / VideoInfo + the filtering logic
that decides split vs. combined audio/video
ytdlp_client.py async wrappers for `yt-dlp --dump-json` and
@@ -39,12 +72,15 @@ app/
screens/
format_select_screen.py Modal format-selection table (audio & video)
error_screen.py Modal error dialog
language_select_screen.py Modal language picker (Ctrl+T)
help_screen.py Modal help viewer, renders help.md (Ctrl+A)
lib/i18n/ The provided i18n library (unmodified aside from
a small `__init__.py` re-export so that
`from i18n import I18n` works as documented)
i18n/en/, i18n/de/ This application's own translation data
(strings.json + help.md), as expected by the
library at <project_root>/i18n/<lang>/
tests/ pytest suite (see "Tests" below)
```
The i18n *library* is kept in `lib/i18n` (added to `sys.path` by
@@ -88,8 +124,8 @@ own package directory would use if it were placed at the project root.
## Notes / assumptions
* The two example JSON documents from the requirements are used as the
basis for the filtering logic and are exercised by an ad-hoc test during
development; there is no bundled test suite since none was requested.
basis for the filtering logic and are checked into `tests/fixtures/` so
the test suite exercises them directly.
* Temporary files for split downloads are named
`<destination-stem>.video.tmp.mp4` / `<destination-stem>.audio.tmp.mp4`
next to the destination file.