From eba27dcd916dc67567d500aef0d08b8dbb59e261 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 17 Oct 2024 21:08:05 +0200 Subject: [PATCH] WIP --- changedetectionio/forms.py | 2 ++ changedetectionio/model/App.py | 2 ++ changedetectionio/model/Watch.py | 3 +++ changedetectionio/model/__init__.py | 2 ++ changedetectionio/templates/settings.html | 7 +++++++ changedetectionio/update_worker.py | 6 ++++++ 6 files changed, 22 insertions(+) diff --git a/changedetectionio/forms.py b/changedetectionio/forms.py index 19056b5d..cac42d6d 100644 --- a/changedetectionio/forms.py +++ b/changedetectionio/forms.py @@ -588,6 +588,8 @@ class globalSettingsApplicationForm(commonSettingsForm): global_ignore_text = StringListField('Ignore Text', [ValidateListRegex()]) global_subtractive_selectors = StringListField('Remove elements', [ValidateCSSJSONXPATHInput(allow_json=False)]) ignore_whitespace = BooleanField('Ignore whitespace') + keep_history_n = IntegerField('Number of snapshots to keep in history for each watch') + keep_history_seconds = IntegerField('Number of snapshots to keep - maximum age (todo/seconds)') password = SaltyPasswordField() pager_size = IntegerField('Pager size', render_kw={"style": "width: 5em;"}, diff --git a/changedetectionio/model/App.py b/changedetectionio/model/App.py index fdd627ed..21b72ce0 100644 --- a/changedetectionio/model/App.py +++ b/changedetectionio/model/App.py @@ -40,6 +40,8 @@ class model(dict): 'global_ignore_text': [], # List of text to ignore when calculating the comparison checksum 'global_subtractive_selectors': [], 'ignore_whitespace': True, + 'keep_history_n': None, # Number of snapshots to keep + 'keep_history_seconds': None, # Or time ago back to keep 'notification_body': default_notification_body, 'notification_format': default_notification_format, 'notification_title': default_notification_title, diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index a2e38ce1..85df935a 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -625,6 +625,9 @@ class model(watch_base): if index > 1 and os.path.isfile(filepath): os.remove(filepath) + def post_process(self): + + x=1 @property def get_browsersteps_available_screenshots(self): diff --git a/changedetectionio/model/__init__.py b/changedetectionio/model/__init__.py index 36d12384..a17d0dbc 100644 --- a/changedetectionio/model/__init__.py +++ b/changedetectionio/model/__init__.py @@ -33,6 +33,8 @@ class watch_base(dict): 'headers': {}, # Extra headers to send 'ignore_text': [], # List of text to ignore when calculating the comparison checksum 'in_stock_only': True, # Only trigger change on going to instock from out-of-stock + 'keep_history_n': None, # Number of snapshots to keep + 'keep_history_seconds': None, # Or time ago back to keep 'include_filters': [], 'last_checked': 0, 'last_error': False, diff --git a/changedetectionio/templates/settings.html b/changedetectionio/templates/settings.html index e39c4081..c9eb03d1 100644 --- a/changedetectionio/templates/settings.html +++ b/changedetectionio/templates/settings.html @@ -129,6 +129,13 @@ Note: Simply changing the User-Agent often does not defeat anti-robot technologies, it's important to consider all of the ways that the browser is detected. +
+ {{ render_field(form.application.form.keep_history_n) }} + Blank - keep all + {{ render_field(form.application.form.keep_history_seconds) }} + Blank - keep all +
+

Tip: Connect using Bright Data and Oxylabs Proxies, find out more here. diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index 9dd460d3..822f48ad 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -568,6 +568,12 @@ class update_worker(threading.Thread): except Exception as e: pass + try: + watch.post_process() + except Exception as e: + logger.critical(e) + + self.datastore.update_watch(uuid=uuid, update_obj={'fetch_time': round(time.time() - now, 3), 'last_checked': round(time.time()), 'check_count': count