diff --git a/changedetectionio/fetch_site_status.py b/changedetectionio/fetch_site_status.py index 76c821be..54587dff 100644 --- a/changedetectionio/fetch_site_status.py +++ b/changedetectionio/fetch_site_status.py @@ -35,8 +35,6 @@ class perform_site_check(): def run(self, uuid): - from jinja2 import Environment - changed_detected = False screenshot = False # as bytes stripped_text_from_html = "" @@ -68,9 +66,7 @@ class perform_site_check(): timeout = self.datastore.data['settings']['requests'].get('timeout') - # Jinja2 available in URLs along with https://pypi.org/project/jinja2-time/ - jinja2_env = Environment(extensions=['jinja2_time.TimeExtension']) - url = str(jinja2_env.from_string(watch.get('url')).render()) + url = watch.link request_body = self.datastore.data['watching'][uuid].get('body') request_method = self.datastore.data['watching'][uuid].get('method') diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index 5834b532..2d3f93b1 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -87,6 +87,16 @@ class model(dict): print ("> Creating data dir {}".format(target_path)) os.mkdir(target_path) + @property + def link(self): + url = self.get('url', '') + if '{%' in url or '{{' in url: + from jinja2 import Environment + # Jinja2 available in URLs along with https://pypi.org/project/jinja2-time/ + jinja2_env = Environment(extensions=['jinja2_time.TimeExtension']) + return str(jinja2_env.from_string(url).render()) + return url + @property def label(self): # Used for sorting diff --git a/changedetectionio/templates/watch-overview.html b/changedetectionio/templates/watch-overview.html index 63dc44de..c7c4c45e 100644 --- a/changedetectionio/templates/watch-overview.html +++ b/changedetectionio/templates/watch-overview.html @@ -87,7 +87,7 @@ Mute notifications {{watch.title if watch.title is not none and watch.title|length > 0 else watch.url}} - + {%if watch.fetch_backend == "html_webdriver" %}{% endif %}