Metadata-Version: 2.4
Name: animepahe-dl-tmux
Version: 1.4.0
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.ru** (also tries `.com` / `.org`).  
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.

## Quick Start

```bash
# 1. Install dependencies (once)
bash setup.sh

# 2. Run
python main.py
```

## Usage

```
python main.py                          # interactive — prompts for everything
python main.py "Demon Slayer"           # search immediately, then pick episodes interactively
python main.py "Demon Slayer" --all     # download every episode
python main.py "Demon Slayer" -e 1-5   # episodes 1 through 5
python main.py "Demon Slayer" -e 1,3,7 # specific episodes
python main.py "Demon Slayer" --visible # show the browser window (useful for debugging)
```

## How It Works

1. **Playwright** launches a headless Chromium browser and visits `animepahe.ru`.
2. Cloudflare's JS challenge runs inside the real browser — it solves automatically (~3–10 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 to intercept the HLS `.m3u8` URL.
5. **ffmpeg** downloads and merges the HLS stream into a `.mp4` file.

## Output

Files are saved to `downloads/<Anime Title>/Episode_NNNN.mp4`.

## Troubleshooting

| Symptom | Fix |
|---|---|
| `CloudflareError: Timed out` | Run with `--visible` to watch the browser; the site may need a CAPTCHA click |
| `ffmpeg: command not found` | Install ffmpeg: `sudo apt install ffmpeg` (or via your OS package manager) |
| No players found for an episode | The episode may not be available yet; try again later |
| 403 on API calls after warm-up | Add `--visible` and watch — the browser may need user interaction |

## Requirements

- Python 3.9+
- ffmpeg (in PATH)
- ~300 MB disk for Chromium (installed by `playwright install chromium`)
