1 from __future__ import unicode_literals
6 from .common import InfoExtractor
16 class XTubeIE(InfoExtractor):
20 https?://(?:www\.)?xtube\.com/(?:watch\.php\?.*\bv=|video-watch/(?P<display_id>[^/]+)-)
27 'url': 'http://www.xtube.com/watch.php?v=kVTUy_G222_',
28 'md5': '092fbdd3cbe292c920ef6fc6a8a9cdab',
32 'title': 'strange erotica',
33 'description': 'contains:an ET kind of thing',
34 'uploader': 'greenshowers',
42 'url': 'http://www.xtube.com/video-watch/strange-erotica-625837',
43 'only_matching': True,
45 'url': 'xtube:625837',
46 'only_matching': True,
49 def _real_extract(self, url):
50 mobj = re.match(self._VALID_URL, url)
51 video_id = mobj.group('id')
52 display_id = mobj.group('display_id')
56 url = 'http://www.xtube.com/video-watch/-%s' % video_id
58 req = sanitized_Request(url)
59 req.add_header('Cookie', 'age_verified=1; cookiesAccepted=1')
60 webpage = self._download_webpage(req, display_id)
62 sources = self._parse_json(self._search_regex(
63 r'(["\'])sources\1\s*:\s*(?P<sources>{.+?}),',
64 webpage, 'sources', group='sources'), video_id)
67 for format_id, format_url in sources.items():
70 'format_id': format_id,
71 'height': int_or_none(format_id),
73 self._sort_formats(formats)
75 title = self._search_regex(
76 (r'<h1>(?P<title>[^<]+)</h1>', r'videoTitle\s*:\s*(["\'])(?P<title>.+?)\1'),
77 webpage, 'title', group='title')
78 description = self._search_regex(
79 r'</h1>\s*<p>([^<]+)', webpage, 'description', fatal=False)
80 uploader = self._search_regex(
81 (r'<input[^>]+name="contentOwnerId"[^>]+value="([^"]+)"',
82 r'<span[^>]+class="nickname"[^>]*>([^<]+)'),
83 webpage, 'uploader', fatal=False)
84 duration = parse_duration(self._search_regex(
85 r'<dt>Runtime:?</dt>\s*<dd>([^<]+)</dd>',
86 webpage, 'duration', fatal=False))
87 view_count = str_to_int(self._search_regex(
88 r'<dt>Views:?</dt>\s*<dd>([\d,\.]+)</dd>',
89 webpage, 'view count', fatal=False))
90 comment_count = str_to_int(self._html_search_regex(
91 r'>Comments? \(([\d,\.]+)\)<',
92 webpage, 'comment count', fatal=False))
96 'display_id': display_id,
98 'description': description,
100 'duration': duration,
101 'view_count': view_count,
102 'comment_count': comment_count,
108 class XTubeUserIE(InfoExtractor):
109 IE_DESC = 'XTube user profile'
110 _VALID_URL = r'https?://(?:www\.)?xtube\.com/profile/(?P<id>[^/]+-\d+)'
112 'url': 'http://www.xtube.com/profile/greenshowers-4056496',
114 'id': 'greenshowers-4056496',
117 'playlist_mincount': 155,
120 def _real_extract(self, url):
121 user_id = self._match_id(url)
124 for pagenum in itertools.count(1):
125 request = sanitized_Request(
126 'http://www.xtube.com/profile/%s/videos/%d' % (user_id, pagenum),
128 'Cookie': 'popunder=4',
129 'X-Requested-With': 'XMLHttpRequest',
133 page = self._download_json(
134 request, user_id, 'Downloading videos JSON page %d' % pagenum)
136 html = page.get('html')
140 for video_id in orderedSet([video_id for _, video_id in re.findall(
141 r'data-plid=(["\'])(.+?)\1', html)]):
142 entries.append(self.url_result('xtube:%s' % video_id, XTubeIE.ie_key()))
144 page_count = int_or_none(page.get('pageCount'))
145 if not page_count or pagenum == page_count:
148 playlist = self.playlist_result(entries, user_id)
149 playlist['age_limit'] = 18