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.

44 lines
1.2 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class VineIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?vine\.co/v/(?P<id>\w+)'
  6. _TEST = {
  7. 'url': 'https://vine.co/v/b9KOOWX7HUx',
  8. 'md5': '2f36fed6235b16da96ce9b4dc890940d',
  9. 'info_dict': {
  10. 'id': 'b9KOOWX7HUx',
  11. 'ext': 'mp4',
  12. 'uploader': 'Jack Dorsey',
  13. 'title': 'Chicken.',
  14. },
  15. }
  16. def _real_extract(self, url):
  17. mobj = re.match(self._VALID_URL, url)
  18. video_id = mobj.group('id')
  19. webpage_url = 'https://vine.co/v/' + video_id
  20. webpage = self._download_webpage(webpage_url, video_id)
  21. self.report_extraction(video_id)
  22. video_url = self._html_search_meta('twitter:player:stream', webpage,
  23. 'video URL')
  24. twitter_title = self._html_search_meta('twitter:title', webpage,
  25. 'twitter title')
  26. uploader = re.sub('\'s post on Vine', '', twitter_title)
  27. return {
  28. 'id': video_id,
  29. 'url': video_url,
  30. 'ext': 'mp4',
  31. 'title': self._og_search_title(webpage),
  32. 'thumbnail': self._og_search_thumbnail(webpage),
  33. 'uploader': uploader,
  34. }