]>
Commit | Line | Data |
---|---|---|
d740f7e1 | 1 | from __future__ import unicode_literals |
2 | ||
3 | import re | |
4 | ||
5 | from .common import InfoExtractor | |
eade1d7e | 6 | from ..utils import str_to_int |
d740f7e1 | 7 | |
8 | ||
9 | class DrTuberIE(InfoExtractor): | |
1bf8cf5c | 10 | _VALID_URL = r'https?://(?:www\.)?drtuber\.com/video/(?P<id>\d+)/(?P<display_id>[\w-]+)' |
d740f7e1 | 11 | _TEST = { |
12 | 'url': 'http://www.drtuber.com/video/1740434/hot-perky-blonde-naked-golf', | |
13 | 'md5': '93e680cf2536ad0dfb7e74d94a89facd', | |
14 | 'info_dict': { | |
15 | 'id': '1740434', | |
16 | 'ext': 'mp4', | |
17 | 'title': 'Hot Perky Blonde Naked Golf', | |
eade1d7e S |
18 | 'like_count': int, |
19 | 'dislike_count': int, | |
20 | 'comment_count': int, | |
d740f7e1 | 21 | 'categories': list, # NSFW |
22 | 'thumbnail': 're:https?://.*\.jpg$', | |
11fc065c | 23 | 'age_limit': 18, |
d740f7e1 | 24 | } |
25 | } | |
26 | ||
27 | def _real_extract(self, url): | |
28 | mobj = re.match(self._VALID_URL, url) | |
29 | video_id = mobj.group('id') | |
1bf8cf5c | 30 | display_id = mobj.group('display_id') |
d740f7e1 | 31 | |
1bf8cf5c | 32 | webpage = self._download_webpage(url, display_id) |
d740f7e1 | 33 | |
34 | video_url = self._html_search_regex( | |
35 | r'<source src="([^"]+)"', webpage, 'video URL') | |
36 | ||
37 | title = self._html_search_regex( | |
38 | r'<title>([^<]+)\s*-\s*Free', webpage, 'title') | |
39 | ||
40 | thumbnail = self._html_search_regex( | |
41 | r'poster="([^"]+)"', | |
42 | webpage, 'thumbnail', fatal=False) | |
43 | ||
eade1d7e S |
44 | like_count = str_to_int(self._html_search_regex( |
45 | r'<span id="rate_likes">\s*<img[^>]+>\s*<span>([\d,\.]+)</span>', | |
46 | webpage, 'like count', fatal=False)) | |
47 | dislike_count = str_to_int(self._html_search_regex( | |
48 | r'<span id="rate_dislikes">\s*<img[^>]+>\s*<span>([\d,\.]+)</span>', | |
49 | webpage, 'like count', fatal=False)) | |
50 | comment_count = str_to_int(self._html_search_regex( | |
51 | r'<span class="comments_count">([\d,\.]+)</span>', | |
52 | webpage, 'comment count', fatal=False)) | |
53 | ||
11fc065c | 54 | cats_str = self._html_search_regex( |
d740f7e1 | 55 | r'<meta name="keywords" content="([^"]+)"', webpage, 'categories', fatal=False) |
11fc065c | 56 | categories = None if cats_str is None else cats_str.split(' ') |
d740f7e1 | 57 | |
58 | return { | |
59 | 'id': video_id, | |
1bf8cf5c | 60 | 'display_id': display_id, |
d740f7e1 | 61 | 'url': video_url, |
62 | 'title': title, | |
63 | 'thumbnail': thumbnail, | |
eade1d7e S |
64 | 'like_count': like_count, |
65 | 'dislike_count': dislike_count, | |
66 | 'comment_count': comment_count, | |
d740f7e1 | 67 | 'categories': categories, |
11fc065c | 68 | 'age_limit': self._rta_search(webpage), |
d740f7e1 | 69 | } |