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.

43 lines
1.2 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 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. uploader = self._html_search_regex(r'<p class="username">(.*?)</p>',
  25. webpage, 'uploader', fatal=False, flags=re.DOTALL)
  26. return {
  27. 'id': video_id,
  28. 'url': video_url,
  29. 'ext': 'mp4',
  30. 'title': self._og_search_title(webpage),
  31. 'thumbnail': self._og_search_thumbnail(webpage),
  32. 'uploader': uploader,
  33. }