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.

70 lines
2.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import str_to_int
  5. class DrTuberIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?drtuber\.com/video/(?P<id>\d+)/(?P<display_id>[\w-]+)'
  7. _TEST = {
  8. 'url': 'http://www.drtuber.com/video/1740434/hot-perky-blonde-naked-golf',
  9. 'md5': '93e680cf2536ad0dfb7e74d94a89facd',
  10. 'info_dict': {
  11. 'id': '1740434',
  12. 'display_id': 'hot-perky-blonde-naked-golf',
  13. 'ext': 'mp4',
  14. 'title': 'hot perky blonde naked golf',
  15. 'like_count': int,
  16. 'dislike_count': int,
  17. 'comment_count': int,
  18. 'categories': ['Babe', 'Blonde', 'Erotic', 'Outdoor', 'Softcore', 'Solo'],
  19. 'thumbnail': 're:https?://.*\.jpg$',
  20. 'age_limit': 18,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. display_id = mobj.group('display_id')
  27. webpage = self._download_webpage(url, display_id)
  28. video_url = self._html_search_regex(
  29. r'<source src="([^"]+)"', webpage, 'video URL')
  30. title = self._html_search_regex(
  31. [r'<p[^>]+class="title_substrate">([^<]+)</p>', r'<title>([^<]+) - \d+'],
  32. webpage, 'title')
  33. thumbnail = self._html_search_regex(
  34. r'poster="([^"]+)"',
  35. webpage, 'thumbnail', fatal=False)
  36. def extract_count(id_, name):
  37. return str_to_int(self._html_search_regex(
  38. r'<span[^>]+(?:class|id)="%s"[^>]*>([\d,\.]+)</span>' % id_,
  39. webpage, '%s count' % name, fatal=False))
  40. like_count = extract_count('rate_likes', 'like')
  41. dislike_count = extract_count('rate_dislikes', 'dislike')
  42. comment_count = extract_count('comments_count', 'comment')
  43. cats_str = self._search_regex(
  44. r'<div[^>]+class="categories_list">(.+?)</div>', webpage, 'categories', fatal=False)
  45. categories = [] if not cats_str else re.findall(r'<a title="([^"]+)"', cats_str)
  46. return {
  47. 'id': video_id,
  48. 'display_id': display_id,
  49. 'url': video_url,
  50. 'title': title,
  51. 'thumbnail': thumbnail,
  52. 'like_count': like_count,
  53. 'dislike_count': dislike_count,
  54. 'comment_count': comment_count,
  55. 'categories': categories,
  56. 'age_limit': self._rta_search(webpage),
  57. }