Skip to content

g0ldyy/torrent-parse-rank

Repository files navigation

torrent-parse-rank

A high-performance Rust implementation of The Best Damn Filename Parser You've Ever Used!

Credits

What You Get

  • Fast PTT parsing API for raw torrent names.
  • RTN ranking/filtering API with configurable quality rules.
  • Python-first usage (from PTT import parse_title, from RTN import RTN).
  • Rust performance without changing your Python integration style.

Install In Your Python Project

Option 1: Local path

uv add --editable /absolute/path/to/torrent-parse-rank

Option 2: Git dependency

uv add "torrent-parse-rank@git+https://github.com/g0ldyy/torrent-parse-rank"

Notes:

  • Installing from source requires a Rust toolchain (cargo) available in PATH.
  • The import names are PTT and RTN.

Quickstart

1) Parse a torrent title (PTT)

from PTT import parse_title

data = parse_title("The.Simpsons.S01E01.1080p.BluRay.x265", False)
print(data["title"])      # The Simpsons
print(data["resolution"]) # 1080p

2) Parse + rank a candidate (RTN)

from RTN import RTN
from RTN.models import DefaultRanking, SettingsModel

rtn = RTN(SettingsModel(), DefaultRanking())
item = rtn.rank(
    raw_title="The Walking Dead S05E03 720p x264-ASAP",
    infohash="c08a9ee8ce3a5c2c08865e2b05406273cabc97e7",
)

print(item.fetch)  # True/False after filters
print(item.rank)   # computed rank score
print(item.data.parsed_title)

3) Parse only (RTN)

from RTN import parse

parsed = parse("Oppenheimer.2023.2160p.REMUX.DV.HDR10Plus.TrueHD.7.1.HEVC")
print(parsed.resolution)
print(parsed.codec)

Development

cd torrent-parse-rank
uv sync --group dev
uv run maturin develop --release

Quality / Tests

cd torrent-parse-rank
./scripts/quality_gate.sh
./scripts/quality_gate.sh --full

--full includes upstream parity tests.

Benchmarks

Python API speedup vs upstream (PTT + RTN): ~3.20x geometric-mean throughput.

Parser (N=30,000) Upstream Python (items/s) Rust port (items/s) Speedup Upstream p50 (ms) Rust p50 (ms)
PTT.parse_title 1,832.2 5,763.9 3.15x 0.550 0.173
RTN.parse 1,726.1 5,446.9 3.16x 0.583 0.183

Full benchmark report: benchmarks/README.md

About

A high-performance Rust implementation of The Best Damn Filename Parser You've Ever Used!

Resources

License

Stars

Watchers

Forks

Contributors