From c577d7005a171071133a7794934c797c04a7078a Mon Sep 17 00:00:00 2001 From: pax Date: Sun, 5 Apr 2026 19:00:03 -0500 Subject: [PATCH] =?UTF-8?q?Add=20Animated=20checkbox=20=E2=80=94=20filters?= =?UTF-8?q?=20to=20only=20show=20video/gif/animated=20posts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Client-side filter by file extension. Works with backfill and infinite scroll. Unchecked shows everything, checked shows only gif/mp4/webm/mkv/mov/zip(ugoira). --- booru_viewer/gui/app.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/booru_viewer/gui/app.py b/booru_viewer/gui/app.py index e8d4f23..f62619b 100644 --- a/booru_viewer/gui/app.py +++ b/booru_viewer/gui/app.py @@ -325,6 +325,11 @@ class BooruApp(QMainWindow): score_up.clicked.connect(lambda: self._score_spin.setValue(self._score_spin.value() + 1)) top.addWidget(score_up) + from PySide6.QtWidgets import QCheckBox + self._animated_only = QCheckBox("Animated") + self._animated_only.setToolTip("Only show animated/video posts") + top.addWidget(self._animated_only) + self._search_bar = SearchBar(db=self._db) self._search_bar.search_requested.connect(self._on_search) self._search_bar.autocomplete_requested.connect(self._request_autocomplete) @@ -619,12 +624,16 @@ class BooruApp(QMainWindow): bl_tags = set(self._db.get_blacklisted_tags()) bl_posts = self._db.get_blacklisted_posts() shown_ids = getattr(self, '_shown_post_ids', set()).copy() + animated_only = self._animated_only.isChecked() + _ANIM_EXTS = {".gif", ".mp4", ".webm", ".mkv", ".mov", ".avi", ".zip"} def _filter(posts): if bl_tags: posts = [p for p in posts if not bl_tags.intersection(p.tag_list)] if bl_posts: posts = [p for p in posts if p.file_url not in bl_posts] + if animated_only: + posts = [p for p in posts if Path(p.file_url.split("?")[0]).suffix.lower() in _ANIM_EXTS] posts = [p for p in posts if p.id not in shown_ids] return posts @@ -731,12 +740,16 @@ class BooruApp(QMainWindow): bl_tags = set(self._db.get_blacklisted_tags()) bl_posts = self._db.get_blacklisted_posts() shown_ids = getattr(self, '_shown_post_ids', set()).copy() + animated_only = self._animated_only.isChecked() + _ANIM_EXTS = {".gif", ".mp4", ".webm", ".mkv", ".mov", ".avi", ".zip"} def _filter(posts): if bl_tags: posts = [p for p in posts if not bl_tags.intersection(p.tag_list)] if bl_posts: posts = [p for p in posts if p.file_url not in bl_posts] + if animated_only: + posts = [p for p in posts if Path(p.file_url.split("?")[0]).suffix.lower() in _ANIM_EXTS] # Skip posts already shown on previous pages posts = [p for p in posts if p.id not in shown_ids] return posts