Repository navigation
Conversation
mjc
force-pushed
the
batch-media-sync-lookups
branch
from
October 20, 2026 13:56
58cb0d5 to
c6ac594
Compare
…ield to series snapshot
…s to use typed Series snapshot
mjc
force-pushed
the
batch-media-sync-lookups
branch
from
October 21, 2026 14:47
c6ac594 to
d91f880
Compare
mjc
marked this pull request as draft
October 21, 2026 16:50
mjc
force-pushed
the
batch-media-sync-lookups
branch
from
October 21, 2026 22:56
d91f880 to
61e088c
Compare
Validate JSON directly into slotted dataclasses. Preserve strict fields, scalar conversions, incomplete records and Requests JSON error handling, and replace the msgspec dependency with the vendored Pydantic version.
Search for nonstandard number literals before checking their separators. Avoid a full-buffer regex scan and keep titles containing Infinity or NaN on the typed decoder path.
Probe the selected Requests JSON parser once. Keep the compatibility check for rejecting backends and avoid scanning response buffers when both parsers accept nonstandard numbers.
Keep numeric-string and float conversions as fallbacks. Share byte-count conversion with incomplete movie recovery and cover large integers and floating-point truncation.
Validate movie recovery facts directly, use native defaults for invalid fields and payloads, and avoid reparsing JSON after record validation fails. Keep overview strings on the native validation path.
mjc
force-pushed
the
batch-media-sync-lookups
branch
from
October 22, 2026 17:23
61e088c to
4e5ccad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #3670. Once that merges, this PR will show only the lookup changes.
Sonarr and Radarr sync load movie and episode rows before processing the response, then query some of the same values again for each record. Reuse those rows for previous file IDs and paths, movie and episode monitored state, and the series audio-language fallback.
Also remove repeated work in the same loops:
Movie updates still happen as each record is processed. Bulk updates require the file ID and path to match the loaded values; if another update has replaced the file, the stale write is skipped so the newer file and subtitle index are kept. Monitored-state checks use the loaded rows; changes made by another sync are picked up on the next run. Tag and STRM settings are read during processing.
Measurements
These SQLite fixtures contain 205 records with changed titles. They run the sync functions and parsers with HTTP, subtitle indexing and events stubbed. Both versions perform 205 updates in each changed-record fixture and no updates when every movie is already unmonitored. Stored values match, excluding timestamps. The subtitle-search fixture also queues the same episode IDs.
For 205 undersized files, filesystem size checks fall from 410 to 205 in both movie and episode sync.
The tag/profile comparison parses 1,000 records against 500 tags and 100 profiles, with three tags per record. It includes building the indexes and uses the legacy audio-profile fallback. Median time across five runs is listed below; parsed values match.
Tests
Tests check query counts as the library grows, null audio-language fallbacks and fresh state on the next sync, monitored-state refresh between syncs, new unmonitored movies, duplicate movie records, changed-file indexing, insert collisions, and cancellation after completed writes. Search tests cover retry windows, exclusions, and missing subtitles discovered during indexing. File tests check one filesystem lookup per undersized file, STRM handling, and standalone parsing when a file is absent. Tag/profile tests cover ordering, duplicates, ID matching, and settings changes during processing.
Concurrent replacement tests change the file ID, path, or both after rows are loaded, then check that stale writes and their update events are skipped. Episode tests also check that skipped updates do not schedule subtitle searches.
The sync test fixtures now supply previous-file state and numeric job IDs. Changed production functions have parameter and return annotations.