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.

66 lines
2.5 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. _TESTS = [{
  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. # From http://naked-yogi.tumblr.com/post/118312946248/naked-smoking-stretching
  25. 'url': 'https://vid.me/e/Wmur',
  26. 'only_matching': True,
  27. }]
  28. def _real_extract(self, url):
  29. url = url.replace('vid.me/e/', 'vid.me/')
  30. video_id = self._match_id(url)
  31. webpage = self._download_webpage(url, video_id)
  32. video_url = self._html_search_regex(
  33. r'<source src="([^"]+)"', webpage, 'video URL')
  34. title = self._og_search_title(webpage)
  35. description = self._og_search_description(webpage, default='')
  36. thumbnail = self._og_search_thumbnail(webpage)
  37. timestamp = int_or_none(self._og_search_property('updated_time', webpage, fatal=False))
  38. width = int_or_none(self._og_search_property('video:width', webpage, fatal=False))
  39. height = int_or_none(self._og_search_property('video:height', webpage, fatal=False))
  40. duration = float_or_none(self._html_search_regex(
  41. r'data-duration="([^"]+)"', webpage, 'duration', fatal=False))
  42. view_count = str_to_int(self._html_search_regex(
  43. r'<(?:li|span) class="video_views">\s*([\d,\.]+)\s*plays?', webpage, 'view count', fatal=False))
  44. like_count = str_to_int(self._html_search_regex(
  45. r'class="score js-video-vote-score"[^>]+data-score="([\d,\.\s]+)">',
  46. webpage, 'like count', fatal=False))
  47. return {
  48. 'id': video_id,
  49. 'url': video_url,
  50. 'title': title,
  51. 'description': description,
  52. 'thumbnail': thumbnail,
  53. 'timestamp': timestamp,
  54. 'width': width,
  55. 'height': height,
  56. 'duration': duration,
  57. 'view_count': view_count,
  58. 'like_count': like_count,
  59. }