1 from __future__ import unicode_literals
5 from .common import InfoExtractor
8 compat_urllib_parse_unquote,
16 class XTubeIE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?(?P<url>xtube\.com/watch\.php\?v=(?P<id>[^/?&#]+))'
19 'url': 'http://www.xtube.com/watch.php?v=kVTUy_G222_',
20 'md5': '092fbdd3cbe292c920ef6fc6a8a9cdab',
24 'title': 'strange erotica',
25 'description': 'contains:an ET kind of thing',
26 'uploader': 'greenshowers',
32 def _real_extract(self, url):
33 video_id = self._match_id(url)
35 req = compat_urllib_request.Request(url)
36 req.add_header('Cookie', 'age_verified=1')
37 webpage = self._download_webpage(req, video_id)
39 video_title = self._html_search_regex(
40 r'<p class="title">([^<]+)', webpage, 'title')
41 video_uploader = self._html_search_regex(
42 [r"var\s+contentOwnerId\s*=\s*'([^']+)",
43 r'By:\s*<a href="/community/profile\.php\?user=([^"]+)'],
44 webpage, 'uploader', fatal=False)
45 video_description = self._html_search_regex(
46 r'<p class="fieldsDesc">([^<]+)',
47 webpage, 'description', fatal=False)
48 duration = parse_duration(self._html_search_regex(
49 r'<span class="bold">Runtime:</span> ([^<]+)</p>',
50 webpage, 'duration', fatal=False))
51 view_count = str_to_int(self._html_search_regex(
52 r'<span class="bold">Views:</span> ([\d,\.]+)</p>',
53 webpage, 'view count', fatal=False))
54 comment_count = str_to_int(self._html_search_regex(
55 r'<div id="commentBar">([\d,\.]+) Comments</div>',
56 webpage, 'comment count', fatal=False))
59 for format_id, video_url in re.findall(
60 r'flashvars\.quality_(.+?)\s*=\s*"([^"]+)"', webpage):
62 'url': compat_urllib_parse_unquote(video_url),
63 'format_id': format_id,
65 m = re.search(r'^(?P<height>\d+)[pP]', format_id)
67 fmt['height'] = int(m.group('height'))
71 video_url = compat_urllib_parse_unquote(self._search_regex(
72 r'flashvars\.video_url\s*=\s*"([^"]+)"',
73 webpage, 'video URL'))
74 formats.append({'url': video_url})
76 self._sort_formats(formats)
81 'uploader': video_uploader,
82 'description': video_description,
84 'view_count': view_count,
85 'comment_count': comment_count,
91 class XTubeUserIE(InfoExtractor):
92 IE_DESC = 'XTube user profile'
93 _VALID_URL = r'https?://(?:www\.)?xtube\.com/community/profile\.php\?(.*?)user=(?P<username>[^&#]+)(?:$|[&#])'
95 'url': 'http://www.xtube.com/community/profile.php?user=greenshowers',
100 'playlist_mincount': 155,
103 def _real_extract(self, url):
104 mobj = re.match(self._VALID_URL, url)
105 username = mobj.group('username')
107 profile_page = self._download_webpage(
108 url, username, note='Retrieving profile page')
110 video_count = int(self._search_regex(
111 r'<strong>%s\'s Videos \(([0-9]+)\)</strong>' % username, profile_page,
116 page_count = (video_count + PAGE_SIZE + 1) // PAGE_SIZE
117 for n in range(1, page_count + 1):
118 lpage_url = 'http://www.xtube.com/user_videos.php?page=%d&u=%s' % (n, username)
119 lpage = self._download_webpage(
121 note='Downloading page %d/%d' % (n, page_count))
123 re.findall(r'addthis:url="([^"]+)"', lpage))