-
Notifications
You must be signed in to change notification settings - Fork 0
Fix title-to-slug resolution so generic token overlap no longer picks unrelated shows #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix title-to-slug resolution so generic token overlap no longer picks unrelated shows, and prefer high-confidence exact/near-exact matches across providers. This resolves false matches where The Rookie and Rick and Morty could not be found or were mapped to wrong entries (for example the anime variant). Also add tvsearch fallback resolution when Sonarr sends IDs without `q` by deriving the canonical show title from tvdb/tmdb/imdb via SkyHook before slug matching. Adds regression tests for: - precise matching over weak shared-token matches - low-confidence match rejection - tvsearch ID-based query fallback without `q`
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds identifier-based TV show title resolution to the Torznab API using SkyHook lookups and URL-encoding; and replaces token-intersection slug matching with a tokenized scoring-based title matcher to improve slug resolution confidence. Changes
Sequence DiagramsequenceDiagram
participant Client as Client
participant TorznabAPI as Torznab API
participant Resolver as Query Resolver
participant SkyHook as SkyHook API
participant RSS as RSS Builder
Client->>TorznabAPI: tvsearch (season, ep, maybe tvdbid/tmdbid/imdbid, no q)
TorznabAPI->>Resolver: _resolve_tvsearch_query_from_ids(tvdbid, tmdbid, imdbid)
alt Direct tvdbid present
Resolver->>Resolver: lookup tvdbid -> title
Resolver-->>TorznabAPI: title
else tmdbid/imdbid provided
Resolver->>SkyHook: search (tmdbid/imdbid) [http_get]
SkyHook-->>Resolver: search results
Resolver->>SkyHook: get show details (extract tvdb_id)
SkyHook-->>Resolver: show details with tvdb_id/title
Resolver-->>TorznabAPI: title
else Resolution fails
Resolver-->>TorznabAPI: None
end
TorznabAPI->>TorznabAPI: slug_from_query (token scoring) or return empty RSS
TorznabAPI->>RSS: build feed
RSS-->>TorznabAPI: RSS XML
TorznabAPI-->>Client: HTTP 200 + RSS
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR tightens TV series title resolution for Torznab tvsearch by (1) resolving missing q via ID hints (tvdb/tmdb/imdb) and (2) improving slug matching to avoid false positives from generic token overlap, with new tests covering both behaviors.
Changes:
- Add SkyHook-based fallback to derive
qfromtvdbid/tmdbid/imdbidwhenqis missing intvsearch. - Replace token-overlap-only title matching with a weighted scoring function + minimum confidence threshold.
- Add unit tests for the new ID-based fallback behavior and improved title/slug selection.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
app/api/torznab/api.py |
Adds _resolve_tvsearch_query_from_ids and uses it to derive q for tvsearch when missing. |
app/utils/title_resolver.py |
Introduces stopword-filtered tokenization + candidate scoring and a minimum confidence threshold. |
tests/test_torznab.py |
Adds a test ensuring tvsearch uses the ID-resolved query when q is missing. |
tests/test_title_resolver_sto.py |
Adds tests ensuring the resolver prefers precise matches and rejects low-confidence overlaps. |
uv.lock |
Bumps the local package version to 2.4.1. |
This comment was marked as resolved.
This comment was marked as resolved.
Docstrings generation was requested by @Zzackllack. * #67 (comment) The following files were modified: * `app/api/torznab/api.py` * `app/utils/title_resolver.py` * `tests/test_torznab.py`
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
anibridge-docs | 0bd8a63 | Feb 11 2026, 05:31 PM |
Docstrings generation was requested by @Zzackllack. * #67 (comment) The following files were modified: * `app/api/torznab/api.py` * `app/utils/title_resolver.py` * `tests/test_torznab.py`
Add caching mechanisms for TVDB IDs and titles in the SkyHook search to improve performance and reduce redundant API calls. This includes functions to get and set cached values with a time-to-live (TTL) and a maximum number of entries to maintain. Also, optimize title scoring logic to enhance matching accuracy.
Description
This pull request improves the reliability and precision of TV series title resolution in Torznab TV search queries, especially when the query (
q) parameter is missing but identifier hints (liketvdbid,tmdbid, orimdbid) are provided. It introduces a new fallback mechanism to resolve missing queries via external lookups, enhances the title matching algorithm to reduce false positives, and adds comprehensive tests to verify the new behaviors.Type of Change
Testing
Screenshots (if applicable)
Additional Notes
Torznab API improvements:
qparameter intvsearchrequests using identifier hints (tvdbid,tmdbid,imdbid) via Sonarr's SkyHook API, improving compatibility with clients that rely on ID-based lookups. (app/api/torznab/api.py[1] [2] [3] [4]_coerce_positive_intand_resolve_tvsearch_query_from_idsfor robust identifier parsing and external lookups. (app/api/torznab/api.pyapp/api/torznab/api.pyR66-R142)Title resolution and matching algorithm enhancements:
slug_from_queryto use a new scoring function based on token overlap, precision/recall, normalized string similarity, and substring/exact checks. This reduces false matches and ensures only high-confidence matches are accepted. (app/utils/title_resolver.py[1] [2] [3] [4]app/utils/title_resolver.py[1] [2] [3]Testing improvements:
qis missing. (tests/test_title_resolver_sto.py[1]tests/test_torznab.py[2]Summary by CodeRabbit
New Features
Bug Fixes / Behavior
Tests