Skip to content

refactor(crossseed): improve anime handling#1882

Open
Audionut wants to merge 15 commits into
developfrom
refactor/crossseed-anime
Open

refactor(crossseed): improve anime handling#1882
Audionut wants to merge 15 commits into
developfrom
refactor/crossseed-anime

Conversation

@Audionut
Copy link
Copy Markdown
Contributor

@Audionut Audionut commented May 14, 2026

Summary by CodeRabbit

  • New Features

    • Broader cross-seed matching for TV (including anime-style cases) and improved title normalization for decorative symbols and punctuation.
  • Bug Fixes

    • Treat cache read cancellations/timeouts as immediate errors.
    • Fix category deduplication/compaction in Torznab search parameters.
  • Improvements

    • Enhanced release-filter diagnostics and refined TV source-release inference from file structure.
    • Canonicalized category handling, quieter trace-level logging, and redacted URLs in RSS/middleware logs.
  • Tests

    • Expanded coverage across matching, normalization, inference, categories, webhooks, cache cancellation, and logger redaction.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f09db5d5-21fc-4168-9f47-09c10d43cdbb

📥 Commits

Reviewing files that changed from the base of the PR and between 4bdc9c0 and 4b9a8d1.

📒 Files selected for processing (5)
  • internal/api/middleware/logger.go
  • internal/api/middleware/logger_test.go
  • internal/services/crossseed/batch_matching.go
  • internal/services/crossseed/batch_matching_test.go
  • internal/services/crossseed/service.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/services/crossseed/service.go

Walkthrough

Refactors crossseed title/TV matching and search filtering (title-overlap, AKA parsing, seasonless-anime inference, structured rejection reasons), extends NormalizeForMatching to handle commas and decorative anime symbols, canonicalizes Jackett category slices, propagates context-cancellation from ARR cache reads, and makes several logging-verbosity and test-only improvements.

Changes

Crossseed matching, TV inference, and search diagnostics

Layer / File(s) Summary
Title normalization and matching primitives
pkg/stringutils/unicode.go, pkg/stringutils/unicode_test.go
NormalizeForMatching now converts commas to spaces and maps decorative anime symbols (★, ☆, ・, ♪, etc.) to spaces; tests added/expanded to validate punctuation/symbol normalization and real-world equivalences.
Name-aware release matching and validators
internal/services/crossseed/matching.go, internal/services/crossseed/matching_title_test.go, internal/services/crossseed/matching_anime_test.go, internal/services/crossseed/matching_forbidden_pairs_test.go
Replaced strict normalized-title equality with normalized-title set overlap; introduced AKA-aware title sets and updated title/artist/date/group/site/collection/format validation paths; adjusted TV classification helpers to incorporate Type and anime-style seasonless cases; tests expanded for AKA parsing, punctuation variants, and site/group interactions.
TV source-release inference and selection
internal/services/crossseed/source_release_inference.go, internal/services/crossseed/source_release_inference_test.go
Inference extended to detect seasonless episode files and distinct absolute episode counts, adds guard against year-bearing movie inference, prioritizes pack detection when appropriate, and adjusts search-release selection/merge logic; consolidated and added tests validating pack/episode/seasonless behaviors and search-selection identity preservation.
Search candidate filtering diagnostics
internal/services/crossseed/service.go
Search filtering now uses releasesMatchWithReasonAndNames to obtain boolean + reason, records aggregated rejection reasons keyed by reason+debug release info, and emits a rejection-summary debug log after filtering. New internal helpers added to build debug info and record reasons.
New focused TV matching tests
internal/services/crossseed/matching_unknown_season_tv_test.go
Added table-driven tests covering unknown-season TV matching scenarios (pack vs episode, group/site conflicts, individual-episode gating) asserting match boolean and textual reason.

Operational behavior, logging, tests, and Jackett category handling

Layer / File(s) Summary
ARR cache error propagation and tests
internal/services/arr/service.go, internal/services/arr/service_test.go
LookupExternalIDs now returns context.Canceled and context.DeadlineExceeded from cache reads instead of treating them as cache misses; added DB-backed in-memory test harness and a table-driven test asserting cancellation/deadline behavior.
Jackett category canonicalization and tests
internal/services/jackett/service.go, internal/services/jackett/service_test.go
Category ID slices are canonicalized (sorted/deduplicated) at mapping, parsing, filtering, and search-parameter construction points; tests added to validate deduplication, parent-fallback compaction, and search-param building behavior.
Dir-scan webhook test refactor
internal/api/handlers/dirscan_webhook_test.go
Replaced hand-written JSON request bodies with typed webhook payload structs and a dirScanWebhookJSONBody helper that marshals payloads to *bytes.Reader; updated multiple webhook tests accordingly and switched imports (stringsbytes).
Logging verbosity tweaks
internal/api/handlers/torrents.go, internal/qbittorrent/sync_manager.go, internal/services/automations/service.go
Selected debug logs downgraded to trace (request-parameter logging, intermediate filtering messages, “no actions to apply”, and other detailed filtering/cache messages); no behavior changes.
RSS and crossseed debug redaction
internal/api/handlers/rss.go, internal/services/crossseed/service.go
Redact URL/GUID-like strings in debug/error/warning logs via redact.URLString(...) to avoid logging raw URLs/GUIDs.
Test robustness improvements
internal/services/automations/hardlink_index_test.go
Replaced hardcoded hardlink.FileID literals with actual filesystem-created files via createFile/t.TempDir() to obtain valid hardlink.FileID values in multiple tests.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • autobrr/qui#718: Related punctuation/normalization and title-matching helpers.
  • autobrr/qui#742: Related NormalizeForMatching changes used by crossseed matching.
  • autobrr/qui#1871: Overlaps with releasesMatchWithReason refactor and TV inference adjustments.

Suggested labels

refactor, cross-seed, tests, backend, area/backend

Suggested reviewers

  • s0up4200

Poem

🐇
I hop through titles, commas turned to air,
Stars and symbols smoothed into a space,
Packs and episodes find their careful place,
Logs whisper quieter as traces hum,
And categories march tidy, one by one.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(crossseed): improve anime handling' directly addresses the main scope of changes, which involve extensive updates to anime release detection, matching heuristics, and cross-seed matching logic throughout the crossseed service.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/crossseed-anime

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant