Riven does not blindly pick the first torrent it finds. Every result returned by a scraper backend is parsed and scored by RTN (Rank Torrent Name), an open-source library that extracts structured metadata from torrent titles and applies a configurable scoring model. Only the highest-ranked torrents — up to a configurable bucket limit — are kept for the downloader to act on.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rivenmedia/riven/llms.txt
Use this file to discover all available pages before exploring further.
What RTN Does
Given a raw title likeInception.2010.2160p.UHD.BluRay.x265.HDR.DTS-HD.MA.5.1-GROUP, RTN:
- Parses the title into a
ParsedDataobject:resolution=2160p,codec=x265,hdr=True,audio=DTS-HD MA 5.1,quality=BluRay, etc. - Validates the torrent against the item being scraped (correct title, year, season/episode numbers, country, language).
- Scores the torrent using the active
BaseRankingModel(default:DefaultRanking) and the user’sRTNSettingsModel. - Filters trash results (cam rips, watermarked, mismatched metadata) when
remove_all_trashis enabled.
Torrent object with a numeric rank attribute. Higher rank = better match.
Configuration
RTN settings live under theranking key in Riven’s settings. RTNSettingsModel extends the upstream SettingsModel from the rank-torrent-name library:
scraping:
| Setting | Default | Effect |
|---|---|---|
scraping.enable_aliases | true | Use alternative title spellings (e.g. localised names) when matching torrent titles |
scraping.bucket_limit | 5 | Maximum results kept per quality bucket after sorting |
scraping.dubbed_anime_only | false | Discard subtitled anime torrents; only keep dubbed ones |
scraping.max_failed_attempts | 0 (unlimited) | Move item to Failed after this many scrape cycles with no usable result |
The Bucket System
After scoring, torrents are sorted by rank withsort_torrents(). The bucket limit (scraping.bucket_limit) caps how many torrents are retained per quality bucket (e.g. no more than 5 2160p results, 5 1080p results, etc.):
Setting
bucket_limit to 0 disables the cap entirely. All valid torrents are passed to the downloader. This is also the behaviour when triggering a manual scrape (where manual=True).Per-Scrape Ranking Overrides
You can override ranking preferences for a single scrape without changing the global configuration. Pass a JSON-encodedranking_overrides query parameter to the scrape endpoint:
get_ranking_overrides() function in program/services/scrapers/shared.py takes the current global RTNSettingsModel, deep-copies it, and toggles fetch flags so only the listed items are enabled within each category:
Scrape Endpoint Reference
Get Streams for an Item
Returns all ranked streams for an item, optionally streaming results via SSE as each scraper backend completes:Download a Specific Stream
Once you have identified the infohash you want to use, you can instruct Riven to download it directly without waiting for the automatic ranking to pick one:Validation Filters Applied Before Ranking
RTN ranking only runs on torrents that pass a set of pre-filters inparse_results() (program/services/scrapers/shared.py). These filters ensure that:
- Movies do not match torrents that contain season or episode markers.
- Shows match torrents with at least 3 episodes and all expected seasons.
- Seasons match torrents with the correct season number and all expected episodes.
- Episodes match torrents containing the correct episode (or absolute) number.
- Year is within ±1 year of the item’s release date (or the show’s premiere year for seasons/episodes).
- Country variant (US, UK, AU, NZ) matches the item’s country code.
- Anime results respect the
dubbed_anime_onlyflag.
rtn.rank() is ever called, keeping the candidate set clean and the ranking scores meaningful.