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.

61 lines
2.3 KiB

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