1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
17 class XTubeIE(InfoExtractor
):
21 https?://(?:www\.)?xtube\.com/(?:watch\.php\?.*\bv=|video-watch/(?:embedded/)?(?P<display_id>[^/]+)-)
28 'url': 'http://www.xtube.com/watch.php?v=kVTUy_G222_',
29 'md5': '092fbdd3cbe292c920ef6fc6a8a9cdab',
33 'title': 'strange erotica',
34 'description': 'contains:an ET kind of thing',
35 'uploader': 'greenshowers',
43 'url': 'http://www.xtube.com/video-watch/strange-erotica-625837',
44 'only_matching': True,
46 'url': 'xtube:625837',
47 'only_matching': True,
49 'url': 'xtube:kVTUy_G222_',
50 'only_matching': True,
52 'url': 'https://www.xtube.com/video-watch/embedded/milf-tara-and-teen-shared-and-cum-covered-extreme-bukkake-32203482?embedsize=big',
53 'only_matching': True,
56 def _real_extract(self
, url
):
57 mobj
= re
.match(self
._VALID
_URL
, url
)
58 video_id
= mobj
.group('id')
59 display_id
= mobj
.group('display_id')
64 if video_id
.isdigit() and len(video_id
) < 11:
65 url_pattern
= 'http://www.xtube.com/video-watch/-%s'
67 url_pattern
= 'http://www.xtube.com/watch.php?v=%s'
69 webpage
= self
._download
_webpage
(
70 url_pattern
% video_id
, display_id
, headers
={
71 'Cookie': 'age_verified=1; cookiesAccepted=1',
74 title
, thumbnail
, duration
= [None] * 3
76 config
= self
._parse
_json
(self
._search
_regex
(
77 r
'playerConf\s*=\s*({.+?})\s*,\s*(?:\n|loaderConf)', webpage
, 'config',
78 default
='{}'), video_id
, transform_source
=js_to_json
, fatal
=False)
80 config
= config
.get('mainRoll')
81 if isinstance(config
, dict):
82 title
= config
.get('title')
83 thumbnail
= config
.get('poster')
84 duration
= int_or_none(config
.get('duration'))
85 sources
= config
.get('sources') or config
.get('format')
87 if not isinstance(sources
, dict):
88 sources
= self
._parse
_json
(self
._search
_regex
(
89 r
'(["\'])?sources\
1?\s
*:\s
*(?P
<sources
>{.+?}
),',
90 webpage, 'sources
', group='sources
'), video_id,
91 transform_source=js_to_json)
94 for format_id, format_url in sources.items():
97 'format_id
': format_id,
98 'height
': int_or_none(format_id),
100 self._remove_duplicate_formats(formats)
101 self._sort_formats(formats)
104 title = self._search_regex(
105 (r'<h1
>\s
*(?P
<title
>[^
<]+?
)\s
*</h1
>', r'videoTitle\s
*:\s
*(["\'])(?P<title>.+?)\1'),
106 webpage, 'title', group='title')
107 description = self._og_search_description(
108 webpage, default=None) or self._html_search_meta(
109 'twitter:description', webpage, default=None) or self._search_regex(
110 r'</h1>\s*<p>([^<]+)', webpage, 'description', fatal=False)
111 uploader = self._search_regex(
112 (r'<input[^>]+name="contentOwnerId
"[^>]+value="([^
"]+)"',
113 r'<span
[^
>]+class="nickname"[^
>]*>([^
<]+)'),
114 webpage, 'uploader
', fatal=False)
116 duration = parse_duration(self._search_regex(
117 r'<dt
>Runtime
:?
</dt
>\s
*<dd
>([^
<]+)</dd
>',
118 webpage, 'duration
', fatal=False))
119 view_count = str_to_int(self._search_regex(
120 (r'["\']viewsCount["\'][^
>]*>(\d
+)\s
+views
',
121 r'<dt
>Views
:?
</dt
>\s
*<dd
>([\d
,\
.]+)</dd
>'),
122 webpage, 'view count
', fatal=False))
123 comment_count = str_to_int(self._html_search_regex(
124 r'>Comments? \
(([\d
,\
.]+)\
)<',
125 webpage, 'comment count
', fatal=False))
129 'display_id
': display_id,
131 'description
': description,
132 'thumbnail
': thumbnail,
133 'uploader
': uploader,
134 'duration
': duration,
135 'view_count
': view_count,
136 'comment_count
': comment_count,
142 class XTubeUserIE(InfoExtractor):
143 IE_DESC = 'XTube user profile
'
144 _VALID_URL = r'https?
://(?
:www\
.)?xtube\
.com
/profile
/(?P
<id>[^
/]+-\d
+)'
146 'url
': 'http
://www
.xtube
.com
/profile
/greenshowers
-4056496',
148 'id': 'greenshowers
-4056496',
151 'playlist_mincount
': 154,
154 def _real_extract(self, url):
155 user_id = self._match_id(url)
158 for pagenum in itertools.count(1):
159 request = sanitized_Request(
160 'http
://www
.xtube
.com
/profile
/%s/videos
/%d' % (user_id, pagenum),
162 'Cookie
': 'popunder
=4',
163 'X
-Requested
-With
': 'XMLHttpRequest
',
167 page = self._download_json(
168 request, user_id, 'Downloading videos JSON page
%d' % pagenum)
170 html = page.get('html
')
174 for video_id in orderedSet([video_id for _, video_id in re.findall(
175 r'data
-plid
=(["\'])(.+?)\1', html)]):
176 entries.append(self.url_result('xtube:%s' % video_id, XTubeIE.ie_key()))
178 page_count = int_or_none(page.get('pageCount'))
179 if not page_count or pagenum == page_count:
182 playlist = self.playlist_result(entries, user_id)
183 playlist['age_limit'] = 18