aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGravatar Qetesh <4559341+Qetesh@users.noreply.github.com> 2024-10-12 01:21:11 +0800
committerGravatar GitHub <noreply@github.com> 2024-10-12 01:21:11 +0800
commit999afd4adb73540e6def7b02e110e76a515ae169 (patch)
tree1deb2b9ed46ec962d4d7bbb4d773b6cb7e699243 /core
parente775f7b66c52cc2096938bfa2265a25248a3a7da (diff)
parent92fa74553341d4cdac134b0cafdaf16fa94b3afa (diff)
downloadminiflux-ai-999afd4adb73540e6def7b02e110e76a515ae169.tar.gz
miniflux-ai-999afd4adb73540e6def7b02e110e76a515ae169.tar.zst
miniflux-ai-999afd4adb73540e6def7b02e110e76a515ae169.zip
Merge pull request #4 from Qetesh/deny-allow-list-wildcard-urlv0.6.1
support Deny-/allow list wildcard url
Diffstat (limited to 'core')
-rw-r--r--core/__init__.py0
-rw-r--r--core/entry_filter.py31
2 files changed, 31 insertions, 0 deletions
diff --git a/core/__init__.py b/core/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/core/__init__.py
diff --git a/core/entry_filter.py b/core/entry_filter.py
new file mode 100644
index 0000000..62ab9f5
--- /dev/null
+++ b/core/entry_filter.py
@@ -0,0 +1,31 @@
+import fnmatch
+
+def filter_entry(config, agent, entry):
+ start_with_list = [name[1]['title'] for name in config['agents'].items()]
+ style_block = [name[1]['style_block'] for name in config['agents'].items()]
+ [start_with_list.append('<pre') for i in style_block if i]
+
+ # Todo Compatible with whitelist/blacklist parameter, to be removed
+ allow_list = agent[1].get('allow_list') if agent[1].get('allow_list') is not None else agent[1].get('whitelist')
+ deny_list = agent[1]['deny_list'] if agent[1].get('deny_list') is not None else agent[1].get('blacklist')
+
+ # filter, if not content starts with start flag
+ if not entry['content'].startswith(tuple(start_with_list)):
+
+ # filter, if in allow_list
+ if allow_list is not None:
+ if any(fnmatch.fnmatch(entry['feed']['site_url'], pattern) for pattern in allow_list):
+ return True
+
+ # filter, if not in deny_list
+ elif deny_list is not None:
+ if any(fnmatch.fnmatch(entry['feed']['site_url'], pattern) for pattern in deny_list):
+ return False
+ else:
+ return True
+
+ # filter, if allow_list and deny_list are both None
+ elif allow_list is None and deny_list is None:
+ return True
+
+ return False