3 from .common
import InfoExtractor
7 compat_urllib_parse_unquote
,
22 class FourTubeBaseIE(InfoExtractor
):
23 def _extract_formats(self
, url
, video_id
, media_id
, sources
):
24 token_url
= 'https://%s/%s/desktop/%s' % (
25 self
._TKN
_HOST
, media_id
, '+'.join(sources
))
27 parsed_url
= compat_urlparse
.urlparse(url
)
28 tokens
= self
._download
_json
(token_url
, video_id
, data
=b
'', headers
={
29 'Origin': '%s://%s' % (parsed_url
.scheme
, parsed_url
.hostname
),
33 'url': tokens
[format
]['token'],
34 'format_id': format
+ 'p',
35 'resolution': format
+ 'p',
36 'quality': int(format
),
37 } for format
in sources
]
40 def _real_extract(self
, url
):
41 mobj
= self
._match
_valid
_url
(url
)
42 kind
, video_id
, display_id
= mobj
.group('kind', 'id', 'display_id')
44 if kind
== 'm' or not display_id
:
45 url
= self
._URL
_TEMPLATE
% video_id
47 webpage
= self
._download
_webpage
(url
, video_id
)
49 title
= self
._html
_search
_meta
('name', webpage
)
50 timestamp
= parse_iso8601(self
._html
_search
_meta
(
51 'uploadDate', webpage
))
52 thumbnail
= self
._html
_search
_meta
('thumbnailUrl', webpage
)
53 uploader_id
= self
._html
_search
_regex
(
54 r
'<a class="item-to-subscribe" href="[^"]+/(?:channel|user)s?/([^/"]+)" title="Go to [^"]+ page">',
55 webpage
, 'uploader id', fatal
=False)
56 uploader
= self
._html
_search
_regex
(
57 r
'<a class="item-to-subscribe" href="[^"]+/(?:channel|user)s?/[^/"]+" title="Go to ([^"]+) page">',
58 webpage
, 'uploader', fatal
=False)
60 categories_html
= self
._search
_regex
(
61 r
'(?s)><i class="icon icon-tag"></i>\s*Categories / Tags\s*.*?<ul class="[^"]*?list[^"]*?">(.*?)</ul>',
62 webpage
, 'categories', fatal
=False)
66 c
.strip() for c
in re
.findall(
67 r
'(?s)<li><a.*?>(.*?)</a>', categories_html
)]
69 view_count
= str_to_int(self
._search
_regex
(
70 r
'<meta[^>]+itemprop="interactionCount"[^>]+content="UserPlays:([0-9,]+)">',
71 webpage
, 'view count', default
=None))
72 like_count
= str_to_int(self
._search
_regex
(
73 r
'<meta[^>]+itemprop="interactionCount"[^>]+content="UserLikes:([0-9,]+)">',
74 webpage
, 'like count', default
=None))
75 duration
= parse_duration(self
._html
_search
_meta
('duration', webpage
))
77 media_id
= self
._search
_regex
(
78 r
'<button[^>]+data-id=(["\'])(?P
<id>\d
+)\
1[^
>]+data
-quality
=', webpage,
79 'media
id', default=None, group='id')
82 for _, quality in re.findall(r'<button
[^
>]+data
-quality
=(["\'])(.+?)\1', webpage)]
83 if not (media_id and sources):
84 player_js = self._download_webpage(
86 r'<script[^>]id=(["\'])playerembed\
1[^
>]+src
=(["\'])(?P<url>.+?)\2',
87 webpage, 'player JS', group='url'),
88 video_id, 'Downloading player JS')
89 params_js = self._search_regex(
90 r'\$\.ajax\(url,\ opts\);\s*\}\s*\}\)\(([0-9,\[\] ]+)\)',
91 player_js, 'initialization parameters')
92 params = self._parse_json('[%s]' % params_js, video_id)
94 sources = ['%s' % p for p in params[2]]
96 formats = self._extract_formats(url, video_id, media_id, sources)
102 'categories': categories,
103 'thumbnail': thumbnail,
104 'uploader': uploader,
105 'uploader_id': uploader_id,
106 'timestamp': timestamp,
107 'like_count': like_count,
108 'view_count': view_count,
109 'duration': duration,
114 class FourTubeIE(FourTubeBaseIE):
116 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?4tube\.com/(?:videos|embed)/(?P<id>\d+)(?:/(?P<display_id>[^/?#&]+))?'
117 _URL_TEMPLATE = 'https://www.4tube.com/videos/%s/video'
118 _TKN_HOST = 'token.4tube.com'
120 'url': 'http://www.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
121 'md5': '6516c8ac63b03de06bc8eac14362db4f',
125 'title': 'Hot Babe Holly Michaels gets her ass stuffed by black',
126 'uploader': 'WCP Club',
127 'uploader_id': 'wcp-club',
128 'upload_date': '20131031',
129 'timestamp': 1383263892,
137 'url': 'http://www.4tube.com/embed/209733',
138 'only_matching': True,
140 'url': 'http://m.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
141 'only_matching': True,
145 class FuxIE(FourTubeBaseIE):
146 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?fux\.com/(?:video|embed)/(?P<id>\d+)(?:/(?P<display_id>[^/?#&]+))?'
147 _URL_TEMPLATE = 'https://www.fux.com/video/%s/video'
148 _TKN_HOST = 'token.fux.com'
150 'url': 'https://www.fux.com/video/195359/awesome-fucking-kitchen-ends-cum-swallow',
154 'title': 'Awesome fucking in the kitchen ends with cum swallow',
155 'uploader': 'alenci2342',
156 'uploader_id': 'alenci2342',
157 'upload_date': '20131230',
158 'timestamp': 1388361660,
166 'skip_download': True,
169 'url': 'https://www.fux.com/embed/195359',
170 'only_matching': True,
172 'url': 'https://www.fux.com/video/195359/awesome-fucking-kitchen-ends-cum-swallow',
173 'only_matching': True,
177 class PornTubeIE(FourTubeBaseIE):
178 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?porntube\.com/(?:videos/(?P<display_id>[^/]+)_|embed/)(?P<id>\d+)'
179 _URL_TEMPLATE = 'https://www.porntube.com/videos/video_%s'
180 _TKN_HOST = 'tkn.porntube.com'
182 'url': 'https://www.porntube.com/videos/teen-couple-doing-anal_7089759',
186 'title': 'Teen couple doing anal',
188 'uploader_id': '91488',
189 'upload_date': '20150606',
190 'timestamp': 1433595647,
197 'skip_download': True,
200 'url': 'https://www.porntube.com/videos/squirting-teen-ballerina-ecg_1331406',
204 'title': 'Squirting Teen Ballerina on ECG',
205 'uploader': 'Exploited College Girls',
206 'uploader_id': '665',
207 'channel': 'Exploited College Girls',
209 'upload_date': '20130920',
210 'timestamp': 1379685485,
217 'skip_download': True,
220 'url': 'https://www.porntube.com/embed/7089759',
221 'only_matching': True,
223 'url': 'https://m.porntube.com/videos/teen-couple-doing-anal_7089759',
224 'only_matching': True,
227 def _real_extract(self, url):
228 mobj = self._match_valid_url(url)
229 video_id, display_id = mobj.group('id', 'display_id')
231 webpage = self._download_webpage(url, display_id)
233 video = self._parse_json(
235 r'INITIALSTATE\s*=\s*(["\'])(?P
<value
>(?
:(?
!\
1).)+)\
1',
236 webpage, 'data
', group='value
'), video_id,
237 transform_source=lambda x: compat_urllib_parse_unquote(
238 compat_b64decode(x).decode('utf
-8')))['page
']['video
']
240 title = video['title
']
241 media_id = video['mediaId
']
242 sources = [compat_str(e['height
'])
243 for e in video['encodings
'] if e.get('height
')]
244 formats = self._extract_formats(url, video_id, media_id, sources)
246 thumbnail = url_or_none(video.get('masterThumb
'))
247 uploader = try_get(video, lambda x: x['user
']['username
'], compat_str)
248 uploader_id = str_or_none(try_get(
249 video, lambda x: x['user
']['id'], int))
250 channel = try_get(video, lambda x: x['channel
']['name
'], compat_str)
251 channel_id = str_or_none(try_get(
252 video, lambda x: x['channel
']['id'], int))
253 like_count = int_or_none(video.get('likes
'))
254 dislike_count = int_or_none(video.get('dislikes
'))
255 view_count = int_or_none(video.get('playsQty
'))
256 duration = int_or_none(video.get('durationInSeconds
'))
257 timestamp = unified_timestamp(video.get('publishedAt
'))
263 'thumbnail
': thumbnail,
264 'uploader
': uploader or channel,
265 'uploader_id
': uploader_id or channel_id,
267 'channel_id
': channel_id,
268 'timestamp
': timestamp,
269 'like_count
': like_count,
270 'dislike_count
': dislike_count,
271 'view_count
': view_count,
272 'duration
': duration,
277 class PornerBrosIE(FourTubeBaseIE):
278 _VALID_URL = r'https?
://(?
:(?P
<kind
>www|m
)\
.)?pornerbros\
.com
/(?
:videos
/(?P
<display_id
>[^
/]+)_|embed
/)(?P
<id>\d
+)'
279 _URL_TEMPLATE = 'https
://www
.pornerbros
.com
/videos
/video_
%s'
280 _TKN_HOST = 'token
.pornerbros
.com
'
282 'url
': 'https
://www
.pornerbros
.com
/videos
/skinny
-brunette
-takes
-big
-cock
-down
-her
-anal
-hole_181369
',
283 'md5
': '6516c8ac63b03de06bc8eac14362db4f
',
287 'title
': 'Skinny brunette takes big cock down her anal hole
',
288 'uploader
': 'PornerBros HD
',
289 'uploader_id
': 'pornerbros
-hd
',
290 'upload_date
': '20130130',
291 'timestamp
': 1359527401,
298 'skip_download
': True,
301 'url
': 'https
://www
.pornerbros
.com
/embed
/181369',
302 'only_matching
': True,
304 'url
': 'https
://m
.pornerbros
.com
/videos
/skinny
-brunette
-takes
-big
-cock
-down
-her
-anal
-hole_181369
',
305 'only_matching
': True,