diff --git a/changedetectionio/fetch_site_status.py b/changedetectionio/fetch_site_status.py index 2fb16ed48..61b9a40a3 100644 --- a/changedetectionio/fetch_site_status.py +++ b/changedetectionio/fetch_site_status.py @@ -2,10 +2,9 @@ import hashlib import logging import os import re -import time import urllib3 import requests -import simplejson +import json from changedetectionio import content_fetcher, html_tools urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) @@ -57,17 +56,18 @@ class perform_site_check(): # Tweak the base config with the per-watch ones request_headers = self.datastore.data['settings']['headers'].copy() - if self.datastore.get_val(uuid, 'external_header_server') is not None: + if self.datastore.data['watching'][uuid].get('external_header_server') is not None: try: - resp = requests.get(self.datastore.get_val(uuid, 'external_header_server')) + resp = requests.get(self.datastore.data['watching'][uuid].get('external_header_server')) if resp.status_code != 200: raise Exception("External header server returned non-200 response. Please check the URL for the server") + data = json.loads(resp.text.strip()) request_headers.update(resp.json()) - except simplejson.errors.JSONDecodeError: + except json.decoder.JSONDecodeError: raise Exception("Failed to decode JSON response from external header server") - + request_headers.update(extra_headers) # https://github.com/psf/requests/issues/4525