1 from __future__ import unicode_literals
6 from .common import InfoExtractor
8 compat_urllib_parse_urlparse,
15 class XTubeIE(InfoExtractor):
16 _VALID_URL = r'https?://(?:www\.)?(?P<url>xtube\.com/watch\.php\?v=(?P<videoid>[^/?&]+))'
18 'url': 'http://www.xtube.com/watch.php?v=kVTUy_G222_',
19 'md5': '092fbdd3cbe292c920ef6fc6a8a9cdab',
23 'title': 'strange erotica',
24 'description': 'surreal gay themed erotica...almost an ET kind of thing',
25 'uploader': 'greenshowers',
31 def _real_extract(self, url):
32 mobj = re.match(self._VALID_URL, url)
33 video_id = mobj.group('videoid')
34 url = 'http://www.' + mobj.group('url')
36 req = compat_urllib_request.Request(url)
37 req.add_header('Cookie', 'age_verified=1')
38 webpage = self._download_webpage(req, video_id)
40 video_title = self._html_search_regex(r'<p class="title">([^<]+)', webpage, 'title')
41 video_uploader = self._html_search_regex(
42 r'so_s\.addVariable\("owner_u", "([^"]+)', webpage, 'uploader', fatal=False)
43 video_description = self._html_search_regex(
44 r'<p class="fieldsDesc">([^<]+)', webpage, 'description', fatal=False)
45 video_url = self._html_search_regex(r'var videoMp4 = "([^"]+)', webpage, 'video_url').replace('\\/', '/')
46 duration = parse_duration(self._html_search_regex(
47 r'<span class="bold">Runtime:</span> ([^<]+)</p>', webpage, 'duration', fatal=False))
48 view_count = self._html_search_regex(
49 r'<span class="bold">Views:</span> ([\d,\.]+)</p>', webpage, 'view count', fatal=False)
51 view_count = str_to_int(view_count)
52 comment_count = self._html_search_regex(
53 r'<div id="commentBar">([\d,\.]+) Comments</div>', webpage, 'comment count', fatal=False)
55 comment_count = str_to_int(comment_count)
57 path = compat_urllib_parse_urlparse(video_url).path
58 extension = os.path.splitext(path)[1][1:]
59 format = path.split('/')[5].split('_')[:2]
62 format = "-".join(format)
67 'uploader': video_uploader,
68 'description': video_description,
70 'view_count': view_count,
71 'comment_count': comment_count,