Handling rare error when parsing articles.
Some checks are pending
CodeQL / Analyze (push) Waiting to run

This commit is contained in:
Roland 2025-08-06 15:01:40 -06:00
parent e8b8eb84a9
commit 76b9ead174
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680

View file

@ -319,7 +319,7 @@ def parse_article_html_metadata(html: Union[bytes, str], assume_utc: bool = True
except json.decoder.JSONDecodeError:
# Was not valid JSON.
schema = None
if isinstance(schema, dict) and '://schema.org' in schema.get('@context'):
if isinstance(schema, dict) and (context := schema.get('@context')) and '://schema.org' in context:
# Found https://schema.org/
if headline := schema.get('headline'):
metadata.title = metadata.title or headline