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.

46 lines
1.5 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. _TEST = {
  6. u'url': u'https://vine.co/v/b9KOOWX7HUx',
  7. u'file': u'b9KOOWX7HUx.mp4',
  8. u'md5': u'2f36fed6235b16da96ce9b4dc890940d',
  9. u'info_dict': {
  10. u"uploader": u"Jack Dorsey",
  11. u"title": u"Chicken."
  12. }
  13. }
  14. def _real_extract(self, url):
  15. mobj = re.match(self._VALID_URL, url)
  16. video_id = mobj.group('id')
  17. webpage_url = 'https://vine.co/v/' + video_id
  18. webpage = self._download_webpage(webpage_url, video_id)
  19. self.report_extraction(video_id)
  20. video_url = self._html_search_regex(r'<meta property="twitter:player:stream" content="(.+?)"',
  21. webpage, u'video URL')
  22. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  23. webpage, u'title')
  24. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)(\?.*?)?"',
  25. webpage, u'thumbnail', fatal=False)
  26. uploader = self._html_search_regex(r'<div class="user">.*?<h2>(.+?)</h2>',
  27. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  28. return [{
  29. 'id': video_id,
  30. 'url': video_url,
  31. 'ext': 'mp4',
  32. 'title': video_title,
  33. 'thumbnail': thumbnail,
  34. 'uploader': uploader,
  35. }]