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.

68 lines
2.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. float_or_none,
  7. str_to_int,
  8. )
  9. class VidmeIE(InfoExtractor):
  10. _VALID_URL = r'https?://vid\.me/(?:e/)?(?P<id>[\da-zA-Z]+)'
  11. _TEST = {
  12. 'url': 'https://vid.me/QNB',
  13. 'md5': 'f42d05e7149aeaec5c037b17e5d3dc82',
  14. 'info_dict': {
  15. 'id': 'QNB',
  16. 'ext': 'mp4',
  17. 'title': 'Fishing for piranha - the easy way',
  18. 'description': 'source: https://www.facebook.com/photo.php?v=312276045600871',
  19. 'duration': 119.92,
  20. 'timestamp': 1406313244,
  21. 'upload_date': '20140725',
  22. 'thumbnail': 're:^https?://.*\.jpg',
  23. },
  24. }
  25. def _real_extract(self, url):
  26. mobj = re.match(self._VALID_URL, url)
  27. video_id = mobj.group('id')
  28. webpage = self._download_webpage(url, video_id)
  29. video_url = self._html_search_regex(r'<source src="([^"]+)"', webpage, 'video URL')
  30. title = self._og_search_title(webpage)
  31. description = self._og_search_description(webpage, default='')
  32. thumbnail = self._og_search_thumbnail(webpage)
  33. timestamp = int_or_none(self._og_search_property('updated_time', webpage, fatal=False))
  34. width = int_or_none(self._og_search_property('video:width', webpage, fatal=False))
  35. height = int_or_none(self._og_search_property('video:height', webpage, fatal=False))
  36. duration = float_or_none(self._html_search_regex(
  37. r'data-duration="([^"]+)"', webpage, 'duration', fatal=False))
  38. view_count = str_to_int(self._html_search_regex(
  39. r'<span class="video_views">\s*([\d,\.]+)\s*plays?', webpage, 'view count', fatal=False))
  40. like_count = str_to_int(self._html_search_regex(
  41. r'class="score js-video-vote-score"[^>]+data-score="([\d,\.\s]+)">',
  42. webpage, 'like count', fatal=False))
  43. comment_count = str_to_int(self._html_search_regex(
  44. r'class="js-comment-count"[^>]+data-count="([\d,\.\s]+)">',
  45. webpage, 'comment count', fatal=False))
  46. return {
  47. 'id': video_id,
  48. 'url': video_url,
  49. 'title': title,
  50. 'description': description,
  51. 'thumbnail': thumbnail,
  52. 'timestamp': timestamp,
  53. 'width': width,
  54. 'height': height,
  55. 'duration': duration,
  56. 'view_count': view_count,
  57. 'like_count': like_count,
  58. 'comment_count': comment_count,
  59. }