custom_folders: add category / not_category filter primitives#262
Open
jakeyr wants to merge 1 commit into
Open
custom_folders: add category / not_category filter primitives#262jakeyr wants to merge 1 commit into
jakeyr wants to merge 1 commit into
Conversation
Adds `category` and `not_category` filter primitives to the Virtual
Folders feature. Lets a virtual folder scope to torrents added by a
specific *arr without inventing any out-of-band metadata: the qBit
category set by the *arr at add time is already a hot field on
IndexEntry (set in pkg/server/qbit/http.go).
Concretely, this unblocks per-arr virtual folder configs like:
"custom_folders": {
"sonarr": {"filters": {"category": "tv-sonarr"}},
"radarr": {"filters": {"category": "radarr"}},
"whisparr": {"filters": {"category": "backup"}}
}
Changes:
- Expose Category on EntryMetaInfo (already a hot field on IndexEntry).
- Thread category through matchesFilter/checkSingleFilter (5th param).
- Add filterByCategory and filterByNotCategory case branches.
- Update the only call site in pkg/manager/entry.go to pass meta.Category.
- Table tests covering: simple match/mismatch, empty-category rejection,
not_category positive/negative, and category in an AND-stack with
another primitive (include).
All 9 new test cases pass; rest of the test suite unaffected.
Owner
|
Nice work @jakeyr But this needs to be added to the UI as well. |
|
Ah! I could see "Filter key (e.g. name, category)" is listed in an empty input in the Virtual Folder filter, but I couldn't get it to work. Thought I was doing it wrong. +1 for this being added |
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.
Summary
Adds two filter primitives —
categoryandnot_category— to the Virtual Folders feature, letting a folder scope to torrents added by a specific *arr without any out-of-band metadata.The qBit category set by the *arr at torrent-add time is already a hot field on
IndexEntry(populated inpkg/server/qbit/http.go). This change just exposes it to the existing virtual-folder filter chain.Why
A common ask is "show me only the torrents Sonarr added" or "everything Radarr added except 4K" as a virtual folder. The metadata is already there; the filter language just couldn't reference it.
With this PR, configs like the following work:
categoryinteracts cleanly with the existing AND-stack — e.g. a "Sonarr + 2160p" folder is just{ "category": "tv-sonarr", "include": "2160p" }.What changed
pkg/manager/custom_folders.go— two new filter constants (filterByCategory,filterByNotCategory);matchesFilterandcheckSingleFiltertake a newcategoryparameter; two case branches do exact-match / negated-match against the torrent'sCategory.pkg/storage/entry.go— surfaceCategoryonEntryMetaInfoso the metadata-only iterator (ForEachMeta) can pass it without a disk read. The field is already onIndexEntry, so no new state.pkg/manager/entry.go— the single call site ingetCustomFolderChildrenpassesmeta.Category.pkg/manager/custom_folders_test.go— table tests for: simple match / mismatch, empty-category rejection (an empty Category never matches a non-empty filter),not_categorypositive + negative, and category in an AND-stack withinclude(Sonarr+2160p match, Sonarr+1080p reject, Radarr+2160p reject, empty+2160p reject).Empty-category behavior is intentional and tested: a torrent with no category never matches a
category: "X"filter ("" == "tv-sonarr"is false), so older torrents that predate qBit category tracking simply don't show up in category-filtered folders — they remain visible under__all__, the per-provider folder, and any non-category virtual folder.Test plan
go test ./pkg/manager/... -run TestMatchesFilterCategory— all 9 new cases passgo test ./...— full suite greensonarrfolder (filtercategory: tv-sonarr) returned 394 torrentsradarrfolder (filtercategory: radarr) returned 69 torrentstorrents.jsonto confirm the category labels matchNotes for the reviewer
categoryparameter is threaded throughmatchesFilter/checkSingleFilter— there is exactly one call site (the metadata-only iterator ingetCustomFolderChildren), and the signature change is local to the manager package.IndexEntry.Categoryfor entries created before this field was tracked, by reading qBit'storrents.json. That's not part of this PR — happy to send it as a follow-up if it's useful upstream.