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.

40 lines
1.4 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class IconosquareIE(InfoExtractor):
  5. _VALID_URL = r'https?://(www\.)?(?:iconosquare\.com|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. 'description': 'md5:644406a9ec27457ed7aa7a9ebcd4ce3d',
  15. },
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  20. webpage = self._download_webpage(url, video_id)
  21. html_title = self._html_search_regex(
  22. r'<title>(.+?)</title>',
  23. webpage, 'title')
  24. title = re.sub(r'(?: *\(Videos?\))? \| (?:Iconosquare|Statigram)$', '', html_title)
  25. uploader_id = self._html_search_regex(
  26. r'@([^ ]+)', title, 'uploader name', fatal=False)
  27. return {
  28. 'id': video_id,
  29. 'url': self._og_search_video_url(webpage),
  30. 'title': title,
  31. 'description': self._og_search_description(webpage),
  32. 'thumbnail': self._og_search_thumbnail(webpage),
  33. 'uploader_id': uploader_id
  34. }