logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

drtuber.py (3968B)


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