diff --git a/Dockerfile b/Dockerfile index a88ab5a6..2272ea01 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ libc-dev \ libffi-dev \ + libjpeg-dev \ libssl-dev \ libxslt-dev \ make \ @@ -36,13 +37,14 @@ ARG CRYPTOGRAPHY_DONT_BUILD_RUST=1 # Re #93, #73, excluding rustc (adds another 430Mb~) RUN apt-get update && apt-get install -y --no-install-recommends \ - libssl-dev \ - libffi-dev \ + g++ \ gcc \ libc-dev \ + libffi-dev \ + libjpeg-dev \ + libssl-dev \ libxslt-dev \ - zlib1g-dev \ - g++ + zlib1g-dev # https://stackoverflow.com/questions/58701233/docker-logs-erroneously-appears-empty-until-container-stops ENV PYTHONUNBUFFERED=1 diff --git a/README.md b/README.md index 86d0cd52..790212fb 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ _Need an actual Chrome runner with Javascript support? We support fetching via W - Override Request Headers, Specify `POST` or `GET` and other methods - Use the "Visual Selector" to help target specific elements - Configurable [proxy per watch](https://github.com/dgtlmoon/changedetection.io/wiki/Proxy-configuration) +- Send a screenshot with the notification when a change is detected in the web page We [recommend and use Bright Data](https://brightdata.grsm.io/n0r16zf7eivq) global proxy services, Bright Data will match any first deposit up to $100 using our signup link. diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 97db72cf..0215f12c 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -644,12 +644,18 @@ def changedetection_app(config=None, datastore_o=None): except ModuleNotFoundError: jq_support = False + watch = datastore.data['watching'].get(uuid) + system_uses_webdriver = datastore.data['settings']['application']['fetch_backend'] == 'html_webdriver' + is_html_webdriver = True if watch.get('fetch_backend') == 'html_webdriver' or ( + watch.get('fetch_backend', None) is None and system_uses_webdriver) else False + output = render_template("edit.html", current_base_url=datastore.data['settings']['application']['base_url'], emailprefix=os.getenv('NOTIFICATION_MAIL_BUTTON_PREFIX', False), form=form, has_default_notification_urls=True if len(datastore.data['settings']['application']['notification_urls']) else False, has_empty_checktime=using_default_check_time, + is_html_webdriver=is_html_webdriver, jq_support=jq_support, playwright_enabled=os.getenv('PLAYWRIGHT_DRIVER_URL', False), settings_application=datastore.data['settings']['application'], @@ -657,7 +663,7 @@ def changedetection_app(config=None, datastore_o=None): uuid=uuid, visualselector_data_is_ready=visualselector_data_is_ready, visualselector_enabled=visualselector_enabled, - watch=datastore.data['watching'][uuid], + watch=watch ) return output diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index 3689cf93..62eaf33b 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -248,7 +248,28 @@ class model(dict): if os.path.isfile(fname): return fname - return False + # False is not an option for AppRise, must be type None + return None + + def get_screenshot_as_jpeg(self): + """Best used in notifications due to its smaller size""" + png_fname = os.path.join(self.watch_data_dir, "last-screenshot.png") + jpg_fname = os.path.join(self.watch_data_dir, "last-screenshot.jpg") + + if os.path.isfile(jpg_fname): + return jpg_fname + + if os.path.isfile(png_fname) and not os.path.isfile(jpg_fname): + # Doesnt exist, so create the JPEG from the PNG + from PIL import Image + im1 = Image.open(png_fname) + im1.convert('RGB').save(jpg_fname, quality=int(os.getenv("NOTIFICATION_SCREENSHOT_JPG_QUALITY", 75))) + return jpg_fname + + + # False is not an option for AppRise, must be type None + return None + def __get_file_ctime(self, filename): fname = os.path.join(self.watch_data_dir, filename) diff --git a/changedetectionio/notification.py b/changedetectionio/notification.py index 116c0cce..ec5e9d19 100644 --- a/changedetectionio/notification.py +++ b/changedetectionio/notification.py @@ -103,7 +103,7 @@ def process_notification(n_object, datastore): body=n_body, body_format=n_format, # False is not an option for AppRise, must be type None - attach=None if not n_object.get('screenshot') else n_object.get('screenshot') + attach=n_object.get('screenshot', None) ) apobj.clear() diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index 0f8e2ce1..57113272 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -141,9 +141,14 @@ User-Agent: wonderbra 1.0") }}