diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 0397c026..08072500 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -88,7 +88,7 @@ jobs: - name: Build and push :dev id: docker_build if: ${{ github.ref }} == "refs/heads/master" - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: ./ file: ./Dockerfile @@ -106,7 +106,7 @@ jobs: - name: Build and push :tag id: docker_build_tag_release if: github.event_name == 'release' && startsWith(github.event.release.tag_name, '0.') - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: ./ file: ./Dockerfile diff --git a/.github/workflows/test-container-build.yml b/.github/workflows/test-container-build.yml index c6fd9efb..3a5f5351 100644 --- a/.github/workflows/test-container-build.yml +++ b/.github/workflows/test-container-build.yml @@ -51,7 +51,7 @@ jobs: # Check we can still build under alpine/musl - name: Test that the docker containers can build (musl via alpine check) id: docker_build_musl - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: ./ file: ./.github/test/Dockerfile-alpine @@ -59,7 +59,7 @@ jobs: - name: Test that the docker containers can build id: docker_build - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 # https://github.com/docker/build-push-action#customizing with: context: ./ diff --git a/Dockerfile b/Dockerfile index 5e45880c..626759cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,9 @@ # @NOTE! I would love to move to 3.11 but it breaks the async handler in changedetectionio/content_fetchers/puppeteer.py # If you know how to fix it, please do! and test it for both 3.10 and 3.11 -ARG PYTHON_VERSION=3.10 +ARG PYTHON_VERSION=3.11 -FROM python:${PYTHON_VERSION}-slim-bookworm as builder +FROM python:${PYTHON_VERSION}-slim-bookworm AS builder # See `cryptography` pin comment in requirements.txt ARG CRYPTOGRAPHY_DONT_BUILD_RUST=1 @@ -26,7 +26,8 @@ WORKDIR /install COPY requirements.txt /requirements.txt -RUN pip install --target=/dependencies -r /requirements.txt +# --extra-index-url https://www.piwheels.org/simple is for cryptography module to be prebuilt (or rustc etc needs to be installed) +RUN pip install --extra-index-url https://www.piwheels.org/simple --target=/dependencies -r /requirements.txt # Playwright is an alternative to Selenium # Excluded this package from requirements.txt to prevent arm/v6 and arm/v7 builds from failing diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index e5c86e60..86f26da9 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -2,7 +2,7 @@ # Read more https://github.com/dgtlmoon/changedetection.io/wiki -__version__ = '0.45.24' +__version__ = '0.45.25' from changedetectionio.strtobool import strtobool from json.decoder import JSONDecodeError diff --git a/changedetectionio/api/api_v1.py b/changedetectionio/api/api_v1.py index c6014d6c..9b3eb440 100644 --- a/changedetectionio/api/api_v1.py +++ b/changedetectionio/api/api_v1.py @@ -171,23 +171,33 @@ class WatchSingleHistory(Resource): curl http://localhost:5000/api/v1/watch/cc0cfffa-f449-477b-83ea-0caafd1dc091/history/1677092977 -H"x-api-key:813031b16330fe25e3780cf0325daa45" -H "Content-Type: application/json" @apiName Get single snapshot content @apiGroup Watch History + @apiParam {String} [html] Optional Set to =1 to return the last HTML (only stores last 2 snapshots, use `latest` as timestamp) @apiSuccess (200) {String} OK @apiSuccess (404) {String} ERR Not found """ watch = self.datastore.data['watching'].get(uuid) if not watch: - abort(404, message='No watch exists with the UUID of {}'.format(uuid)) + abort(404, message=f"No watch exists with the UUID of {uuid}") if not len(watch.history): - abort(404, message='Watch found but no history exists for the UUID {}'.format(uuid)) + abort(404, message=f"Watch found but no history exists for the UUID {uuid}") if timestamp == 'latest': timestamp = list(watch.history.keys())[-1] - content = watch.get_history_snapshot(timestamp) + if request.args.get('html'): + content = watch.get_fetched_html(timestamp) + if content: + response = make_response(content, 200) + response.mimetype = "text/html" + else: + response = make_response("No content found", 404) + response.mimetype = "text/plain" + else: + content = watch.get_history_snapshot(timestamp) + response = make_response(content, 200) + response.mimetype = "text/plain" - response = make_response(content, 200) - response.mimetype = "text/plain" return response diff --git a/changedetectionio/blueprint/browser_steps/__init__.py b/changedetectionio/blueprint/browser_steps/__init__.py index 30797099..f92bf9f8 100644 --- a/changedetectionio/blueprint/browser_steps/__init__.py +++ b/changedetectionio/blueprint/browser_steps/__init__.py @@ -187,8 +187,10 @@ def construct_blueprint(datastore: ChangeDetectionStore): u = browsersteps_sessions[browsersteps_session_id]['browserstepper'].page.url if is_last_step and u: (screenshot, xpath_data) = browsersteps_sessions[browsersteps_session_id]['browserstepper'].request_visualselector_data() - datastore.save_screenshot(watch_uuid=uuid, screenshot=screenshot) - datastore.save_xpath_data(watch_uuid=uuid, data=xpath_data) + watch = datastore.data['watching'].get(uuid) + if watch: + watch.save_screenshot(screenshot=screenshot) + watch.save_xpath_data(data=xpath_data) # if not this_session.page: # cleanup_playwright_session() diff --git a/changedetectionio/blueprint/tags/templates/edit-tag.html b/changedetectionio/blueprint/tags/templates/edit-tag.html index 1d297c81..9f316c55 100644 --- a/changedetectionio/blueprint/tags/templates/edit-tag.html +++ b/changedetectionio/blueprint/tags/templates/edit-tag.html @@ -63,7 +63,7 @@ xpath://body/div/span[contains(@class, 'example-class')]",