Metadata-Version: 2.3
Name: pptu
Version: 2026.11.14
Summary: Python P2P Torrent Uploader
Author: pcroland, varyg
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: beautifulsoup4>=4.12.3,<5.0.0
Requires-Dist: guessit>=4.1.0,<5.0.0
Requires-Dist: humanize>=4.9.0,<5.0.0
Requires-Dist: langcodes>=3.4.0,<4.0.0
Requires-Dist: lxml>=6.0.1,<7.0.0
Requires-Dist: platformdirs>=4.2.2,<5.0.0
Requires-Dist: pymediainfo>=7.0.0,<8.0.0
Requires-Dist: pyotp>=2.9.0,<3.0.0
Requires-Dist: pyoxipng>=9.0.0,<10.0.0
Requires-Dist: pyrosimple>=2.14.0,<3.0.0
Requires-Dist: rich>=15.0.0,<16.0.0
Requires-Dist: toml>=0.10.2,<1.0.0
Requires-Dist: torf>=4.2.7,<5.0.0
Requires-Dist: pillow>=13.0.0
Requires-Dist: cloup>=3.0.7,<4.0.0
Requires-Dist: niquests[full,utls]>=3.15.2
Requires-Dist: ordered-set>=4.1.0,<5.0.0
Requires-Dist: orjson>=3.11.3
Requires-Dist: beaupy>=3.10.2
Requires-Dist: language-data>=1.3.0
Requires-Dist: pymal-ng>=2.0.0
Requires-Dist: nodriver>=0.45 ; extra == 'cloudflare'
Requires-Python: >=3.11, <3.15
Project-URL: Homepage, https://github.com/encoding-hun/pptu
Project-URL: Source, https://github.com/encoding-hun/pptu
Provides-Extra: cloudflare
Description-Content-Type: text/markdown

<p align="center"><img width="350" src="logo/logo.svg"><br>Python P2P Torrent Uploader</p>

## Requirements

- Python 3.10 to 3.13
- Python package dependencies (`uv sync --frozen` – requires uv 0.8.0 or newer – or `pip install .`)
- [mkbrr](https://github.com/autobrr/mkbrr) or [intermodal (imdl)](https://github.com/casey/intermodal) (faster torrent creation, optional; torf is used by default)
- [cfsolve](https://github.com/chris124567/cfsolve) (for headless Cloudflare solving, optional)
- MediaInfo CLI (for generating tech info)
- FFmpeg (for generating snapshots)

## Supported trackers

<table>
  <tr>
    <th>Name</th>
    <th>Acronym</th>
    <th>Auth</th>
    <th>Protection</th>
    <th>Captcha</th>
    <th>Server upload allowed</th>
  </tr>
  <tr>
    <th colspan="6">General</th>
  </tr>
  <tr>
    <th>BroadcasTheNet</th>
    <td align="center"><code>BTN</code></td>
    <td align="center">Credentials/<br />Cookies</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/274c.png" width="14" /> None</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/274c.png" width="14" /> No</td>
    <td><img src="https://github.githubassets.com/images/icons/emoji/unicode/26a0.png" width="14" /> Dedicated servers only, requires staff approval</td>
  </tr>
  <tr>
    <th>HDBits</th>
    <td align="center"><code>HDB</code></td>
    <td align="center">Credentials/<br />Cookies</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/2714.png" width="14" /> Cloudflare</td>
    <td align="center"><img width="14" src="https://github.githubassets.com/images/icons/emoji/unicode/2714.png"> Simple</td>
    <td><img src="https://github.githubassets.com/images/icons/emoji/unicode/2714.png" width="14" /> Yes, if IP whitelisted in profile or 2FA enabled</td>
  </tr>
  <tr>
    <th>nCore</th>
    <td align="center"><code>nC</code></td>
    <td align="center">Credentials/<br />Cookies</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/274c.png" width="14" /> None</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/274c.png" width="14" /> No</td>
    <td><img src="https://github.githubassets.com/images/icons/emoji/unicode/2714.png" width="14" /> Yes</td>
  </tr>
  <tr>
    <th>nekoBT</th>
    <td align="center"><code>nBT</code></td>
    <td align="center">API key</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/274c.png" width="14" /> None</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/274c.png" width="14" /> No</td>
    <td><img src="https://github.githubassets.com/images/icons/emoji/unicode/2714.png" width="14" /> Yes</td>
  </tr>
  <tr>
    <th>Nyaa</th>
    <td align="center"><code>nyaa</code></td>
    <td align="center">Credentials</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/26a0.png" width="14" /> DDoS-Guard</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/274c.png" width="14" /> No</td>
    <td><img src="https://github.githubassets.com/images/icons/emoji/unicode/2714.png" width="14" /> Yes</td>
  </tr>
  <tr>
    <th>PassThePopcorn</th>
    <td align="center"><code>PTP</code></td>
    <td align="center">Credentials/<br />Cookies</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/274c.png" width="14" /> None</td>
    <td align="center"><img src="https://github.githubassets.com/images/icons/emoji/unicode/274c.png" width="14" /> No</td>
    <td><img src="https://github.githubassets.com/images/icons/emoji/unicode/26a0.png" width="14" /> Dedicated servers only, requires staff approval</td>
  </tr>
  <tr>
    <th colspan="6">AvistaZ Network</th>
  </tr>
  <tr>
    <th>AvistaZ</td>
    <td align="center"><code>AvZ</code></td>
    <td align="center" rowspan="3">Credentials/<br />Cookies</td>
    <td align="center" rowspan="3"><img src="https://github.githubassets.com/images/icons/emoji/unicode/274c.png" width="14" /> None</td>
    <td align="center" rowspan="3"><img src="https://github.githubassets.com/images/icons/emoji/unicode/2714.png" width="14" /> Yes</td>
    <td rowspan="3"><img src="https://github.githubassets.com/images/icons/emoji/unicode/2714.png" width="14" /> Yes, if IP whitelisted in profile</td>
  </tr>
  <tr>
    <th>CinemaZ</th>
    <td align="center"><code>CZ</code></td>
  </tr>
  <tr>
    <th>PrivateHD</th>
    <td align="center"><code>PHD</code></td>
  </tr>
</table>

For sites with captcha, a 2captcha API key is required to solve the captcha. Manual solving may be added in the future.
"Simple" captchas can be solved automatically without 2captcha or user interaction.

### PassThePopcorn

- Credential auth requires passkey in addition to username and password.

### Cloudflare-protected trackers

Some trackers (currently HDBits) sit behind a Cloudflare managed challenge. The challenge yields a `cf_clearance` cookie that is bound to your IP, User-Agent, and TLS fingerprint. Settings go in the tracker's own config section (`[hdbits]` below).

By default (`cf_solver = "auto"`), pptu tries the headless `cfsolve` solver first, and automatically falls back to the real browser solver (`nodriver`) or manual cookies if needed. You can skip `cfsolve` and force the real browser solver at any time by setting `cf_solver = "browser"` (or `cfsolve = false`) under `[hdbits]` in `config.toml`, or passing `--cf-solver browser` on the command line.

**Primary: headless solver via `cfsolve` (no browser or GUI needed)**

- Install [`cfsolve`](https://github.com/chris124567/cfsolve) (requires `cmake` and `libclang`, e.g. `sudo dnf install cmake clang-devel` on Fedora or `sudo apt install cmake libclang-dev` on Debian/Ubuntu):
  ```shell
  cargo install --git https://github.com/chris124567/cfsolve --bin challenge
  ```
- No config paths are needed: pptu automatically finds the `challenge` binary on your `PATH` (or `~/.cargo/bin`) and automatically downloads and caches the browser profile into `~/.local/share/pptu/cfsolve/profiles/` on first use.
- If `cfsolve` fails or its clearance is rejected, pptu automatically falls back to the browser solver or manual cookies below.

**Fallback 1: built-in browser solver (desktop with a GUI)**

- Install the extra: `pip install 'pptu[cloudflare]'` (or `pip install nodriver`). It needs Chrome, Chromium, Edge or Brave installed.
- pptu briefly opens the browser, clears the check, and stores the clearance and the browser's User-Agent next to the tracker's cookies. Later runs reuse them until they expire.
- If the browser isn't auto-detected, set `browser_path` (e.g. `/snap/bin/chromium`, `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` or `C:\Program Files\Google\Chrome\Application\chrome.exe`).
- On a Linux server with a browser but no display, run `xvfb-run pptu ...`.
- If Cloudflare shows a "Verify you are human" checkbox, click it in the opened window. For unattended runs (`--auto`, watch folders), set `2captcha_api_key` (the same key AvistaZ uses) instead: when the browser hasn't passed after 15 seconds, pptu has 2captcha solve the Turnstile check and hands the token back to the page, so no click is needed.

**Fallback 2: exported cookies (headless / CLI-only servers without `cfsolve`)**

1. On a machine with a browser on the same network (same IP / VPN exit), pass the check on the tracker's site and export its cookies as Netscape `cookies.txt` (must include `cf_clearance`).
2. Save them as the tracker's cookie file in pptu's cookies directory (`~/.local/share/pptu/cookies/` on Linux): `<tracker>.txt` (e.g. `hdb.txt`), or `<tracker>_<sha1 of your username>.txt` if a `username` is set. No username or password is needed for this.
3. Tell pptu that browser's exact User-Agent, because a mismatch gets the clearance rejected:
   ```toml
   [hdbits]
   browser_ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) ... Chrome/131.0.0.0 Safari/537.36"
   ```

When run interactively without a solver, pptu prints the cookie file path, waits for you to drop the file in, and asks for the User-Agent, so steps 2 and 3 can be done on the spot.

### AvistaZ Network

- Using credential auth is strongly recommended as cookies always expire within a few days.

## Installation

Install dependencies and the script with `./install.py`. You can re-run the script to update after a git pull.

## Setup

Copy `config.example.toml` to `~/.config/pptu/config.toml` and edit it as appropriate.

For credential-based auth, add your credentials in `~/.config/pptu/config.toml`:

```
[TRACKER]
username = "yourusername"
password = "yourpassword"
```

Optionally, you may specify `totp_secret` for automating 2FA logins.
Optionally, you may specify `img_uploader` for image host site.

For cookie-based auth, place cookies in `~/.local/share/pptu/cookies/TRACKER.txt`.

`TRACKER` is the name or the abbreviation of the tracker above (all lowercase).

## Usage

```
❯ pptu -h

Usage: pptu [OPTIONS] COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...

Options:
   -v, --version                      Show the version and exit.
   -i, --input PATH                   Files or directories to create torrents for.
   --fast-upload / --no-fast-upload   Upload only after all steps succeed (or force-disable).
   -c, --confirm                      Ask for confirmation before uploading.
   -a, --auto                         Run non-interactively (never prompt).
   --cf-solver [auto|browser|...]     Cloudflare solver: auto, browser, cfsolve, manual.
   -ds, --disable-snapshots           Skip creating description snapshots.
   -s, --skip-upload                  Create torrents but don't upload.
   -n, --note TEXT                    Note to attach to the upload.
   -lt, --list-trackers               Show the list of supported trackers and exit.
   -h, --help                         Show this message and exit.

Uploaders (9):
   AvistaZ          https://avistaz.to/
   BroadcasTheNet   https://broadcasthe.net/
   CinemaZ          https://cinemaz.to/
   HDBits           https://hdbits.org/
   nCore            https://ncore.pro/
   nekoBT           https://nekobt.to/
   Nyaa             https://nyaa.si/
   PassThePopcorn   https://passthepopcorn.me/
   PrivateHD        https://privatehd.to/

```

### Example

```shell
pptu -i /path/example.mkv -i /path/example2.mkv hdb nc --request-id 12356
```
