1 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_urllib_parse_unquote
16 class XTubeIE(InfoExtractor):
17 _VALID_URL = r'(?:xtube:|https?://(?:www\.)?xtube\.com/watch\.php\?.*\bv=)(?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 = sanitized_Request('http://www.xtube.com/watch.php?v=%s' % video_id)
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/profile/(?P<id>[^/]+-\d+)'
95 'url': 'http://www.xtube.com/profile/greenshowers-4056496',
97 'id': 'greenshowers-4056496',
100 'playlist_mincount': 155,
103 def _real_extract(self, url):
104 user_id = self._match_id(url)
107 for pagenum in itertools.count(1):
108 request = sanitized_Request(
109 'http://www.xtube.com/profile/%s/videos/%d' % (user_id, pagenum),
111 'Cookie': 'popunder=4',
112 'X-Requested-With': 'XMLHttpRequest',
116 page = self._download_json(
117 request, user_id, 'Downloading videos JSON page %d' % pagenum)
119 html = page.get('html')
123 for _, video_id in re.findall(r'data-plid=(["\'])(.+?)\1', html):
124 entries.append(self.url_result('xtube:%s' % video_id, XTubeIE.ie_key()))
126 page_count = int_or_none(page.get('pageCount'))
127 if not page_count or pagenum == page_count:
130 playlist = self.playlist_result(entries, user_id)
131 playlist['age_limit'] = 18