Metadata-Version: 2.4
Name: animepahe-dl-tmux
Version: 1.4.1
Summary: AnimePahe downloader with automatic Cloudflare bypass via Playwright
License: MIT
Keywords: anime,animepahe,cloudflare,downloader,playwright
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Video
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27.0
Requires-Dist: playwright>=1.44.0
Requires-Dist: rich>=13.7.0
Requires-Dist: tqdm>=4.66.0
Description-Content-Type: text/markdown

# AnimePahe Downloader

Downloads anime from **animepahe.com**.  
Uses a real Chromium browser via **Playwright** to automatically solve Cloudflare's JS challenge — no manual cookie juggling needed.

## Why Playwright?

AnimePahe uses Cloudflare's "Managed Challenge" (interactive JS mode) on every route including the JSON API.  
Standard HTTP clients (`requests`, `httpx`, `curl_cffi`) cannot execute JavaScript and therefore always get a 403.  
Playwright runs a real Chromium instance that solves the challenge exactly as a human browser would.

## Installation

```bash
pip install animepahe-dl-tmux

# Required one-time setup — installs the Chromium browser (~150 MB):
playwright install chromium
```

> **If you skip `playwright install chromium` you will get a "Browser not found" error.**

## Usage

```
animepahe-dl-tmux                          # interactive — prompts for everything
animepahe-dl-tmux "Demon Slayer"           # search immediately, pick episodes interactively
animepahe-dl-tmux "Demon Slayer" --all     # download every episode
animepahe-dl-tmux "Demon Slayer" -e 1-5   # episodes 1 through 5
animepahe-dl-tmux "Demon Slayer" -e 1,3,7 # specific episodes
animepahe-dl-tmux "Demon Slayer" --visible # show the browser window (debug)
```

## How It Works

1. **Playwright** launches a headless Chromium browser and visits `animepahe.com`.
2. Cloudflare's JS challenge runs inside the real browser — it solves automatically (~5–15 s).
3. The solved session cookies (`cf_clearance` etc.) are extracted and reused in fast `httpx` API calls.
4. For each episode, the script navigates to kwik.si in the browser and intercepts the HLS `.m3u8` URL from network traffic.
5. **ffmpeg** downloads and muxes the HLS stream into a single `.mp4` file.

## Output

Files are saved to `downloads/<Anime Title>/Episode_NNNN.mp4` in the current directory.

## Troubleshooting

| Symptom | Fix |
|---|---|
| `Browser not found` | Run `playwright install chromium` |
| `CloudflareError: Timed out` | Run with `--visible` to watch the browser; may need a manual CAPTCHA click |
| `ffmpeg: command not found` | Install ffmpeg: `winget install ffmpeg` (Windows) or `brew install ffmpeg` (Mac) or `apt install ffmpeg` (Linux) |
| No players found for an episode | The episode may not be available yet on AnimePahe |

## Requirements

- Python 3.9+
- ffmpeg (in system PATH)
- Chromium browser: install with `playwright install chromium` (~150 MB, one-time)
