Skip to content

Commit

Permalink
Fixed array with single or multiples entries on json extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
felipehertzer committed Nov 15, 2021
1 parent 7224971 commit fbbd55a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions trafilatura/json_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def extract_json(schema, metadata):
if '@context' not in parent or not isinstance(parent['@context'], str) or parent['@context'][-10:].lower() != 'schema.org':
continue
if '@graph' in parent:
parent = parent['@graph']
parent = parent['@graph'] if isinstance(parent['@graph'], list) else [parent['@graph']]
elif '@type' in parent and isinstance(parent['@type'], str) and 'liveblogposting' in parent['@type'].lower():
parent = parent['liveBlogUpdate']
parent = parent['liveBlogUpdate'] if isinstance(parent['liveBlogUpdate'], list) else [parent['liveBlogUpdate']]
else:
parent = schema

Expand Down

0 comments on commit fbbd55a

Please sign in to comment.