Metadata-Version: 2.4
Name: hpkg1
Version: 0.1.0
Summary: CLI downloader for amateursubs.com — direct MP4 with parallel chunks
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.28
Requires-Dist: rich>=13
Requires-Dist: tqdm>=4.64
Requires-Dist: InquirerPy>=0.3.4
Requires-Dist: pyfiglet>=0.8
Requires-Dist: urllib3>=1.26

# hpkg1

CLI downloader for [amateursubs.com](https://amateursubs.com/) — direct MP4 with parallel chunk download.

## Install

```bash
pip install hpkg1
```

## Usage

```bash
hpkg1                          # interactive fuzzy search picker
hpkg1 -s "kokuhaku"            # pre-filter by title
hpkg1 -s "title" --all         # download all files non-interactively
hpkg1 -q 1080p                 # only download 1080p files
hpkg1 -q best                  # best quality per episode (default)
hpkg1 -q all                   # every available quality
hpkg1 --refresh-index          # force-refresh the post list
hpkg1 --config                 # show current settings
hpkg1 --set-download-dir ~/dl  # change download directory
hpkg1 --set-threads 16         # change parallel threads
hpkg1 --set-quality 1080p      # change default quality
hpkg1 --version                # print version
```

## How it works

1. Loads all posts from WordPress REST API → local cache (`~/.hpkg1_index.json`)
2. InquirerPy fuzzy picker to select a title
3. Extracts direct MP4 URLs from post content:
   - Strategy 1: WP REST API `content.rendered` (fast)
   - Strategy 2: HTML scrape fallback (handles Presto Player posts)
   - Strategy 3: ouo.io link resolver — bypasses monetized redirect links (~65% of posts use these)
4. Downloads with parallel Range requests for full bandwidth utilisation
5. **Resume-safe**: chunks are stored in `~/.hpkg1_chunks/` keyed by URL hash — re-run to continue an interrupted download exactly where it left off

## Config

Config stored at `~/.hpkg1.json`:

| Key | Default | Description |
|---|---|---|
| `download_dir` | `~/hpkg1_downloads` | Where files are saved |
| `threads` | `8` | Parallel download threads |
| `quality` | `best` | Quality filter (see below) |

## Quality options

| Value | Behaviour |
|---|---|
| `best` | Highest quality per episode (default) |
| `all` | Every available file, no filtering |
| `1080p` | Exact match; falls back to all if not found |
| `720p` | Exact match; falls back to all if not found |
| `576p` | Exact match; falls back to all if not found |
| `480p` | Exact match; falls back to all if not found |
| `2160p` | Exact match; falls back to all if not found |

## Flags reference

| Flag | Description |
|---|---|
| `-s / --search TITLE` | Pre-filter titles before the fuzzy picker |
| `-a / --all` | Skip the file-selection prompt and download everything |
| `-q / --quality QUALITY` | Quality filter for this run |
| `-t / --threads N` | Parallel threads for this run |
| `-d / --download-dir PATH` | Download directory for this run |
| `--no-ouo` | Skip ouo.io resolution (faster, may miss files) |
| `--refresh-index` | Force-rebuild post cache and exit |
| `--config` | Print current config and exit |
| `--set-quality QUALITY` | Save quality default to config |
| `--set-threads N` | Save threads default to config |
| `--set-download-dir PATH` | Save download dir to config |
| `--reset-config` | Reset config to defaults |
| `--version / -V` | Print version and exit |
