You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class StatigramIE(InfoExtractor):
  5. _VALID_URL = r'https?://(www\.)?statigr\.am/p/(?P<id>[^/]+)'
  6. _TEST = {
  7. 'url': 'http://statigr.am/p/522207370455279102_24101272',
  8. 'md5': '6eb93b882a3ded7c378ee1d6884b1814',
  9. 'info_dict': {
  10. 'id': '522207370455279102_24101272',
  11. 'ext': 'mp4',
  12. 'uploader_id': 'aguynamedpatrick',
  13. 'title': 'Instagram photo by @aguynamedpatrick (Patrick Janelle)',
  14. },
  15. }
  16. def _real_extract(self, url):
  17. mobj = re.match(self._VALID_URL, url)
  18. video_id = mobj.group('id')
  19. webpage = self._download_webpage(url, video_id)
  20. html_title = self._html_search_regex(
  21. r'<title>(.+?)</title>',
  22. webpage, 'title')
  23. title = re.sub(r'(?: *\(Videos?\))? \| Statigram$', '', html_title)
  24. uploader_id = self._html_search_regex(
  25. r'@([^ ]+)', title, 'uploader name', fatal=False)
  26. return {
  27. 'id': video_id,
  28. 'url': self._og_search_video_url(webpage),
  29. 'title': title,
  30. 'thumbnail': self._og_search_thumbnail(webpage),
  31. 'uploader_id': uploader_id
  32. }