Skip to content

Keep parsed names between searches; a cached open lists what the first did - #590

Merged
xbmc4lyfe merged 3 commits into
mainfrom
parse-store
Nov 16, 2026
Merged

xbmc4lyfe merged 3 commits into
mainfrom
parse-store

Conversation

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator

Summary

Release names parsed in one search are kept for the next, so a first open of a search seen before (after its cache entry expired, or the next episode of a show) parses only new names. Also: a cached open now lists exactly what the first open listed, and a list is grouped once per open.

Measured on the 23-search corpus (tests/grouping_corpus.py), development machine:

Before After
First opens, all 23, names seen before 23.3 s 9.5 s
Cached opens, all 23 2,637 ms 2,359 ms
Searches whose cached open differed from the first 1 0

Changes

flowchart TD
    A[Row from a search] --> B{Name in parsed_names.json?}
    B -- yes --> C[Copy of the stored parse]
    B -- no --> D[Parse the name] --> E[Keep it for next time]
    C --> F[Spellings, list groups, payloads, NFO]
    E --> F
    F --> G[release_index.build once per open]
    G --> H[Copy counts and ranking]
    G --> I[Picker rows]
    G --> J[NZBGet backups]

    classDef step fill:#1E1E2E,stroke:#4A9EFF,color:#FFFFFF
    classDef ask fill:#151520,stroke:#FBBF24,color:#FFFFFF
    classDef done fill:#151520,stroke:#34D399,color:#FFFFFF
    class A,C,D,E,F,G step
    class B ask
    class H,I,J done
Loading
  • parse_store.py: name -> parse_title_metadata(name) in parsed_names.json in the profile folder, beside (not inside) the search cache's folder. At most 8,000 names (about 5 MB), least recently used dropped first; the file carries the code fingerprint the search cache already uses and is thrown away when the add-on changes. Written on a daemon thread; an unreadable file or folder means parsing as before. Only what a name parses to is stored, never what later steps add.
  • Cached open equals first open: _recover_list_groups counts only groups names state (not ones it or filter_payload added on an earlier pass); a recovered group reaches the name's other spellings in the same pass; the leading spelling's pinned identity title is set on its own rows too. tests/test_grouping_corpus.py now checks every search.
  • release_index.build reuses its grouping when the same rows, parses and metadata pass are grouped again (ranking, picker, backups), put in the new list's order with that grouping's NOGRP labels; the upload join skips sizes held by one release.

Testing

  • just test passes (5,198 passed, 2 skipped)
  • just lint passes, and the Python 3.8 compile gate
  • Tested in Kodi: not run on the box; timing it there is the next step, with your go
  • Updated CHANGELOG.md and docs-site/how-it-works/search-pipeline.md

The corpus picker rows change from 6,535 to 6,534: one Godzilla Minus One name now gets its recovered group on the first open, as it already did on a cached one.

🤖 Generated with Claude Code

…the first did

* parse_store keeps name -> parse in parsed_names.json in the profile
  folder (beside the search cache's folder, so the cache never evicts it):
  8,000 names at most, least recently used dropped first, thrown away when
  the add-on's code changes, written on a background thread, and every
  failure soft. On the 23-search corpus first opens go from 23.3 s to 9.5 s
  on the Mac.
* A cached open lists exactly what the first open listed: list-group
  recovery counts only groups names state, a recovered group reaches the
  name's other spellings in the same pass, and the leading spelling's
  pinned title is set on its own rows too. The corpus test now checks it.
* release_index reuses a grouping when the same rows with the same parses
  and pass are grouped again, in the new list's order and with its own size
  labels, and the upload join skips sizes held by one release. Cached opens
  2,637 -> 2,359 ms, same output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T19:22:23.443177Z 0bd8737 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-code-quality

github-code-quality Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Python

Python / code-coverage/pytest

main 7c5be15 parse-store 0bd8737 +/-
91% 92% +1%
View coverage of the 7 most impacted files.
File main 7c5be15 parse-store 0bd8737 +/-
repo/plugin.vid...es/lib/cache.py 92% 91% -1%
repo/plugin.vid...elease_index.py 99% 98% -1%
repo/plugin.vid...ib/nfo_audio.py 96% 96% 0%
repo/plugin.vid...s/lib/filter.py 96% 96% 0%
repo/plugin.vid...lter_payload.py 94% 96% +2%
repo/plugin.vid.../parse_store.py 0% 97% +97%
repo/plugin.vid...b/code_stamp.py 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 16, 2026 19:22 UTC

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4f105fadd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +134 to +135
keep = sorted(_NAMES.items(), key=lambda item: item[1][0], reverse=True)
keep = keep[:MAX_NAMES]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track recency within a day before evicting parsed names

Once 8,000 names have been used on the same UTC day, newly parsed names are immediately evicted: _today() assigns them all the same value, and this stable sort retains the earlier dictionary entries before the newly appended ones. Consequently, later searches repeatedly parse their names instead of benefiting from the persistent cache, even when those searches are more recent than the retained entries. For example, with MAX_NAMES=2 and a fixed day, parsing and saving A/B followed by C twice retains A/B and invokes the parser for C both times. Use a finer-grained timestamp or an access-order tie-breaker so recently used names survive eviction.

Useful? React with 👍 / 👎.

* The store keeps names in order of use, the most recent last, and trims
  the oldest: a full store kept the old names and dropped the day's new
  ones.
* Each write goes through a temporary file of its own, serialized on the
  background thread, and an older snapshot never replaces a newer one.
* The path is resolved when the write is queued, a RuntimeError from the
  profile lookup fails soft, and the code fingerprint moved to its own
  module (code_stamp) so the store does not import the search cache.
* The grouping reuse in release_index holds a lock: lists are filtered on
  worker threads too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread tests/test_parse_store.py
break
time.sleep(0.01)

_path, (_stamp, entries), _number = write.call_args.args
Comment thread tests/test_parse_store.py
break
time.sleep(0.01)

_path, (_stamp, entries), _number = write.call_args.args
if tmp_path is not None:
try:
os.remove(tmp_path)
except OSError:
* A hit always marks the store for writing, so a run of repeat searches
  keeps its names ahead of the next run's new ones.
* The write counters keep counting after forget(), so a writer still
  running from before cannot outrank later writes.
* Temporary files left by a write cut short are removed after an hour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
if tmp_path is not None:
try:
os.remove(tmp_path)
except OSError:
@xbmc4lyfe
xbmc4lyfe merged commit 21204cb into main Nov 16, 2026
15 checks passed
@xbmc4lyfe
xbmc4lyfe deleted the parse-store branch November 16, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant