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.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. _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. uploader = self._html_search_regex(r'<div class="user">.*?<h2>(.+?)</h2>',
  23. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  24. return [{
  25. 'id': video_id,
  26. 'url': video_url,
  27. 'ext': 'mp4',
  28. 'title': self._og_search_title(webpage),
  29. 'thumbnail': self._og_search_thumbnail(webpage),
  30. 'uploader': uploader,
  31. }]