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.

59 lines
1.8 KiB

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. import json
  4. from .common import InfoExtractor
  5. from ..utils import unified_strdate
  6. class VineIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?vine\.co/v/(?P<id>\w+)'
  8. _TEST = {
  9. 'url': 'https://vine.co/v/b9KOOWX7HUx',
  10. 'md5': '2f36fed6235b16da96ce9b4dc890940d',
  11. 'info_dict': {
  12. 'id': 'b9KOOWX7HUx',
  13. 'ext': 'mp4',
  14. 'title': 'Chicken.',
  15. 'description': 'Chicken.',
  16. 'upload_date': '20130519',
  17. 'uploader': 'Jack Dorsey',
  18. 'uploader_id': '76',
  19. },
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('id')
  24. webpage = self._download_webpage('https://vine.co/v/' + video_id, video_id)
  25. data = json.loads(self._html_search_regex(
  26. r'window\.POST_DATA = { %s: ({.+?}) }' % video_id, webpage, 'vine data'))
  27. formats = [
  28. {
  29. 'url': data['videoLowURL'],
  30. 'ext': 'mp4',
  31. 'format_id': 'low',
  32. },
  33. {
  34. 'url': data['videoUrl'],
  35. 'ext': 'mp4',
  36. 'format_id': 'standard',
  37. }
  38. ]
  39. return {
  40. 'id': video_id,
  41. 'title': self._og_search_title(webpage),
  42. 'description': data['description'],
  43. 'thumbnail': data['thumbnailUrl'],
  44. 'upload_date': unified_strdate(data['created']),
  45. 'uploader': data['username'],
  46. 'uploader_id': data['userIdStr'],
  47. 'like_count': data['likes']['count'],
  48. 'comment_count': data['comments']['count'],
  49. 'repost_count': data['reposts']['count'],
  50. 'formats': formats,
  51. }