Skip to content

Commit

Permalink
Merge pull request #3421 from rebeccacremona/no-pageinfo
Browse files Browse the repository at this point in the history
Don't assume pageInfo is present.
  • Loading branch information
rebeccacremona authored Oct 30, 2023
2 parents ac1454d + 8d4c520 commit eecba3f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions perma_web/perma/celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,16 +829,20 @@ def save_scoop_capture(link, capture_job, data):
link.primary_capture.content_type = data['scoop_capture_summary']['targetUrlContentType']
link.primary_capture.save(update_fields=['content_type'])

title = data['scoop_capture_summary']['pageInfo'].get('title')
if title and link.submitted_title == link.get_default_title():
link.submitted_title = title[:2100]
description = data['scoop_capture_summary']['pageInfo'].get('description')
if description:
link.submitted_description=description[:300]
link.save(update_fields=[
'submitted_title',
'submitted_description'
])
if data['scoop_capture_summary'].get('pageInfo'):
title = data['scoop_capture_summary']['pageInfo'].get('title')
if title and link.submitted_title == link.get_default_title():
link.submitted_title = title[:2100]
description = data['scoop_capture_summary']['pageInfo'].get('description')
if description:
link.submitted_description=description[:300]
link.save(update_fields=[
'submitted_title',
'submitted_description'
])
else:
link.tags.add('scoop-missing-pageinfo')
logger.warning(f"{capture_job.link_id}: Scoop metadata does not contain pageInfo ({data['id_capture']}).")

# Make this link private by policy, if the captured domain is on the list.
target_url = data['scoop_capture_summary']['targetUrl']
Expand Down

0 comments on commit eecba3f

Please sign in to comment.