]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/drtuber.py
Update changelog.
[youtubedl] / youtube_dl / extractor / drtuber.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import (
7 NO_DEFAULT,
8 str_to_int,
9 )
10
11
12 class DrTuberIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?drtuber\.com/video/(?P<id>\d+)/(?P<display_id>[\w-]+)'
14 _TEST = {
15 'url': 'http://www.drtuber.com/video/1740434/hot-perky-blonde-naked-golf',
16 'md5': '93e680cf2536ad0dfb7e74d94a89facd',
17 'info_dict': {
18 'id': '1740434',
19 'display_id': 'hot-perky-blonde-naked-golf',
20 'ext': 'mp4',
21 'title': 'hot perky blonde naked golf',
22 'like_count': int,
23 'comment_count': int,
24 'categories': ['Babe', 'Blonde', 'Erotic', 'Outdoor', 'Softcore', 'Solo'],
25 'thumbnail': 're:https?://.*\.jpg$',
26 'age_limit': 18,
27 }
28 }
29
30 def _real_extract(self, url):
31 mobj = re.match(self._VALID_URL, url)
32 video_id = mobj.group('id')
33 display_id = mobj.group('display_id')
34
35 webpage = self._download_webpage(url, display_id)
36
37 video_url = self._html_search_regex(
38 r'<source src="([^"]+)"', webpage, 'video URL')
39
40 title = self._html_search_regex(
41 (r'class="title_watch"[^>]*><p>([^<]+)<',
42 r'<p[^>]+class="title_substrate">([^<]+)</p>',
43 r'<title>([^<]+) - \d+'),
44 webpage, 'title')
45
46 thumbnail = self._html_search_regex(
47 r'poster="([^"]+)"',
48 webpage, 'thumbnail', fatal=False)
49
50 def extract_count(id_, name, default=NO_DEFAULT):
51 return str_to_int(self._html_search_regex(
52 r'<span[^>]+(?:class|id)="%s"[^>]*>([\d,\.]+)</span>' % id_,
53 webpage, '%s count' % name, default=default, fatal=False))
54
55 like_count = extract_count('rate_likes', 'like')
56 dislike_count = extract_count('rate_dislikes', 'dislike', default=None)
57 comment_count = extract_count('comments_count', 'comment')
58
59 cats_str = self._search_regex(
60 r'<div[^>]+class="categories_list">(.+?)</div>',
61 webpage, 'categories', fatal=False)
62 categories = [] if not cats_str else re.findall(
63 r'<a title="([^"]+)"', cats_str)
64
65 return {
66 'id': video_id,
67 'display_id': display_id,
68 'url': video_url,
69 'title': title,
70 'thumbnail': thumbnail,
71 'like_count': like_count,
72 'dislike_count': dislike_count,
73 'comment_count': comment_count,
74 'categories': categories,
75 'age_limit': self._rta_search(webpage),
76 }