From da92a12d920bb6e6d489a8a5ab532046972eaaab Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 4 Oct 2023 14:28:31 +0200 Subject: [PATCH] Add extra checks and try/except wrapper --- changedetectionio/html_tools.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/changedetectionio/html_tools.py b/changedetectionio/html_tools.py index 92b10906..dad56823 100644 --- a/changedetectionio/html_tools.py +++ b/changedetectionio/html_tools.py @@ -193,10 +193,15 @@ def extract_json_as_string(content, json_filter, ensure_is_ldjson_info_type=None # (Some sites have multiple of the same ld+json @type='product', but some have the review part, some have the 'price' part) # @type could also be a list (Product, SubType) # LD_JSON auto-extract also requires some content PLUS the ldjson to be present + # 1833 - could be either str or dict, should not be anything else if json_data.get('@type') and stripped_text_from_html: - types = [json_data.get('@type')] if isinstance(json_data.get('@type'), str) else json_data.get('@type') - if ensure_is_ldjson_info_type.lower() in [x.lower().strip() for x in types]: - break + try: + if json_data.get('@type') == str or json_data.get('@type') == dict: + types = [json_data.get('@type')] if isinstance(json_data.get('@type'), str) else json_data.get('@type') + if ensure_is_ldjson_info_type.lower() in [x.lower().strip() for x in types]: + break + except: + continue elif stripped_text_from_html: break