Skip to content

feat: support Sonarr and Radarr custom filters - #179

Merged
retransmit merged 6 commits into
retransmit:developmentfrom
Bhavyashah94:feat/custom-filters
Oct 7, 2026
Merged

retransmit merged 6 commits into
retransmit:developmentfrom
Bhavyashah94:feat/custom-filters

Conversation

@Bhavyashah94

@Bhavyashah94 Bhavyashah94 commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds support for user-defined Sonarr and Radarr custom filters in the Movies and Series filter bottom sheets, resolving #177.

Changes

1. Data Models & API

  • Radarr (service_radarr):
    • Added RadarrCustomFilter model (id, type, label, filters) representing /api/v3/customfilter.
    • Added getCustomFilters() to RadarrApi.
    • Added radarrCustomFiltersProvider and radarrActiveCustomFilterProvider.
  • Sonarr (service_sonarr):
    • Reused existing generated CustomFilterResource model for /api/v3/customfilter.
    • Added getCustomFilters() to SonarrApi.
    • Added sonarrCustomFiltersProvider and sonarrActiveCustomFilterProvider.

2. Custom Filter Evaluation Engine

  • Implemented matchesRadarrCustomFilter and matchesSonarrCustomFilter supporting:
    • Servarr filter operators: equal, notEqual, contains, notContains, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, startsWith, endsWith, in, notIn.
    • Unwraps array-wrapped values (e.g. [0], [2020], ["English"]) as returned by the Servarr custom filter APIs.
    • Target fields for movies and series including download/file status (hasFile, episodeFileCount, episodeCount, missing), monitoring status (monitored), status (status), year (year), genres (genres), size on disk (sizeOnDisk), tags, and quality profiles.
    • Multi-condition logical AND rules matching web UI behavior.

3. UI Integration

  • In MoviesTab (_SortFilterBottomSheet) and SeriesTab (_SortFilterBottomSheet):
    • Fetches custom filters and displays them as selectable chips alongside standard filters.
    • Toggling is mutually exclusive: selecting a custom filter clears any standard filter and vice-versa. Deselecting an active custom filter falls back cleanly to "All".

Screenshots

Radarr Custom Filters

Filter Bottom Sheet Filtered Library Grid

Sonarr Custom Filters

Filter Bottom Sheet Filtered Library Grid

Verification

  • Automated Tests:
    • services/service_radarr/test/radarr_custom_filter_test.dart: 7 tests verifying operator logic, multi-rule evaluation, array-wrapped API values, and edge cases.
    • services/service_sonarr/test/sonarr_custom_filter_test.dart: 7 tests verifying operator logic, series properties, array-wrapped API values, and edge cases.
    • All test suites passing (flutter test services/service_radarr, flutter test services/service_sonarr).
    • Analyzer clean (dart analyze services/service_radarr services/service_sonarr reported 0 issues).
  • Live Server & Device Verification:
    • Tested on live Sonarr and Radarr server backends via Android emulator (Pixel_7_API_35).
    • Verified custom filter chips ("Downloaded Movies" and "Downloaded Shows") appear in the filter bottom sheets and filter movie and series library grids in memory correctly.

Closes #177

- Fetch custom filters from /api/v3/customfilter in Sonarr and Radarr API clients
- Add custom filter evaluators supporting Servarr operators (equal, notEqual, contains, notContains, greaterThan, lessThan, list comparisons, etc.)
- Expose custom filter providers and integrate client-side filtering in filtered series and movies providers
- Render custom filter chips in the Sort & Filter bottom sheet alongside standard filters with mutually exclusive selection
- Add comprehensive unit test suites covering operators, edge cases, and custom filter evaluations for both Sonarr and Radarr
Bhavyashah94 and others added 5 commits October 7, 2026 17:59
…d judges them

The evaluator now follows the series list's own filter rule for rule, so
that a custom filter shows the same series here as it does in Sonarr:

- the filter builder saves a rule's value as a list of alternatives. Each
  is tested on its own and any one is enough, except under notEqual and
  notContains, where none may match. The ordering tests and the starts and
  ends tests looked at the first value alone
- the relative date rules ("in the last 30 days") are measured from now.
  They fell through to an equality check that never matched. A series
  with no such date passes none of the date rules, where "before" used to
  let it through
- the keys Sonarr works a value out for are worked out the same way:
  episode progress, rating as a percentage, rating votes, original
  language, release groups, season count, missing season and seasons
  monitored
- equal is exact, case included
- a rule that cannot be tested rejects the series: an unknown key, a row
  left empty, or a property the server left out

SonarrSeries gains the properties those rules read: quality profile, root
folder, tags, scene numbering, ratings, original language, and the release
groups in its statistics.

The provider hands back only the filters saved for the series list, by
label as Sonarr's own menu orders them, so the sheet no longer sorts them
out itself.

The tests use rules in the shape the server sends them. The one on
episodeFileCount goes: Sonarr has no filter key of that name, and its own
page shows nothing for a rule on it.
…d judges them

The evaluator now follows the movie list's own filter rule for rule, so
that a custom filter shows the same movies here as it does in Radarr:

- the filter builder saves a rule's value as a list of alternatives. Each
  is tested on its own and any one is enough, except under notEqual and
  notContains, where none may match. The ordering tests and the starts and
  ends tests looked at the first value alone
- the relative date rules ("in the next 6 months") are measured from now.
  They fell through to an equality check that never matched. A movie with
  no such date passes none of the date rules, where "before" used to let
  it through
- the keys Radarr works a value out for are worked out the same way: the
  collection by its title, original language, release groups, the
  qualities of its files, size on disk from the statistics, and the TMDb,
  IMDb, Rotten Tomatoes and Trakt ratings and votes
- equal is exact, case included
- a rule that cannot be tested rejects the movie: an unknown key, a row
  left empty, or a property the server left out

RadarrMovie gains the properties those rules read: original title,
availability, minimum availability, quality profile, keywords, popularity,
tags, its statistics and the Trakt rating.

The provider hands back only the filters saved for the movie list
(movieIndex, or the movies section it belongs to), by label as Radarr's
own menu orders them, so the sheet no longer sorts them out itself.

The tests use rules in the shape the server sends them.
@retransmit

Copy link
Copy Markdown
Owner

Thanks, putting the saved filters beside the built-in chips with one active at a time fits the sheet well.

I pushed some changes to your branch, on top of your second commit:

Fixes

  • A list value was unwrapped to its first entry. The web UI passes a rule when any of its values does, and when none does under notEqual and notContains, so each value is now tested on its own.
  • The relative date rules ("in the last 30 days") are saved as {"time": "days", "value": 30} and fell through to an equality check, so they matched nothing. They are measured from now, and an item with no such date passes none of the date rules, as in the web UI.
  • The keys the web UI works a value out for came back empty: Sonarr's rating, rating votes, original language, release groups, missing season and seasons monitored, and Radarr's TMDb, IMDb, Rotten Tomatoes and Trakt ratings and votes, release groups and file qualities. The models were also missing tags, quality profile, root folder and a few others the builder offers, so rules on those matched nothing.
  • equal is exact, as in the web UI. It ignored case and read text as numbers.
  • A rule that cannot be tested rejects the item, as in the web UI: an unknown key, a row left empty, or a property the server left out. notEqual on a series with no certification used to pass. That covers episodeFileCount too, which is not a key Sonarr filters on (its own page shows nothing for a rule on it), so the test for list values is on sizeOnDisk now.

Changed

  • Both evaluators follow the web UI's own filter (createClientSideCollectionSelector and the filterPredicates of the series and movie lists) rule for rule.
  • The provider returns only the filters saved for the list, in the order the web UI's menu has them, and the sheet no longer sorts them out by type. Radarr's are movieIndex or movies, Sonarr's series or seriesIndex.
  • The branch has development merged in, since the model changes sit on top of the collection work.

Added

  • Tests on rules in the shape the servers send them, and one for each tab that opens the sheet and picks a filter.
  • README, STATUS.md and the site mention the custom filters.

@retransmit
retransmit merged commit 94c2376 into retransmit:development Oct 7, 2026
1 check passed
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.

[Feature]: Sonarr/Radarr Custom Filters

2 participants