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.

106 lines
3.7 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. NO_DEFAULT,
  6. str_to_int,
  7. )
  8. class DrTuberIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:(?:www|m)\.)?drtuber\.com/(?:video|embed)/(?P<id>\d+)(?:/(?P<display_id>[\w-]+))?'
  10. _TESTS = [{
  11. 'url': 'http://www.drtuber.com/video/1740434/hot-perky-blonde-naked-golf',
  12. 'md5': '93e680cf2536ad0dfb7e74d94a89facd',
  13. 'info_dict': {
  14. 'id': '1740434',
  15. 'display_id': 'hot-perky-blonde-naked-golf',
  16. 'ext': 'mp4',
  17. 'title': 'hot perky blonde naked golf',
  18. 'like_count': int,
  19. 'comment_count': int,
  20. 'categories': ['Babe', 'Blonde', 'Erotic', 'Outdoor', 'Softcore', 'Solo'],
  21. 'thumbnail': r're:https?://.*\.jpg$',
  22. 'age_limit': 18,
  23. }
  24. }, {
  25. 'url': 'http://www.drtuber.com/embed/489939',
  26. 'only_matching': True,
  27. }, {
  28. 'url': 'http://m.drtuber.com/video/3893529/lingerie-blowjob-from-beautiful-teen',
  29. 'only_matching': True,
  30. }]
  31. @staticmethod
  32. def _extract_urls(webpage):
  33. return re.findall(
  34. r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//(?:www\.)?drtuber\.com/embed/\d+)',
  35. webpage)
  36. def _real_extract(self, url):
  37. mobj = re.match(self._VALID_URL, url)
  38. video_id = mobj.group('id')
  39. display_id = mobj.group('display_id') or video_id
  40. webpage = self._download_webpage(
  41. 'http://www.drtuber.com/video/%s' % video_id, display_id)
  42. video_data = self._download_json(
  43. 'http://www.drtuber.com/player_config_json/', video_id, query={
  44. 'vid': video_id,
  45. 'embed': 0,
  46. 'aid': 0,
  47. 'domain_id': 0,
  48. })
  49. formats = []
  50. for format_id, video_url in video_data['files'].items():
  51. if video_url:
  52. formats.append({
  53. 'format_id': format_id,
  54. 'quality': 2 if format_id == 'hq' else 1,
  55. 'url': video_url
  56. })
  57. self._sort_formats(formats)
  58. title = self._html_search_regex(
  59. (r'<h1[^>]+class=["\']title[^>]+>([^<]+)',
  60. r'<title>([^<]+)\s*@\s+DrTuber',
  61. r'class="title_watch"[^>]*><(?:p|h\d+)[^>]*>([^<]+)<',
  62. r'<p[^>]+class="title_substrate">([^<]+)</p>',
  63. r'<title>([^<]+) - \d+'),
  64. webpage, 'title')
  65. thumbnail = self._html_search_regex(
  66. r'poster="([^"]+)"',
  67. webpage, 'thumbnail', fatal=False)
  68. def extract_count(id_, name, default=NO_DEFAULT):
  69. return str_to_int(self._html_search_regex(
  70. r'<span[^>]+(?:class|id)="%s"[^>]*>([\d,\.]+)</span>' % id_,
  71. webpage, '%s count' % name, default=default, fatal=False))
  72. like_count = extract_count('rate_likes', 'like')
  73. dislike_count = extract_count('rate_dislikes', 'dislike', default=None)
  74. comment_count = extract_count('comments_count', 'comment')
  75. cats_str = self._search_regex(
  76. r'<div[^>]+class="categories_list">(.+?)</div>',
  77. webpage, 'categories', fatal=False)
  78. categories = [] if not cats_str else re.findall(
  79. r'<a title="([^"]+)"', cats_str)
  80. return {
  81. 'id': video_id,
  82. 'display_id': display_id,
  83. 'formats': formats,
  84. 'title': title,
  85. 'thumbnail': thumbnail,
  86. 'like_count': like_count,
  87. 'dislike_count': dislike_count,
  88. 'comment_count': comment_count,
  89. 'categories': categories,
  90. 'age_limit': self._rta_search(webpage),
  91. }