Skip to content

Commit

Permalink
Merge pull request #45 from michaelhelmick/bugs-44
Browse files Browse the repository at this point in the history
Fixes #44, handle AMP image data with list data
  • Loading branch information
michaelhelmick authored Nov 1, 2016
2 parents 94101d2 + 85efeee commit f43fca4
Show file tree
Hide file tree
Showing 3 changed files with 252 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lassie/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,19 @@ def _filter_amp_data(self, soup, data, url, all_images):
'src': urljoin(url, image),
})
elif isinstance(image, object):
data['images'].append({
'src': urljoin(url, image.get('url')),
'width': convert_to_int(image.get('width')),
'height': convert_to_int(image.get('height')),
})
if image.get('@list'):
for _image in image.get('@list'):
data['images'].append({
'src': urljoin(url, _image.get('url')),
'width': convert_to_int(_image.get('width')),
'height': convert_to_int(_image.get('height')),
})
else:
data['images'].append({
'src': urljoin(url, image.get('url')),
'width': convert_to_int(image.get('width')),
'height': convert_to_int(image.get('height')),
})

data['title'] = _json.get('headline', '')
data['url'] = _json.get('url', '')
Expand Down
Loading

0 comments on commit f43fca4

Please sign in to comment.