Search pipeline¶
This page traces a search from the moment you select a title to the ranked list you see in the picker.
Overview¶
flowchart TD
Q[Play / search request] --> SRC{Entry path}
SRC -->|plugin:// play or search| CACHE{Cache hit?}
SRC -->|TMDBHelper RunScript| PLAN
CACHE -->|yes| RANK
CACHE -->|no| PLAN[Plan Newznab query<br/>tvdbid / imdbid / title]
PLAN --> FAN[Run enabled providers<br/>serial if one, threaded if many]
FAN --> NORM[Normalize to common result dict]
NORM --> DEDUPE[De-duplicate by download link]
DEDUPE --> STORE[Store in cache<br/>plugin:// path only]
STORE --> RANK[Filter + rank<br/>record first rejecting filter]
RANK --> PICK{Auto-select best on<br/>and any result passed filters?}
PICK -->|yes| PLAY[Resolve top filtered result]
PICK -->|no| TAG[Tag already-downloaded results]
TAG --> DLG[Picker: filtered view<br/>show-all toggle reveals rejected rows]
Query planning¶
A shared planner builds each provider's query from the title and any IDs:
- Episodes prefer a TVDB ID, then an IMDb ID, then fall back to a cleaned title plus season and episode numbers.
- Movies use the IMDb ID, else a cleaned title.
- When an indexer advertises its capabilities (caps), the planner honors the supported parameters for each search type. Without caps, it uses sensible defaults.
- If an id-based query returns nothing, NeNeTeePee-Stream-Kodi retries by title so a missing or mismatched id never leaves you empty-handed.
- When an episode request has no TVDB id,
tvdb_resolver.pylooks it up once from the TMDB/IMDb id through the TMDB API (cached on disk, fail-soft) so every provider shares it. A movie request carrying only a TMDB id gets its IMDb id the same way.
Prowlarr is a special case: its native search API doesn't take id parameters,
so NeNeTeePee-Stream-Kodi embeds them as tokens inside the query text: {tvdbid:…},
{imdbid:…}, {season:…}, and {episode:…}.
Provider fan-out¶
Each enabled provider runs as a job. A single provider runs inline. Multiple providers run concurrently, one worker thread each. Direct indexers additionally fan out across themselves in parallel with a bounded pool (at most four workers) and a fan-out deadline, so one slow indexer can't stall the search. Worker threads read settings from a snapshot taken up front, never from Kodi's settings API directly.
Result normalization¶
Every provider maps its response into one common shape:
| Field | Meaning |
|---|---|
title |
Release name (parsed for quality metadata) |
link |
Download URL for the NZB (the de-duplication key) |
size |
Size in bytes, as a string |
indexer |
Source indexer name |
pubdate |
Usenet post date, normalized to RFC-2822 |
age |
Human-readable age string |
Why pubdate is normalized to RFC-2822
Prowlarr reports ISO-8601 dates; Newznab reports RFC-2822. NeNeTeePee-Stream-Kodi normalizes everything to RFC-2822 because post date drives sorting, same-repost de-duplication, and the download ledger. An unparseable date sorts at the epoch, which is why the format contract matters.
De-duplication¶
Results are de-duplicated by download link: the first occurrence wins, and the add-on drops a result with no link as unplayable. The same release offered by two providers with different download URLs is intentionally kept as two rows, because they are genuinely different downloads.
Title parsing (PTT)¶
NeNeTeePee-Stream-Kodi parses each release title with a vendored copy of parse-torrent-title to extract resolution, HDR, audio, codec, group, languages, edition, year, and flags such as PROPER/REPACK. If the parser throws or returns nothing useful, a regular expression fallback extracts the essentials. The normalized metadata is cached on the result and reused by filtering, ranking, and fallback matching.
Requested episode only¶
An episode search doesn't trust the indexer to return only the episode it was asked for. An indexer that searches raw post subjects matches the show's name alone and returns every episode it has. Before filtering, NeNeTeePee-Stream-Kodi removes any result whose parsed name can't hold the requested episode. These results aren't marked as filtered: they appear in neither picker view.
A result stays when its name is one of these:
- the requested season and episode, or a multi-episode file that includes it
- a pack for the requested season, or a complete-series pack
- a daily show named by air date
Two kinds of name stay because they may still be the episode. The first is a video release whose episode number the parser can't read, as some anime names are written. The second is a bare episode number with no season, when it equals the requested episode or could be an absolute count for a later season.
For a show named by date, the TMDBHelper player passes the episode's air date and only that night's releases stay. If no release carries that exact date, releases dated one day either side stay. If none of those exist either, every dated release stays, so a metadata mismatch never empties the list.
An episode search also removes another show that was matched on something
other than its title: an episode titled like the show you asked for
(Sweet.Magnolias.S03E05.On.This.Foundation for Foundation), or a release
group of that name. A foreign-language title of the right show is kept, since
it has none of the requested words. Nothing is removed if the rule would take
more than half of the results. A show whose title is the requested one plus
more words (The Office Movers, Narcos Mexico), or another country's remake
(The.Office.PL), is listed below the requested show.
A movie search does the same by year. An indexer that can't search by id falls
back to the title, so a search for Avatar (2009) also returned Avatar: Fire
and Ash (2025). A result whose name is dated more than a year from the
requested year is removed, unless the requested year also appears in the name
(2001.A.Space.Odyssey.1968). A result with no year stays. A result that is
an episode of a show (The.Simpsons.S34E12) is removed too, unless it is a
special, which a movie entry can point at.
Filtering and ranking¶
Filtering applies your format, keyword, size, and excluded-group rules. Each format category has a default-enabled Other / Unknown option. A release with no Dolby Vision, HDR10, HDR10+, or HLG tag is SDR, tagged or not. Addon-owned tag normalization corrects audio families, HDR aliases, dimensions, and language names without editing vendored PTT. See Quality filtering.
filter_results() returns both the surviving rows and the full parsed list.
It tags every row with the first filter that rejected it, checked in this
order: resolution, HDR, audio, codec, language, keyword, group, size. The
max_results cap applies only to the filtered list.
Under Relevance sort, NeNeTeePee-Stream-Kodi orders results by this priority tuple:
flowchart LR
A[Resolution: highest first]
A --> P[CiNEPHiLES > FraMeSToR > other groups]
P --> G[Has a release group > none]
G --> B[HDR: DV > HDR10+ > HDR10 > HLG > SDR]
B --> R[Hybrid REMUX > REMUX > other]
R --> C[Preferred tier 1 > 2 > 3]
C --> D[Audio tier: lossless > Atmos on DD+ or lossy DTS:X > everything else]
D --> N[More NZB copies of the release]
N --> E[Size: larger wins]
The preferred tiers apply to all releases. Explicit size or age sorting bypasses the relevance priorities.
Tagging and the picker¶
When the picker is about to open, results already present in your download backend get a DL tag. A tag needs a name match plus a size match (and a consistent post date) against nzbdav's completed history, or NZBGet's history in NZBGet mode. In NZBGet mode the completed folder is checked too: a history item whose files were deleted gets no tag. An episode request can also get an already-downloaded season-pack row prepended (see Playback pipeline).
With Auto-select best match (skip result list) on (Sorting › Auto-Select),
the top filtered result plays straight away. There's no picker and no
picker-wide tagging pass. Otherwise,
results_dialog.py opens the full-screen picker on the filtered view. Each row
is labelled by release_display.display_name, which builds one normalized name
from the row's parsed metadata instead of showing the indexer's title.
The picker receives the unfiltered rows as well as the filtered ones. Pressing
C (context menu) switches between the filtered view and a show all
view. Rows that a filter rejected carry a FILTERED: <reason> chip naming that
filter. On Linux and CoreELEC, where results_input.py can read the OK-key
state from /dev/input, holding OK for five seconds also switches to
show-all. If nothing survives
filtering, the picker opens straight into show-all. NeNeTeePee-Stream-Kodi computes DL tags
over the full row set, so rows revealed by show-all keep them.
In the default List compacted view (results_view 0),
results_groups.release_groups folds the ranked rows into one row per release
with the same release_match.same_release rule the copies tiebreak and NZBGet
backups use. A row joins a group only when it matches every member, because the
rule isn't transitive. The group keeps the position of its best-ranked copy, and
selecting it plays the first copy with a DL tag, otherwise that best-ranked
copy. List (results_view 1) skips the grouping.
One grouping, four readers¶
release_index.build groups a result list once, and everything that needs to
know which rows are one release reads that grouping:
flowchart TD
P[filter._attach_metadata<br>once per list] --> X[release_index.build]
X --> C[Copy counts:<br>single copy last, more copies first]
X --> O[Odd-size check:<br>a copy 1.35x off its release's median]
X --> R[Picker rows:<br>results_groups.release_groups]
X --> B[NZBGet backups:<br>router_play._same_release_backups]
classDef step fill:#1E1E2E,stroke:#4A9EFF,color:#FFFFFF
classDef reader fill:#151520,stroke:#34D399,color:#FFFFFF
class P,X step
class C,O,R,B reader
Rows are only compared when they share the parsed release profile, the title
and the episode, and each distinct name is placed once, so a list of 2,500
rows is grouped in a few milliseconds. The grouping does not depend on the
order of the rows: a name that fits two releases goes with the one on more
rows. Rows with no release group are grouped by name instead
(release_subject.name_form_key); same_release itself still refuses them.
Two releases of one group that share an upload (the same film or episode at
the same exact size) are joined whole.
The metadata pass (filter._attach_metadata: parse, unify spellings, recover
a group the list knows, give a listing that lost its group the parse of its
upload's name in filter_payload, apply NFO and MediaInfo facts, share
Atmos) marks the rows
it handled. The requested-item rules and filter_results ask for it again
with the same rows and return at once. It runs again when a row is new, when
two lists were joined, or when nfo_audio.known_version() changed.
Parsing a name is the slow part of a first open (about half a millisecond a
name on a desktop, ten times that on a TV box). parse_store keeps what each
name parsed to in parsed_names.json in the profile folder, so a name seen in
an earlier search is not parsed again: 8,000 names at most, the least
recently used dropped first, and the file is thrown away when the add-on's
code changes. Only what a name parses to is kept; what later steps add from
other names or an NFO is worked out again for each list.
upload_count.count_copies counts a release's separate uploads for both the
ranking and the picker. It keeps the counted uploads of a size sorted by
date and compares a listing only with those inside its two-minute window.
Progress while it searches¶
On the TMDBHelper RunScript path, search_dialog.open_progress shows the
search progress window from the start of
title identification until the picker opens, and closes it on every early
return. The window is shown, not run modally (the modal DialogProgress
crashes Kodi mid-search on CoreELEC and Arctic Fuse), and a short-lived thread
redraws it while the add-on's own thread searches. Each step reports to the
active search_progress.Session: ID resolution, the provider fan-out, each
direct indexer's answer, the NFO and MediaInfo reads in nfo_audio, and the
filter, tag and picker steps. A report never raises and does nothing when no
window is shown.
NZBHydra2's Newznab answer doesn't say which indexers it asked.
hydra_history.report_indexers reads Hydra's record of the search just run
(POST /internalapi/history/searches, then
GET /internalapi/history/searches/details/{id}, with Hydra's XSRF token) and
matches the entry by source, IDs, season, episode and time. It fails soft to the
indexer names in the result rows.
Cancel sets a Home window property the drawing thread reads; the window closes at once, and the add-on stops after the request in flight, before the picker.
Caching¶
NeNeTeePee-Stream-Kodi caches the merged, pre-filter results on disk, keyed by a SHA-256 of the search type, title, year, season/episode, IDs, and the enabled provider set. That means:
- Re-opening the same title is instant within the cache duration (default 30 minutes, capped at 1440 minutes).
- A search made with different providers enabled never reuses another's entry.
- Changing filter or sort settings takes effect immediately. No new search needed, because filtering runs fresh on every read.
- Each entry also keeps the parsed details of every release name, so a repeat open skips the name parsing, the slowest step on a low-power box. Those details are reused only by the build that stored them: after an update, an entry is parsed once more and stored again.
- When the details were stored from one whole pass over the list, and nothing new has been read since from any of its releases' NFOs or MediaInfo, a repeat open also skips the rest of that pass (spellings, shared tags, shared Atmos): the stored details are what it would make.
- The cache self-limits to 70 MB and 1000 entries, evicting the oldest first, and writes atomically.
The plugin:// play and search routes and the TMDBHelper RunScript path all
use the cache. The RunScript path reads the cache duration through its XML
settings snapshot and resolves the cache folder from
special://profile/addon_data/, never through Kodi's add-on info API, which
can crash CoreELEC in that context.
Set Cache duration (minutes, 0=off) (Advanced › Search Cache) to
0 to turn off caching, or clear it any time from the add-on's main menu.
Next: the Playback pipeline.