From ab74377be0dc7f12182fc9d2710817629a6b41e8 Mon Sep 17 00:00:00 2001 From: bwees Date: Tue, 12 Jul 2022 18:28:29 -0400 Subject: [PATCH] fixed file based text saving system --- changedetectionio/fetch_site_status.py | 13 ++++++++----- changedetectionio/model/Watch.py | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/changedetectionio/fetch_site_status.py b/changedetectionio/fetch_site_status.py index 8483277f..7c6687a5 100644 --- a/changedetectionio/fetch_site_status.py +++ b/changedetectionio/fetch_site_status.py @@ -277,28 +277,31 @@ class perform_site_check(): else: logging.debug("check_unique_lines: UUID {} had unique content".format(uuid)) + if changed_detected: diff_filters = { "add": watch.get('trigger_on_add', True), "del": watch.get('trigger_on_del', True), } if False in diff_filters.values(): # if we are supposed to filter any diff types - print(">>>>>>>>>>>> Filtering diffs") + print("Diff Filters Active: " + str(diff_filters)) + # get the diff types present in the watch - diff_types = watch.get_diff_types(str(stripped_text_from_html)) - + diff_types = watch.get_diff_types(text_content_before_ignored_filter) + print("Diff components found: " + str(diff_types)) + # 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 + # Always record the new checksum and the new text update_obj["previous_md5"] = fetched_md5 + watch.save_previous_text(text_content_before_ignored_filter) # 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 diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index c3b75e52..bb33d3a7 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -230,7 +230,8 @@ class model(dict): } # get diff types using difflib - cruncher = difflib.SequenceMatcher(isjunk=lambda x: x in " \\t", a=self.get_previous_text(), b=str(new_text)) + cruncher = difflib.SequenceMatcher(isjunk=lambda x: x in " \\t", a=str(self.get_previous_text()), b=str(new_text)) + for tag, alo, ahi, blo, bhi in cruncher.get_opcodes(): if tag == 'delete': diff_types["del"] = True