Metadata-Version: 2.4
Name: anime-termux
Version: 1.0.2
Summary: A user-friendly anime downloader CLI for Termux — streams from animepahe.pw with real-time search, CF cookie bypass, quality selection, and aria2c segmented downloading.
Author: anime-termux
License: MIT
Project-URL: Repository, https://github.com/anime-termux/anime-termux
Keywords: anime,downloader,termux,animepahe,android,cli,aria2c,yt-dlp
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Environment :: Console
Classifier: Topic :: Multimedia
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: prompt_toolkit>=3.0.0
Requires-Dist: yt-dlp>=2024.1.0
Provides-Extra: crypto
Requires-Dist: cryptography>=41.0.0; extra == "crypto"

# anime-termux

A user-friendly anime downloader CLI for Termux (Android) and Linux, streaming from [animepahe.pw](https://animepahe.pw).

## Install

```bash
pip install anime-termux
```

**Recommended** (for fastest downloads):
```bash
pkg install aria2   # 16-thread segmented downloading
pkg install ffmpeg  # video merging (usually pre-installed with yt-dlp)
```

## Usage

```bash
# Interactive mode — search, pick, download
anime

# Custom download directory
anime --dir=/sdcard/MyAnime
anime --dir=/storage/external/Anime

# Refresh Cloudflare cookie (auto-extract or manual wizard)
anime --setup
```

## Cloudflare bypass

AnimePahe sits behind Cloudflare. `anime-termux` handles this in two ways:

### Automatic (Linux desktop / rooted Android)

On first run the tool tries to read `cf_clearance` directly from your locally installed Chrome or Chromium browser — no manual steps needed. It also detects your Chrome version and constructs the matching User-Agent automatically.

To unlock automatic decryption, install one of:

```bash
pip install cryptography   # recommended
# OR
pip install pycryptodome
```

Without a crypto library the tool falls back to the manual wizard.

### Manual wizard (all platforms)

If auto-extraction fails (e.g. non-rooted Android, or no crypto library installed), the first-run wizard guides you through a one-time copy-paste:

1. Open <https://animepahe.pw> in Chrome — let the CF check pass.
2. `F12` → Application → Cookies → copy `cf_clearance` value.
3. `F12` Console → type `navigator.userAgent` → copy the string.
4. Paste both into the wizard.

Credentials are saved to `~/.config/anime-termux.json` and reused on every subsequent run. Refresh with `anime --setup` when the cookie expires (usually every 1–7 days).

## Features

- **Auto CF extraction** — reads `cf_clearance` straight from Chrome on Linux/macOS; falls back to wizard on Android without root
- **Real-time search** — suggestions appear from the **first character** you type; Tab to autocomplete
- **Quality picker** — choose 360p / 480p / 720p / 1080p / best
- **Segmented download** — aria2c with 16 connections (falls back to yt-dlp 8-fragment mode)
- **Episode range** — single ep, ranges, comma lists, or `all`
- **Skip existing** — already-downloaded episodes are skipped automatically
- **Custom directory** — `anime --dir=/path/to/folder`

## Output

```
/sdcard/Anime/{Anime Title}/{Anime Title} - Ep001.mp4
```

## How it works

1. Auto-extracts (or wizard-collects) `cf_clearance` + `User-Agent` from Chrome
2. Searches the AnimePahe API with those credentials
3. Shows a live-search prompt — results appear after the first character
4. You pick episode range + quality
5. yt-dlp downloads via kwik.cx extraction with segmented aria2c
