feat(plex): actor filter AND/OR toggle (default OR) (S2)

Multiple selected actors now combine as OR (any) by default — click several cast
and see films featuring ANY of them — instead of the old hardcoded AND that
emptied the grid. An AND (all) toggle in the ACTIVE filter section (shown for 2+
actors, mirroring the genre match toggle) narrows to films with ALL of them.
Backend actor_mode param mirrors genre_mode. Verified: OR John Goodman|Douglas
M. Griffin = 11 films; AND = 1 (10 Cloverfield Lane). (Plex cast-explore S2)
This commit is contained in:
2026-07-19 03:37:57 +02:00
parent 0030f32a5d
commit 6f28ce36a7
3 changed files with 27 additions and 4 deletions
+7 -3
View File
@@ -373,8 +373,10 @@ def _meta_filter_conds(model, p: dict) -> list:
conds.append(model.added_at >= cutoff)
for d in _csv(p.get("directors")): # AND
conds.append(model.directors.contains([d]))
for a in _csv(p.get("actors")): # AND
conds.append(model.cast_names.contains([a]))
alist = _csv(p.get("actors"))
if alist: # AND (all) or OR (any) — default OR, mirroring genre_mode
ac = [model.cast_names.contains([a]) for a in alist]
conds.append(and_(*ac) if p.get("actor_mode") == "all" else or_(*ac))
stds = _csv(p.get("studios"))
if stds: # OR
conds.append(model.studio.in_(stds))
@@ -405,6 +407,7 @@ class LibraryFilters:
added_within: str | None = None
directors: str | None = None
actors: str | None = None
actor_mode: str = "any" # how multiple actors combine: any (OR, default) | all (AND)
studios: str | None = None
collection: str | None = None
@@ -415,7 +418,8 @@ class LibraryFilters:
"year_max": self.year_max, "rating_min": self.rating_min,
"duration_min": self.duration_min, "duration_max": self.duration_max,
"added_within": self.added_within, "directors": self.directors,
"actors": self.actors, "studios": self.studios, "collection": self.collection,
"actors": self.actors, "actor_mode": self.actor_mode,
"studios": self.studios, "collection": self.collection,
}