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.

86 lines
3.0 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\.)?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. @staticmethod
  29. def _extract_urls(webpage):
  30. return re.findall(
  31. r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//(?:www\.)?drtuber\.com/embed/\d+)',
  32. webpage)
  33. def _real_extract(self, url):
  34. mobj = re.match(self._VALID_URL, url)
  35. video_id = mobj.group('id')
  36. display_id = mobj.group('display_id') or video_id
  37. webpage = self._download_webpage(
  38. 'http://www.drtuber.com/video/%s' % video_id, display_id)
  39. video_url = self._html_search_regex(
  40. r'<source src="([^"]+)"', webpage, 'video URL')
  41. title = self._html_search_regex(
  42. (r'class="title_watch"[^>]*><(?:p|h\d+)[^>]*>([^<]+)<',
  43. r'<p[^>]+class="title_substrate">([^<]+)</p>',
  44. r'<title>([^<]+) - \d+'),
  45. webpage, 'title')
  46. thumbnail = self._html_search_regex(
  47. r'poster="([^"]+)"',
  48. webpage, 'thumbnail', fatal=False)
  49. def extract_count(id_, name, default=NO_DEFAULT):
  50. return str_to_int(self._html_search_regex(
  51. r'<span[^>]+(?:class|id)="%s"[^>]*>([\d,\.]+)</span>' % id_,
  52. webpage, '%s count' % name, default=default, fatal=False))
  53. like_count = extract_count('rate_likes', 'like')
  54. dislike_count = extract_count('rate_dislikes', 'dislike', default=None)
  55. comment_count = extract_count('comments_count', 'comment')
  56. cats_str = self._search_regex(
  57. r'<div[^>]+class="categories_list">(.+?)</div>',
  58. webpage, 'categories', fatal=False)
  59. categories = [] if not cats_str else re.findall(
  60. r'<a title="([^"]+)"', cats_str)
  61. return {
  62. 'id': video_id,
  63. 'display_id': display_id,
  64. 'url': video_url,
  65. 'title': title,
  66. 'thumbnail': thumbnail,
  67. 'like_count': like_count,
  68. 'dislike_count': dislike_count,
  69. 'comment_count': comment_count,
  70. 'categories': categories,
  71. 'age_limit': self._rta_search(webpage),
  72. }