support list based json-ld authors.

This commit is contained in:
Jason Schwarzenberger 2020-11-12 15:08:23 +13:00
parent 587b10c438
commit 3d0a3f1577

View File

@ -102,7 +102,10 @@ def parse_extruct(s, data):
if ld['datePublished']:
s['date'] = ld['datePublished']
if 'author' in ld and ld['author']:
if 'name' in ld['author']:
s['author'] = ld['author']['name']
elif len(ld['author']):
s['author'] = ld['author'][0]['name']
if '@graph' in ld:
for gld in ld['@graph']:
if '@type' in gld and gld['@type'] in ['Article', 'NewsArticle']:
@ -255,7 +258,12 @@ class Category(_Base):
if __name__ == '__main__':
print("Sitemap: The Spinoff")
site = Sitemap("https://thespinoff.co.nz/sitemap.xml")
posts = site.feed()
excludes = [
'thespinoff.co.nz/sitemap-misc.xml',
'thespinoff.co.nz/sitemap-authors.xml',
'thespinoff.co.nz/sitemap-tax-category.xml',
]
posts = site.feed(excludes)
print(posts[:5])
print(site.story(posts[0]))