From e9a9790cb03c169ecd145ad65de88d3fb655da5c Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 1 Feb 2024 00:09:27 +0100 Subject: [PATCH 1/2] Fetching - Make an obvious error when using BrowserSteps with the simple text fetcher (#2145) --- changedetectionio/content_fetcher.py | 7 +++++++ changedetectionio/update_worker.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index ce051920..9544a950 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -61,6 +61,10 @@ class PageUnloadable(Exception): self.message = message return +class BrowserStepsInUnsupportedFetcher(Exception): + def __init__(self, url): + self.url = url + return class EmptyReply(Exception): def __init__(self, status_code, url, screenshot=None): @@ -712,6 +716,9 @@ class html_requests(Fetcher): current_include_filters=None, is_binary=False): + if self.browser_steps_get_valid_steps(): + raise BrowserStepsInUnsupportedFetcher(url=url) + # Make requests use a more modern looking user-agent if not {k.lower(): v for k, v in request_headers.items()}.get('user-agent', None): request_headers['User-Agent'] = os.getenv("DEFAULT_SETTINGS_HEADERS_USERAGENT", diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index 46984089..fee6a5a2 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -430,6 +430,12 @@ class update_worker(threading.Thread): 'last_check_status': e.status_code, 'has_ldjson_price_data': None}) process_changedetection_results = False + except content_fetcher.BrowserStepsInUnsupportedFetcher as e: + err_text = "This watch has Browser Steps configured and so it cannot run with the 'Basic fast Plaintext/HTTP Client', either remove the Browser Steps or select a Chrome fetcher." + self.datastore.update_watch(uuid=uuid, update_obj={'last_error': err_text}) + process_changedetection_results = False + logger.error(f"Exception (BrowserStepsInUnsupportedFetcher) reached processing watch UUID: {uuid}") + except UnableToExtractRestockData as e: # Usually when fetcher.instock_data returns empty logger.error(f"Exception (UnableToExtractRestockData) reached processing watch UUID: {uuid}") From 4b4975911360bab1ae3f2182c54d8b6e04bd8368 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 1 Feb 2024 10:36:43 +0100 Subject: [PATCH 2/2] UI - Show error/warning when trying to compare the same version --- changedetectionio/static/js/diff-overview.js | 7 ++++++- changedetectionio/templates/diff.html | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/changedetectionio/static/js/diff-overview.js b/changedetectionio/static/js/diff-overview.js index 8cbe7dcd..767cf6e1 100644 --- a/changedetectionio/static/js/diff-overview.js +++ b/changedetectionio/static/js/diff-overview.js @@ -90,5 +90,10 @@ $(document).ready(function () { } } - + $('#diff-form').on('submit', function (e) { + if ($('select[name=from_version]').val() === $('select[name=to_version]').val()) { + e.preventDefault(); + alert('Error - You are trying to compare the same version.'); + } + }); }); diff --git a/changedetectionio/templates/diff.html b/changedetectionio/templates/diff.html index 6cac4605..0197bfc9 100644 --- a/changedetectionio/templates/diff.html +++ b/changedetectionio/templates/diff.html @@ -13,7 +13,7 @@
-
+
{% if versions|length >= 1 %} Compare