1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
9 compat_urllib_parse_unquote
,
24 class FourTubeBaseIE(InfoExtractor
):
25 def _extract_formats(self
, url
, video_id
, media_id
, sources
):
26 token_url
= 'https://%s/%s/desktop/%s' % (
27 self
._TKN
_HOST
, media_id
, '+'.join(sources
))
29 parsed_url
= compat_urlparse
.urlparse(url
)
30 tokens
= self
._download
_json
(token_url
, video_id
, data
=b
'', headers
={
31 'Origin': '%s://%s' % (parsed_url
.scheme
, parsed_url
.hostname
),
35 'url': tokens
[format
]['token'],
36 'format_id': format
+ 'p',
37 'resolution': format
+ 'p',
38 'quality': int(format
),
39 } for format
in sources
]
40 self
._sort
_formats
(formats
)
43 def _real_extract(self
, url
):
44 mobj
= re
.match(self
._VALID
_URL
, url
)
45 kind
, video_id
, display_id
= mobj
.group('kind', 'id', 'display_id')
47 if kind
== 'm' or not display_id
:
48 url
= self
._URL
_TEMPLATE
% video_id
50 webpage
= self
._download
_webpage
(url
, video_id
)
52 title
= self
._html
_search
_meta
('name', webpage
)
53 timestamp
= parse_iso8601(self
._html
_search
_meta
(
54 'uploadDate', webpage
))
55 thumbnail
= self
._html
_search
_meta
('thumbnailUrl', webpage
)
56 uploader_id
= self
._html
_search
_regex
(
57 r
'<a class="item-to-subscribe" href="[^"]+/(?:channel|user)s?/([^/"]+)" title="Go to [^"]+ page">',
58 webpage
, 'uploader id', fatal
=False)
59 uploader
= self
._html
_search
_regex
(
60 r
'<a class="item-to-subscribe" href="[^"]+/(?:channel|user)s?/[^/"]+" title="Go to ([^"]+) page">',
61 webpage
, 'uploader', fatal
=False)
63 categories_html
= self
._search
_regex
(
64 r
'(?s)><i class="icon icon-tag"></i>\s*Categories / Tags\s*.*?<ul class="[^"]*?list[^"]*?">(.*?)</ul>',
65 webpage
, 'categories', fatal
=False)
69 c
.strip() for c
in re
.findall(
70 r
'(?s)<li><a.*?>(.*?)</a>', categories_html
)]
72 view_count
= str_to_int(self
._search
_regex
(
73 r
'<meta[^>]+itemprop="interactionCount"[^>]+content="UserPlays:([0-9,]+)">',
74 webpage
, 'view count', default
=None))
75 like_count
= str_to_int(self
._search
_regex
(
76 r
'<meta[^>]+itemprop="interactionCount"[^>]+content="UserLikes:([0-9,]+)">',
77 webpage
, 'like count', default
=None))
78 duration
= parse_duration(self
._html
_search
_meta
('duration', webpage
))
80 media_id
= self
._search
_regex
(
81 r
'<button[^>]+data-id=(["\'])(?P
<id>\d
+)\
1[^
>]+data
-quality
=', webpage,
82 'media
id', default=None, group='id')
85 for _, quality in re.findall(r'<button
[^
>]+data
-quality
=(["\'])(.+?)\1', webpage)]
86 if not (media_id and sources):
87 player_js = self._download_webpage(
89 r'<script[^>]id=(["\'])playerembed\
1[^
>]+src
=(["\'])(?P<url>.+?)\2',
90 webpage, 'player JS', group='url'),
91 video_id, 'Downloading player JS')
92 params_js = self._search_regex(
93 r'\$\.ajax\(url,\ opts\);\s*\}\s*\}\)\(([0-9,\[\] ]+)\)',
94 player_js, 'initialization parameters')
95 params = self._parse_json('[%s]' % params_js, video_id)
97 sources = ['%s' % p for p in params[2]]
99 formats = self._extract_formats(url, video_id, media_id, sources)
105 'categories': categories,
106 'thumbnail': thumbnail,
107 'uploader': uploader,
108 'uploader_id': uploader_id,
109 'timestamp': timestamp,
110 'like_count': like_count,
111 'view_count': view_count,
112 'duration': duration,
117 class FourTubeIE(FourTubeBaseIE):
119 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?4tube\.com/(?:videos|embed)/(?P<id>\d+)(?:/(?P<display_id>[^/?#&]+))?'
120 _URL_TEMPLATE = 'https://www.4tube.com/videos/%s/video'
121 _TKN_HOST = 'token.4tube.com'
123 'url': 'http://www.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
124 'md5': '6516c8ac63b03de06bc8eac14362db4f',
128 'title': 'Hot Babe Holly Michaels gets her ass stuffed by black',
129 'uploader': 'WCP Club',
130 'uploader_id': 'wcp-club',
131 'upload_date': '20131031',
132 'timestamp': 1383263892,
140 'url': 'http://www.4tube.com/embed/209733',
141 'only_matching': True,
143 'url': 'http://m.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
144 'only_matching': True,
148 class FuxIE(FourTubeBaseIE):
149 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?fux\.com/(?:video|embed)/(?P<id>\d+)(?:/(?P<display_id>[^/?#&]+))?'
150 _URL_TEMPLATE = 'https://www.fux.com/video/%s/video'
151 _TKN_HOST = 'token.fux.com'
153 'url': 'https://www.fux.com/video/195359/awesome-fucking-kitchen-ends-cum-swallow',
157 'title': 'Awesome fucking in the kitchen ends with cum swallow',
158 'uploader': 'alenci2342',
159 'uploader_id': 'alenci2342',
160 'upload_date': '20131230',
161 'timestamp': 1388361660,
169 'skip_download': True,
172 'url': 'https://www.fux.com/embed/195359',
173 'only_matching': True,
175 'url': 'https://www.fux.com/video/195359/awesome-fucking-kitchen-ends-cum-swallow',
176 'only_matching': True,
180 class PornTubeIE(FourTubeBaseIE):
181 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?porntube\.com/(?:videos/(?P<display_id>[^/]+)_|embed/)(?P<id>\d+)'
182 _URL_TEMPLATE = 'https://www.porntube.com/videos/video_%s'
183 _TKN_HOST = 'tkn.porntube.com'
185 'url': 'https://www.porntube.com/videos/teen-couple-doing-anal_7089759',
189 'title': 'Teen couple doing anal',
191 'uploader_id': '91488',
192 'upload_date': '20150606',
193 'timestamp': 1433595647,
200 'skip_download': True,
203 'url': 'https://www.porntube.com/videos/squirting-teen-ballerina-ecg_1331406',
207 'title': 'Squirting Teen Ballerina on ECG',
208 'uploader': 'Exploited College Girls',
209 'uploader_id': '665',
210 'channel': 'Exploited College Girls',
212 'upload_date': '20130920',
213 'timestamp': 1379685485,
220 'skip_download': True,
223 'url': 'https://www.porntube.com/embed/7089759',
224 'only_matching': True,
226 'url': 'https://m.porntube.com/videos/teen-couple-doing-anal_7089759',
227 'only_matching': True,
230 def _real_extract(self, url):
231 mobj = re.match(self._VALID_URL, url)
232 video_id, display_id = mobj.group('id', 'display_id')
234 webpage = self._download_webpage(url, display_id)
236 video = self._parse_json(
238 r'INITIALSTATE\s*=\s*(["\'])(?P
<value
>(?
:(?
!\
1).)+)\
1',
239 webpage, 'data
', group='value
'), video_id,
240 transform_source=lambda x: compat_urllib_parse_unquote(
241 compat_b64decode(x).decode('utf
-8')))['page
']['video
']
243 title = video['title
']
244 media_id = video['mediaId
']
245 sources = [compat_str(e['height
'])
246 for e in video['encodings
'] if e.get('height
')]
247 formats = self._extract_formats(url, video_id, media_id, sources)
249 thumbnail = url_or_none(video.get('masterThumb
'))
250 uploader = try_get(video, lambda x: x['user
']['username
'], compat_str)
251 uploader_id = str_or_none(try_get(
252 video, lambda x: x['user
']['id'], int))
253 channel = try_get(video, lambda x: x['channel
']['name
'], compat_str)
254 channel_id = str_or_none(try_get(
255 video, lambda x: x['channel
']['id'], int))
256 like_count = int_or_none(video.get('likes
'))
257 dislike_count = int_or_none(video.get('dislikes
'))
258 view_count = int_or_none(video.get('playsQty
'))
259 duration = int_or_none(video.get('durationInSeconds
'))
260 timestamp = unified_timestamp(video.get('publishedAt
'))
266 'thumbnail
': thumbnail,
267 'uploader
': uploader or channel,
268 'uploader_id
': uploader_id or channel_id,
270 'channel_id
': channel_id,
271 'timestamp
': timestamp,
272 'like_count
': like_count,
273 'dislike_count
': dislike_count,
274 'view_count
': view_count,
275 'duration
': duration,
280 class PornerBrosIE(FourTubeBaseIE):
281 _VALID_URL = r'https?
://(?
:(?P
<kind
>www|m
)\
.)?pornerbros\
.com
/(?
:videos
/(?P
<display_id
>[^
/]+)_|embed
/)(?P
<id>\d
+)'
282 _URL_TEMPLATE = 'https
://www
.pornerbros
.com
/videos
/video_
%s'
283 _TKN_HOST = 'token
.pornerbros
.com
'
285 'url
': 'https
://www
.pornerbros
.com
/videos
/skinny
-brunette
-takes
-big
-cock
-down
-her
-anal
-hole_181369
',
286 'md5
': '6516c8ac63b03de06bc8eac14362db4f
',
290 'title
': 'Skinny brunette takes big cock down her anal hole
',
291 'uploader
': 'PornerBros HD
',
292 'uploader_id
': 'pornerbros
-hd
',
293 'upload_date
': '20130130',
294 'timestamp
': 1359527401,
301 'skip_download
': True,
304 'url
': 'https
://www
.pornerbros
.com
/embed
/181369',
305 'only_matching
': True,
307 'url
': 'https
://m
.pornerbros
.com
/videos
/skinny
-brunette
-takes
-big
-cock
-down
-her
-anal
-hole_181369
',
308 'only_matching
': True,