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.

42 lines
1.5 KiB

  1. import re
  2. from .common import InfoExtractor
  3. class StatigramIE(InfoExtractor):
  4. _VALID_URL = r'(?:http://)?(?:www\.)?statigr\.am/p/([^/]+)'
  5. _TEST = {
  6. u'url': u'http://statigr.am/p/484091715184808010_284179915',
  7. u'file': u'484091715184808010_284179915.mp4',
  8. u'md5': u'deda4ff333abe2e118740321e992605b',
  9. u'info_dict': {
  10. u"uploader_id": u"videoseconds",
  11. u"title": u"Instagram photo by @videoseconds (Videos)"
  12. }
  13. }
  14. def _real_extract(self, url):
  15. mobj = re.match(self._VALID_URL, url)
  16. video_id = mobj.group(1)
  17. webpage = self._download_webpage(url, video_id)
  18. video_url = self._html_search_regex(
  19. r'<meta property="og:video:secure_url" content="(.+?)">',
  20. webpage, u'video URL')
  21. thumbnail_url = self._html_search_regex(
  22. r'<meta property="og:image" content="(.+?)" />',
  23. webpage, u'thumbnail URL', fatal=False)
  24. html_title = self._html_search_regex(
  25. r'<title>(.+?)</title>',
  26. webpage, u'title')
  27. title = html_title.rpartition(u' | Statigram')[0]
  28. uploader_id = self._html_search_regex(
  29. r'@([^ ]+)', title, u'uploader name', fatal=False)
  30. ext = 'mp4'
  31. return [{
  32. 'id': video_id,
  33. 'url': video_url,
  34. 'ext': ext,
  35. 'title': title,
  36. 'thumbnail': thumbnail_url,
  37. 'uploader_id' : uploader_id
  38. }]