Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
scraper_q: look for og:image:url
Browse files Browse the repository at this point in the history
This is another way of specifying thumbnails, and one we've even used - so we
should look for it when scraping other sites.
  • Loading branch information
xiongchiamiov committed Jun 1, 2015
1 parent f4cc22f commit f07095d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions r2/r2/lib/media.py
Expand Up @@ -581,12 +581,16 @@ def _find_thumbnail_image(self):
else:
return None, None

# allow the content author to specify the thumbnail:
# <meta property="og:image" content="http://...">
# Allow the content author to specify the thumbnail using the Open
# Graph protocol: http://ogp.me/
og_image = (soup.find('meta', property='og:image') or
soup.find('meta', attrs={'name': 'og:image'}))
if og_image and og_image['content']:
return og_image['content'], None
og_image = (soup.find('meta', property='og:image:url') or
soup.find('meta', attrs={'name': 'og:image:url'}))
if og_image and og_image['content']:
return og_image['content'], None

# <link rel="image_src" href="http://...">
thumbnail_spec = soup.find('link', rel='image_src')
Expand Down

0 comments on commit f07095d

Please sign in to comment.