From 33e8353b4ef532e45b7f3845b6431871b798a069 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Wed, 11 Dec 2024 00:38:43 +0100
Subject: [PATCH] Treat tag filter input fields as OR of comma-delimited terms.

---
 src/ytplom/misc.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/ytplom/misc.py b/src/ytplom/misc.py
index 90c5e3e..e3d3728 100644
--- a/src/ytplom/misc.py
+++ b/src/ytplom/misc.py
@@ -305,11 +305,18 @@ class VideoFile(DbData):
                      show_absent: bool = False
                      ) -> list[Self]:
         """Return cls.get_all matching provided filter criteria."""
-        return [f for f in cls.get_all(conn)
+        filtered_before_tags = [
+                f for f in cls.get_all(conn)
                 if str(filter_path).lower() in str(f.rel_path).lower()
-                and ([t for t in f.tags if str(filter_tags).lower() in t]
-                     or not filter_tags)
                 and (show_absent or f.present)]
+        if filter_tags:
+            tags_or = filter_tags.split(',')
+            filtered_after_tags = set()
+            for f in filtered_before_tags:
+                for t in [t for t in tags_or if t in f.tags]:
+                    filtered_after_tags.add(f)
+            return list(filtered_after_tags)
+        return filtered_before_tags
 
     def unused_tags(self, conn: BaseDbConn) -> set[Tag]:
         """Return tags used among other VideoFiles, not in self."""
-- 
2.30.2