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 directly from GitHub with a single command:
pip install git+https://github.com/Ysn4Irix/tpb-cli.gitOr install from a pre-built wheel:
pip install tpb_cli-0.1.0-py3-none-any.whl# Clone the repository
git clone https://github.com/Ysn4Irix/tpb-cli.git
cd tpb-cli
# Install in editable mode for development
pip install -e .After installation, the tpb executable command will be immediately available in your terminal.
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. |
--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/
├── tpb/
│ ├── __init__.py # Package initialization & version metadata
│ ├── api.py # ApibayClient, HTTP requests, caching & error handling
│ ├── cli.py # Argument parsing and headless automation entrypoint
│ ├── exporter.py # File export, magnet formatters & Rich tables
│ ├── interactive.py # Interactive TUI, state machine & 0ms back navigation
│ ├── models.py # Torrent dataclass, properties & model coercion
│ └── parser.py # Regex parsers for seasons, episodes, quality & codecs
├── tests/
│ ├── test_api.py # API client and response mocking tests
│ ├── test_exporter.py # File writer & dict resilience 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
├── pyproject.toml # Build configuration & dependencies
├── requirements.txt # Direct runtime dependencies
└── README.md # Project documentation
The test suite contains 24 automated unit tests covering API queries, metadata parsing, interactive state transitions, and file exports:
pytest -vContributions, 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.