]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/drtuber.py
Merge branch 'fstirlitz-filmon'
[yt-dlp.git] / youtube_dl / extractor / drtuber.py
CommitLineData
d740f7e1 1from __future__ import unicode_literals
2
3import re
4
5from .common import InfoExtractor
0aef0771
S
6from ..utils import (
7 NO_DEFAULT,
8 str_to_int,
9)
d740f7e1 10
11
12class DrTuberIE(InfoExtractor):
519d8970
S
13 _VALID_URL = r'https?://(?:www\.)?drtuber\.com/(?:video|embed)/(?P<id>\d+)(?:/(?P<display_id>[\w-]+))?'
14 _TESTS = [{
d740f7e1 15 'url': 'http://www.drtuber.com/video/1740434/hot-perky-blonde-naked-golf',
16 'md5': '93e680cf2536ad0dfb7e74d94a89facd',
17 'info_dict': {
18 'id': '1740434',
33422c05 19 'display_id': 'hot-perky-blonde-naked-golf',
d740f7e1 20 'ext': 'mp4',
76d1466b 21 'title': 'hot perky blonde naked golf',
eade1d7e 22 'like_count': int,
eade1d7e 23 'comment_count': int,
2914e5f0 24 'categories': ['Babe', 'Blonde', 'Erotic', 'Outdoor', 'Softcore', 'Solo'],
ec85ded8 25 'thumbnail': r're:https?://.*\.jpg$',
11fc065c 26 'age_limit': 18,
d740f7e1 27 }
519d8970
S
28 }, {
29 'url': 'http://www.drtuber.com/embed/489939',
30 'only_matching': True,
31 }]
d740f7e1 32
37e7a71c
S
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
d740f7e1 39 def _real_extract(self, url):
40 mobj = re.match(self._VALID_URL, url)
41 video_id = mobj.group('id')
519d8970 42 display_id = mobj.group('display_id') or video_id
d740f7e1 43
519d8970
S
44 webpage = self._download_webpage(
45 'http://www.drtuber.com/video/%s' % video_id, display_id)
d740f7e1 46
47 video_url = self._html_search_regex(
48 r'<source src="([^"]+)"', webpage, 'video URL')
49
50 title = self._html_search_regex(
f5c4b06f 51 (r'class="title_watch"[^>]*><(?:p|h\d+)[^>]*>([^<]+)<',
367976d4
S
52 r'<p[^>]+class="title_substrate">([^<]+)</p>',
53 r'<title>([^<]+) - \d+'),
76d1466b 54 webpage, 'title')
d740f7e1 55
56 thumbnail = self._html_search_regex(
57 r'poster="([^"]+)"',
58 webpage, 'thumbnail', fatal=False)
59
0aef0771 60 def extract_count(id_, name, default=NO_DEFAULT):
86511ea4
S
61 return str_to_int(self._html_search_regex(
62 r'<span[^>]+(?:class|id)="%s"[^>]*>([\d,\.]+)</span>' % id_,
0aef0771 63 webpage, '%s count' % name, default=default, fatal=False))
86511ea4
S
64
65 like_count = extract_count('rate_likes', 'like')
0aef0771 66 dislike_count = extract_count('rate_dislikes', 'dislike', default=None)
86511ea4 67 comment_count = extract_count('comments_count', 'comment')
eade1d7e 68
2914e5f0 69 cats_str = self._search_regex(
0aef0771
S
70 r'<div[^>]+class="categories_list">(.+?)</div>',
71 webpage, 'categories', fatal=False)
72 categories = [] if not cats_str else re.findall(
73 r'<a title="([^"]+)"', cats_str)
d740f7e1 74
75 return {
76 'id': video_id,
1bf8cf5c 77 'display_id': display_id,
d740f7e1 78 'url': video_url,
79 'title': title,
80 'thumbnail': thumbnail,
eade1d7e
S
81 'like_count': like_count,
82 'dislike_count': dislike_count,
83 'comment_count': comment_count,
d740f7e1 84 'categories': categories,
11fc065c 85 'age_limit': self._rta_search(webpage),
d740f7e1 86 }