pahe-batcher is a professional-grade, high-performance TUI tool for AnimePahe. It automates the tedious process of resolving, downloading, and streaming anime into a seamless, parallelized terminal experience.
Built with a modern asynchronous pipeline, it features a content-addressed SQLite segment engine that deduplicates shared data (like Openings/Endings) across episodes, saving significant disk space and bandwidth.
-
Prerequisites:
- FlareSolverr: Must be running to bypass Cloudflare protection.
- FFmpeg: Required for HLS segment remuxing (.ts → .mp4).
- MPV: Optional, required for the
--streamfeature.
-
Installation:
git clone https://github.com/smolfiddle/pahebatcher.git cd pahebatcher pip install -r requirements.txt -
Run:
python3 pahe_batcher.py "https://animepahe.pw/anime/<uuid>"
- Batch Download: Fetches HLS segments in parallel, stores them in a deduplicated SQLite vault, and remuxes them into organized
.mp4files using FFmpeg. - Export Links: Resolves M3U8 URLs and extracts authentication headers (User-Agent, Referer, Cookies) to a
links_export.txtfile for use in IDM or JDownloader. - Stream via MPV: Watch anime directly in your terminal with a live "Now Playing" dashboard and interactive playback controls (Next, Prev, Replay).
- Parallel HLS Engine: Uses
aiohttpandasyncioto fetch segments with up to 32 concurrent workers per download. - SQLite Vault: A content-addressed chunk store using BLAKE2b hashing. Identical HLS segments are stored only once, even if they appear in multiple episodes.
- Adaptive Compression: Entropy-based zlib compression for low-entropy segments (subtitles, silent audio) to save disk space during the staging process.
- Hardened TLS: Strict SSL/TLS 1.2+ context with AEAD cipher selection and certificate validation for secure, modern connections.
- Interactive Wizard: A polished, step-by-step TUI for configuring your batch without memorizing flags.
- Live Dashboards: Real-time progress tracking for downloads and a "Live Playback" panel for streaming.
- Smart Resume: Interrupted downloads can be resumed seamlessly—the SQLite engine tracks exactly which segments are already persisted.
PaheBatcher follows a modular Asynchronous Pipeline Architecture.
- AnimePahe API: Scans series metadata and resolves the full episode list with JIT title fetching.
- FlareSolverr Integration: Automatically handles Cloudflare challenges and persists valid Chromium sessions across requests.
- Kwik Resolver: Unpacks obfuscated JavaScript to extract protected HLS manifests and authentication tokens.
- Content-Addressing: Chunks are indexed by their BLAKE2b hash. This enables seamless cross-episode deduplication for shared assets.
- WAL-Mode SQLite: A high-concurrency database layer using Write-Ahead Logging to handle thousands of segment writes without I/O blocking.
- Automatic Cleanup: Temporary database assets are purged after successful remuxing to keep your staging directory clean.
- FFmpeg Remuxer: Stitches segments into a stream-copy MP4 container with
+faststartflags for immediate playback across all devices. - MPV Bridge: Injects dynamic headers directly into the
lavfdemuxer to enable streaming of protected HLS feeds with full decryption support.
python3 pahe_batcher.py <url> [options]| Argument | Description | Default |
|---|---|---|
URL |
AnimePahe series URL. | Required |
-a, --all |
Download every episode automatically. | False |
-r, --range |
Specify episode range (e.g., 1-12, 1,4, 13-). |
None |
-n, --latest |
Download the latest N episodes. | None |
-e, --export |
Export links/headers to a file. | False |
-s, --stream |
Stream episodes via MPV. | False |
-q, --quality |
Preferred quality: 1080, 720, 360. |
1080 |
-o, --output |
Output directory. | ./downloads |
-j, --parallel |
Concurrent downloads (max 6). | 2 |
-w, --workers |
HLS segment workers per download (max 32). | 16 |
--keep-db |
Do not delete the temp SQLite database. | False |
-y, --yes |
Skip all confirmation prompts. | False |
Stream the latest episode in 1080p:
python3 pahe_batcher.py <URL> --latest 1 --streamDownload a specific range with high concurrency:
python3 pahe_batcher.py <URL> --range 1-12 --parallel 4 --workers 24Export links for an external manager:
python3 pahe_batcher.py <URL> --all --export --output ~/Desktop/LinksThe project includes a comprehensive pytest suite covering the database engine, HLS encryption, and async streaming logic.
pytest test_pahe_batcher.pyThis tool is intended for personal and educational use. Downloading copyrighted content may violate terms of service or local laws. Support official creators.
MIT License. See LICENSE for details.

