From 7ac062009917ebc5dc7409158ca9257b59cfcc31 Mon Sep 17 00:00:00 2001 From: bwees Date: Thu, 28 Jul 2022 20:52:01 -0400 Subject: [PATCH] fixed merge conflict with latest version --- changedetectionio/model/Watch.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index 0352742db..0cdbc480b 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -1,7 +1,9 @@ import os import uuid as uuid_builder +from distutils.util import strtobool minimum_seconds_recheck_time = int(os.getenv('MINIMUM_SECONDS_RECHECK_TIME', 60)) +mtable = {'seconds': 1, 'minutes': 60, 'hours': 3600, 'days': 86400, 'weeks': 86400 * 7} from changedetectionio.notification import ( default_notification_body, @@ -40,6 +42,8 @@ class model(dict): 'trigger_text': [], # List of text or regex to wait for until a change is detected 'text_should_not_be_present': [], # Text that should not present 'fetch_backend': None, + 'filter_failure_notification_send': strtobool(os.getenv('FILTER_FAILURE_NOTIFICATION_SEND_DEFAULT', 'True')), + 'consecutive_filter_failures': 0, # Every time the CSS/xPath filter cannot be located, reset when all is fine. 'extract_title_as_title': False, 'check_unique_lines': False, # On change-detected, compare against all history if its something new 'trigger_add': True, @@ -53,7 +57,7 @@ class model(dict): 'webdriver_js_execute_code': None, # Run before change-detection } jitter_seconds = 0 - mtable = {'seconds': 1, 'minutes': 60, 'hours': 3600, 'days': 86400, 'weeks': 86400 * 7} + def __init__(self, *arg, **kw): import uuid self.update(self.__base_config) @@ -195,7 +199,7 @@ class model(dict): def threshold_seconds(self): seconds = 0 - for m, n in self.mtable.items(): + for m, n in mtable.items(): x = self.get('time_between_check', {}).get(m, None) if x: seconds += x * n @@ -203,16 +207,17 @@ class model(dict): # Iterate over all history texts and see if something new exists def lines_contain_something_unique_compared_to_history(self, lines=[]): - local_lines = [l.decode('utf-8').strip().lower() for l in lines] + local_lines = set([l.decode('utf-8').strip().lower() for l in lines]) # Compare each lines (set) against each history text file (set) looking for something new.. + existing_history = set({}) for k, v in self.history.items(): - alist = [line.decode('utf-8').strip().lower() for line in open(v, 'rb')] - res = set(alist) != set(local_lines) - if res: - return True + alist = set([line.decode('utf-8').strip().lower() for line in open(v, 'rb')]) + existing_history = existing_history.union(alist) - return False + # Check that everything in local_lines(new stuff) already exists in existing_history - it should + # if not, something new happened + return not local_lines.issubset(existing_history) # Get diff types (addition, deletion, modification) from the previous snapshot and new_text # uses similar algorithm to customSequenceMatcher in diff.py