A fast, interactive Python CLI and automation tool for searching movies and TV series, selecting episodes/seasons across quality releases, and batch-exporting magnet links via the apibay.org (The Pirate Bay) backend.
- π Immediate Search & Discovery:
- Automatically queries the backend immediately after you enter a show title.
- Scans results upfront to determine total releases, codecs, and qualities.
- πΊ Auto-Detected Season Selector:
- Analyzes search results to detect all available seasons.
- Displays episode counts and complete pack counts for each season (e.g.,
Season 1 (10 episodes, 3 packs)), eliminating guesswork.
- π Series Disambiguation:
- Automatically identifies regional variants (e.g., The Office US vs The Office UK) and prompts you to select the exact version you want.
- ποΈ Multi-Quality Episode Picker:
- Groups results by episode number (
E01,E02, ...). - Pre-selects the healthiest release per episode by default.
- Allows switching or selecting alternate qualities (
1080p,720p,2160p / 4K, SD,x265,x264) directly from an interactive checklist.
- Groups results by episode number (
- π¦ Season Packs vs Individual Episodes:
- Detects full season packs and lets you grab a complete pack in one click or pick and choose individual episodes.
- π¬ Movie Search & High-Quality Filters:
- Fast search with rich metadata tables (seeders, leechers, file size, codec, VIP/Trusted uploader tags).
- β‘ Zero-Lag Back Navigation:
- Press
Esc,b,q, orβat any step to instantly return to the previous screen (configured with sub-10ms key sequence timeouts). - In-memory query caching ensures backing up doesn't repeat slow network requests.
- Press
- πΎ Smart Export Workflows:
- Save magnet links to text files (
.txt) with pre-filled smart filenames (e.g.,breaking_bad_S01_magnets.txt). - File collision resolution: overwrite or append to existing link lists.
- Print links directly to the terminal or both save and print.
- High-reliability public trackers are automatically embedded in generated magnet links.
- Save magnet links to text files (
- π‘οΈ Scriptable & Resilient:
- Run interactively (TUI) or automate batch exports using CLI flags.
- Custom proxy support (HTTP / SOCKS5) and custom API base URLs.
- CP1252-safe console rendering for Windows terminals.
- Python 3.10 or higher
- Git
Install the lightweight CLI directly from GitHub:
pip install git+https://github.com/Ysn4Irix/tpb-cli.gitOr include the optional PySide6 Desktop GUI ([gui] extra):
pip install "tpb-cli[gui] @ git+https://github.com/Ysn4Irix/tpb-cli.git"Or install from a pre-built wheel:
pip install tpb_cli-0.3.0-py3-none-any.whl# Clone the repository
git clone https://github.com/Ysn4Irix/tpb-cli.git
cd tpb-cli
# Install CLI + GUI + dev/packaging dependencies in editable mode
pip install -e ".[gui,dev]"After installation, tpb (CLI) and tpb-gui (Desktop GUI, when [gui] is installed) are available in your terminal.
Launch the native desktop window (PySide6):
tpb-gui
# or via CLI flag:
tpb --gui- TV Series Browser: Regional disambiguation chips (
US,UK,All), auto-detected Season list with episode & pack counts, Season Packs table, and an interactive Episode Quality Matrix (all results start unchecked by default, with a one-click Select Recommended action and automatic single-quality switching per episode). - Movies & General Search: Live-filterable and numerically sortable release table with VIP/Trusted uploader tags and resolution/codec indicators.
- Torrent File Inspector: Click any release to asynchronously fetch and inspect internal file paths and sizes (
ApibayClient.get_files). - Batch Magnet Handoff: Copy selected magnets to clipboard, launch staggered
magnet:URIs in your default torrent client (with safety confirmation for large batches > 5), or export.txtwith Overwrite/Append prompt. - Library & Settings: Dark Mode (default) / Light Mode toggle (
Ctrl+T), persistent search history & bookmarks sidebar, and Apibay mirror / HTTP & SOCKS5 proxy configuration (Ctrl+,).
.\packaging\build_exe.ps1This bundles dist\tpb-gui.exe using PyInstaller with console suppression (--windowed).
Simply run tpb without arguments:
tpbOr via Python module:
python -m tpb.cli- Choose Category: Select between TV Series, Movies, or General Search.
- Enter Title: Type in the show or movie title (e.g.,
Severance,The Office). - Disambiguation (if applicable): If multiple series versions exist (e.g., US vs UK), choose your preferred version.
- Select Season: Pick from auto-detected seasons with release statistics.
- Quality Filter: Filter by
1080p,720p,2160p, orAny. - Pack or Episodes: Grab a complete Season Pack or select individual episodes.
- Episode Checklist: Use
[Space]to toggle,[a]to select all, and[Enter]to confirm. - Export: Save to file and/or print magnet links to the terminal.
π‘ Navigation Tip: Press
Esc,b,q, orβanytime to jump back to the previous menu step.
You can automate search and export directly using CLI flags:
tpb "Severance" -s 1 -q 1080p -o severance_s1.txttpb "Breaking Bad" -s 1 --pack -o bb_s1.txttpb "Inception" -q 1080p --printtpb "Better Call Saul" -s 1 -q 720p -o series_links.txttpb "The Matrix" --proxy "socks5://127.0.0.1:9050" --api-url "https://apibay.org"| Flag | Long Flag | Description |
|---|---|---|
query |
Search query string (movie or TV title). Omit to launch interactive mode. | |
-s |
--season |
TV Show season number (e.g. 1, 2). |
-q |
--quality |
Resolution preference: 2160p, 1080p, 720p, 480p, or any. |
-o |
--output |
Destination file path to save magnet links (.txt). |
-p |
--print |
Print magnet links to terminal stdout. |
--pack |
Prefer complete season pack over individual episodes. | |
-i |
--interactive |
Force interactive TUI even if a query argument was passed. |
--gui |
Launch the PySide6 desktop GUI (tpb-cli[gui]). |
|
--api-url |
Custom Apibay backend URL (Default: https://apibay.org). |
|
--proxy |
HTTP or SOCKS5 proxy URL (e.g. socks5://127.0.0.1:9050). |
|
-v |
--version |
Display program version and exit. |
-h |
--help |
Show command line options and help message. |
tpb-cli/
βββ .github/workflows/
β βββ ci.yml # Lint, format, typecheck, security, cross-OS tests & build
β βββ release.yml # Tagged release automation (.whl, .tar.gz & tpb-gui.exe)
βββ docs/
β βββ tpb-cli.md # CLI design notes
β βββ tpb-desktop-gui.md # Desktop GUI implementation plan & checklist
βββ tpb/
β βββ __init__.py # Package initialization & version metadata
β βββ api.py # ApibayClient, URL/proxy validation, cache lock & file normalization
β βββ cli.py # Argument parsing, --gui launcher & headless automation
β βββ exporter.py # File export, magnet formatters & Rich tables
β βββ interactive.py # Interactive TUI, state machine & 0ms back navigation
β βββ models.py # Torrent/TorrentFile dataclasses, formatting & coercion
β βββ parser.py # Regex parsers for seasons, episodes, quality & codecs
β βββ gui/ # Optional PySide6 desktop interface (pip install tpb-cli[gui])
β βββ assets/ # Multi-resolution Cyan Vector Magnet PNG/ICO icons & loader
β βββ app.py # QApplication bootstrap & tpb-gui entrypoint
β βββ column_state.py# Persistent interactive table & tree column widths
β βββ main_window.py # Desktop window shell, search bar, loading & workspace states
β βββ state.py # Persistent settings, dark/light theme, history & bookmarks
β βββ theme.py # Dark & Light QSS stylesheets and palette tokens
β βββ workers.py # QThreadPool async workers with cancellation & stale guards
β βββ views/ # TV Series browser & Movie/General sortable results table
β βββ widgets/ # File Inspector, Magnet ActionBar, Library drawer & Settings
βββ packaging/
β βββ tpb-gui.spec # PyInstaller Windows --windowed spec
β βββ build_exe.ps1 # Standalone .exe build script
βββ tests/
β βββ conftest.py # Headless QT_QPA_PLATFORM=offscreen setup
β βββ test_api.py # API client and response mocking tests
β βββ test_exporter.py # File writer & dict resilience tests
β βββ test_gui_state.py # GUI settings, URL validation, history, bookmarks & CLI --gui tests
β βββ test_gui_views.py # Offscreen Qt widget/view/action-bar tests
β βββ test_gui_workers.py# Async worker fallback, cancellation & stale-request tests
β βββ test_interactive.py# Navigation, series disambiguation & prompt tests
β βββ test_models.py # Dataclass properties & tracker verification
β βββ test_parser.py # TV metadata extraction & episode grouping tests
βββ AGENTS.md # Project engineering, security, UI & CI/CD rules
βββ CHANGELOG.md # Keep-a-Changelog release history (SemVer)
βββ pyproject.toml # Build configuration, [gui]/[dev] extras & tool settings
βββ MANIFEST.in # Distribution manifest rules
βββ requirements.txt # Direct core runtime dependencies
βββ README.md # Project documentation
The test suite covers API queries, metadata parsing, interactive TUI navigation, file exports, and offscreen PySide6 GUI workflows:
# Run full test suite
pytest -v
# Linting, formatting, and type checks
ruff check tpb tests
ruff format --check tpb tests
mypy tpb
# Security & dependency vulnerability scans
bandit -r tpb -ll
pip-audit --skip-editableThis repository includes GitHub Actions workflows in .github/workflows/:
- Continuous Integration (
ci.yml):- Triggered automatically on pushes and pull requests to
master/main. - Enforces least-privilege
contents: readpermissions and pip caching. - Fails fast across sequential gates:
- Quality:
ruff format --check,ruff check, andmypy. - Security:
bandit -r tpb -llstatic analysis andpip-auditdependency scan. - Test Matrix:
pytest -vwithQT_QPA_PLATFORM=offscreenacross Ubuntu & Windows (Python 3.10β3.14). - Package Build:
python -m buildandtwine check dist/*.
- Quality:
- Triggered automatically on pushes and pull requests to
- Release Automation (
release.yml):- Triggered on SemVer tags matching
v*.*.*(for examplev0.3.0). - Re-runs full lint, formatting, type, security, and cross-platform test verification before building release binaries (
tpb_cli-*.whl,tpb_cli-*.tar.gz, and Windows standalonetpb-gui.exe). - Extracts matching version notes from
CHANGELOG.mdand publishes the GitHub Release under scopedcontents: writepermission. - Local release checklist before tagging:
- Bump
versioninpyproject.tomland__version__intpb/__init__.py(MAJOR.MINOR.PATCH). - Update
CHANGELOG.mdand commit with a Conventional Commit (e.g.,chore(release): prepare v0.3.0). - Wait for all CI checks to pass before creating and pushing a
vX.Y.Ztag.
- Bump
- Triggered on SemVer tags matching
Contributions, issues, and feature requests are welcome!
- Fork the project.
- Create your feature branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m "feat: add amazing feature"). - Run tests (
pytest -v). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
This project is licensed under the MIT License.