Add support for drtuber.com
[youtube-dl] / youtube_dl / extractor / drtuber.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class DrTuberIE(InfoExtractor):
9     _VALID_URL = r'https?://(?:www\.)?drtuber\.com/video/(?P<id>\d+)/(?P<title_dash>[\w-]+)'
10     _TEST = {
11         'url': 'http://www.drtuber.com/video/1740434/hot-perky-blonde-naked-golf',
12         'md5': '93e680cf2536ad0dfb7e74d94a89facd',
13         'info_dict': {
14             'id': '1740434',
15             'ext': 'mp4',
16             'title': 'Hot Perky Blonde Naked Golf',
17             'categories': list,  # NSFW
18             'thumbnail': 're:https?://.*\.jpg$',
19         }
20     }
21
22     def _real_extract(self, url):
23         mobj = re.match(self._VALID_URL, url)
24         video_id = mobj.group('id')
25
26         webpage = self._download_webpage(url, video_id)
27
28         video_url = self._html_search_regex(
29             r'<source src="([^"]+)"', webpage, 'video URL')
30
31         title = self._html_search_regex(
32             r'<title>([^<]+)\s*-\s*Free', webpage, 'title')
33
34         thumbnail = self._html_search_regex(
35             r'poster="([^"]+)"',
36             webpage, 'thumbnail', fatal=False)
37
38         categories_str = self._html_search_regex(
39             r'<meta name="keywords" content="([^"]+)"', webpage, 'categories', fatal=False)
40         categories = categories_str.split(' ')
41
42         return {
43             'id': video_id,
44             'url': video_url,
45             'title': title,
46             'thumbnail': thumbnail,
47             'categories': categories,
48         }