added logic for filtering based on diff attributes

This commit is contained in:
bwees
2022-07-11 20:35:30 -04:00
parent bdab4f5e09
commit 83565787ae
+19
View File
@@ -4,6 +4,7 @@ import os
import re
import time
import urllib3
import difflib
from changedetectionio import content_fetcher, html_tools
@@ -276,11 +277,29 @@ class perform_site_check():
else:
logging.debug("check_unique_lines: UUID {} had unique content".format(uuid))
diff_filters = {
"add": watch.get('trigger_on_add', True),
"del": watch.get('trigger_on_del', True),
"modify": watch.get('trigger_on_modify', True)
}
if False in diff_filters.values(): # if we are supposed to filter any diff types
print(">>>>>>>>>>>> Filtering diffs")
# get the diff types present in the watch
diff_types = watch.get_diff_types(str(stripped_text_from_html))
# for each diff type, if the filter setting is false, and the diff type is present, then set the changed_detected to false
for diff_type in diff_types:
if not diff_filters[diff_type] and diff_types[diff_type]:
changed_detected = False
break # we only need to check one diff type
# Always record the new checksum
update_obj["previous_md5"] = fetched_md5
# On the first run of a site, watch['previous_md5'] will be None, set it the current one.
if not watch.get('previous_md5'):
watch['previous_md5'] = fetched_md5
watch['previous_text'] = str(stripped_text_from_html)
return changed_detected, update_obj, text_content_before_ignored_filter, fetcher.screenshot, fetcher.xpath_data