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