1 from __future__ import unicode_literals
3 from .common import InfoExtractor
12 class RedTubeIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:(?:www\.)?redtube\.com/|embed\.redtube\.com/\?.*?\bid=)(?P<id>[0-9]+)'
15 'url': 'http://www.redtube.com/66418',
16 'md5': '7b8c22b5e7098a3e1c09709df1126d2d',
20 'title': 'Sucked on a toilet',
21 'upload_date': '20120831',
27 'url': 'http://embed.redtube.com/?bgcolor=000000&id=1443286',
28 'only_matching': True,
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
33 webpage = self._download_webpage(
34 'http://www.redtube.com/%s' % video_id, video_id)
36 if any(s in webpage for s in ['video-deleted-info', '>This video has been removed']):
37 raise ExtractorError('Video %s has been removed' % video_id, expected=True)
39 title = self._html_search_regex(
40 (r'<h1 class="videoTitle[^"]*">(?P<title>.+?)</h1>',
41 r'videoTitle\s*:\s*(["\'])(?P<title>)\1'),
42 webpage, 'title', group='title')
45 sources = self._parse_json(
47 r'sources\s*:\s*({.+?})', webpage, 'source', default='{}'),
48 video_id, fatal=False)
49 if sources and isinstance(sources, dict):
50 for format_id, format_url in sources.items():
54 'format_id': format_id,
55 'height': int_or_none(format_id),
58 video_url = self._html_search_regex(
59 r'<source src="(.+?)" type="video/mp4">', webpage, 'video URL')
60 formats.append({'url': video_url})
61 self._sort_formats(formats)
63 thumbnail = self._og_search_thumbnail(webpage)
64 upload_date = unified_strdate(self._search_regex(
65 r'<span[^>]+class="added-time"[^>]*>ADDED ([^<]+)<',
66 webpage, 'upload date', fatal=False))
67 duration = int_or_none(self._search_regex(
68 r'videoDuration\s*:\s*(\d+)', webpage, 'duration', fatal=False))
69 view_count = str_to_int(self._search_regex(
70 r'<span[^>]*>VIEWS</span></td>\s*<td>([\d,.]+)',
71 webpage, 'view count', fatal=False))
73 # No self-labeling, but they describe themselves as
74 # "Home of Videos Porno"
81 'thumbnail': thumbnail,
82 'upload_date': upload_date,
84 'view_count': view_count,
85 'age_limit': age_limit,