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.

37 lines
1.2 KiB

  1. import re
  2. from .common import InfoExtractor
  3. class VineIE(InfoExtractor):
  4. _VALID_URL = r'(?:https?://)?(?:www\.)?vine\.co/v/(?P<id>\w+)'
  5. def _real_extract(self, url):
  6. mobj = re.match(self._VALID_URL, url)
  7. video_id = mobj.group('id')
  8. webpage_url = 'https://vine.co/v/' + video_id
  9. webpage = self._download_webpage(webpage_url, video_id)
  10. self.report_extraction(video_id)
  11. video_url = self._html_search_regex(r'<meta property="twitter:player:stream" content="(.+?)"',
  12. webpage, u'video URL')
  13. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  14. webpage, u'title')
  15. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)(\?.*?)?"',
  16. webpage, u'thumbnail', fatal=False)
  17. uploader = self._html_search_regex(r'<div class="user">.*?<h2>(.+?)</h2>',
  18. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  19. return [{
  20. 'id': video_id,
  21. 'url': video_url,
  22. 'ext': 'mp4',
  23. 'title': video_title,
  24. 'thumbnail': thumbnail,
  25. 'uploader': uploader,
  26. }]