5 from .common
import InfoExtractor
18 class FourTubeBaseIE(InfoExtractor
):
19 def _extract_formats(self
, url
, video_id
, media_id
, sources
):
20 token_url
= 'https://{}/{}/desktop/{}'.format(
21 self
._TKN
_HOST
, media_id
, '+'.join(sources
))
23 parsed_url
= urllib
.parse
.urlparse(url
)
24 tokens
= self
._download
_json
(token_url
, video_id
, data
=b
'', headers
={
25 'Origin': f
'{parsed_url.scheme}://{parsed_url.hostname}',
29 'url': tokens
[res
]['token'],
30 'format_id': res
+ 'p',
31 'resolution': res
+ 'p',
35 def _real_extract(self
, url
):
36 mobj
= self
._match
_valid
_url
(url
)
37 kind
, video_id
, display_id
= mobj
.group('kind', 'id', 'display_id')
39 if kind
== 'm' or not display_id
:
40 url
= self
._URL
_TEMPLATE
% video_id
42 webpage
= self
._download
_webpage
(url
, video_id
)
44 title
= self
._html
_search
_meta
('name', webpage
)
45 timestamp
= parse_iso8601(self
._html
_search
_meta
(
46 'uploadDate', webpage
))
47 thumbnail
= self
._html
_search
_meta
('thumbnailUrl', webpage
)
48 uploader_id
= self
._html
_search
_regex
(
49 r
'<a class="item-to-subscribe" href="[^"]+/(?:channel|user)s?/([^/"]+)" title="Go to [^"]+ page">',
50 webpage
, 'uploader id', fatal
=False)
51 uploader
= self
._html
_search
_regex
(
52 r
'<a class="item-to-subscribe" href="[^"]+/(?:channel|user)s?/[^/"]+" title="Go to ([^"]+) page">',
53 webpage
, 'uploader', fatal
=False)
55 categories_html
= self
._search
_regex
(
56 r
'(?s)><i class="icon icon-tag"></i>\s*Categories / Tags\s*.*?<ul class="[^"]*?list[^"]*?">(.*?)</ul>',
57 webpage
, 'categories', fatal
=False)
61 c
.strip() for c
in re
.findall(
62 r
'(?s)<li><a.*?>(.*?)</a>', categories_html
)]
64 view_count
= str_to_int(self
._search
_regex
(
65 r
'<meta[^>]+itemprop="interactionCount"[^>]+content="UserPlays:([0-9,]+)">',
66 webpage
, 'view count', default
=None))
67 like_count
= str_to_int(self
._search
_regex
(
68 r
'<meta[^>]+itemprop="interactionCount"[^>]+content="UserLikes:([0-9,]+)">',
69 webpage
, 'like count', default
=None))
70 duration
= parse_duration(self
._html
_search
_meta
('duration', webpage
))
72 media_id
= self
._search
_regex
(
73 r
'<button[^>]+data-id=(["\'])(?P
<id>\d
+)\
1[^
>]+data
-quality
=', webpage,
74 'media
id', default=None, group='id')
77 for _, quality in re.findall(r'<button
[^
>]+data
-quality
=(["\'])(.+?)\1', webpage)]
78 if not (media_id and sources):
79 player_js = self._download_webpage(
81 r'<script[^>]id=(["\'])playerembed\
1[^
>]+src
=(["\'])(?P<url>.+?)\2',
82 webpage, 'player JS', group='url'),
83 video_id, 'Downloading player JS')
84 params_js = self._search_regex(
85 r'\$\.ajax\(url,\ opts\);\s*\}\s*\}\)\(([0-9,\[\] ]+)\)',
86 player_js, 'initialization parameters')
87 params = self._parse_json(f'[{params_js}]', video_id)
89 sources = [f'{p}' for p in params[2]]
91 formats = self._extract_formats(url, video_id, media_id, sources)
97 'categories': categories,
98 'thumbnail': thumbnail,
100 'uploader_id': uploader_id,
101 'timestamp': timestamp,
102 'like_count': like_count,
103 'view_count': view_count,
104 'duration': duration,
109 class FourTubeIE(FourTubeBaseIE):
111 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?4tube\.com/(?:videos|embed)/(?P<id>\d+)(?:/(?P<display_id>[^/?#&]+))?'
112 _URL_TEMPLATE = 'https://www.4tube.com/videos/%s/video'
113 _TKN_HOST = 'token.4tube.com'
115 'url': 'http://www.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
116 'md5': '6516c8ac63b03de06bc8eac14362db4f',
120 'title': 'Hot Babe Holly Michaels gets her ass stuffed by black',
121 'uploader': 'WCP Club',
122 'uploader_id': 'wcp-club',
123 'upload_date': '20131031',
124 'timestamp': 1383263892,
132 'url': 'http://www.4tube.com/embed/209733',
133 'only_matching': True,
135 'url': 'http://m.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
136 'only_matching': True,
140 class FuxIE(FourTubeBaseIE):
141 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?fux\.com/(?:video|embed)/(?P<id>\d+)(?:/(?P<display_id>[^/?#&]+))?'
142 _URL_TEMPLATE = 'https://www.fux.com/video/%s/video'
143 _TKN_HOST = 'token.fux.com'
145 'url': 'https://www.fux.com/video/195359/awesome-fucking-kitchen-ends-cum-swallow',
149 'title': 'Awesome fucking in the kitchen ends with cum swallow',
150 'uploader': 'alenci2342',
151 'uploader_id': 'alenci2342',
152 'upload_date': '20131230',
153 'timestamp': 1388361660,
161 'skip_download': True,
164 'url': 'https://www.fux.com/embed/195359',
165 'only_matching': True,
167 'url': 'https://www.fux.com/video/195359/awesome-fucking-kitchen-ends-cum-swallow',
168 'only_matching': True,
172 class PornTubeIE(FourTubeBaseIE):
173 _VALID_URL = r'https?://(?:(?P<kind>www|m)\.)?porntube\.com/(?:videos/(?P<display_id>[^/]+)_|embed/)(?P<id>\d+)'
174 _URL_TEMPLATE = 'https://www.porntube.com/videos/video_%s'
175 _TKN_HOST = 'tkn.porntube.com'
177 'url': 'https://www.porntube.com/videos/teen-couple-doing-anal_7089759',
181 'title': 'Teen couple doing anal',
183 'uploader_id': '91488',
184 'upload_date': '20150606',
185 'timestamp': 1433595647,
192 'skip_download': True,
195 'url': 'https://www.porntube.com/videos/squirting-teen-ballerina-ecg_1331406',
199 'title': 'Squirting Teen Ballerina on ECG',
200 'uploader': 'Exploited College Girls',
201 'uploader_id': '665',
202 'channel': 'Exploited College Girls',
204 'upload_date': '20130920',
205 'timestamp': 1379685485,
212 'skip_download': True,
215 'url': 'https://www.porntube.com/embed/7089759',
216 'only_matching': True,
218 'url': 'https://m.porntube.com/videos/teen-couple-doing-anal_7089759',
219 'only_matching': True,
222 def _real_extract(self, url):
223 mobj = self._match_valid_url(url)
224 video_id, display_id = mobj.group('id', 'display_id')
226 webpage = self._download_webpage(url, display_id)
228 video = self._parse_json(
230 r'INITIALSTATE\s*=\s*(["\'])(?P
<value
>(?
:(?
!\
1).)+)\
1',
231 webpage, 'data
', group='value
'), video_id,
232 transform_source=lambda x: urllib.parse.unquote(
233 base64.b64decode(x).decode('utf
-8')))['page
']['video
']
235 title = video['title
']
236 media_id = video['mediaId
']
237 sources = [str(e['height
'])
238 for e in video['encodings
'] if e.get('height
')]
239 formats = self._extract_formats(url, video_id, media_id, sources)
241 thumbnail = url_or_none(video.get('masterThumb
'))
242 uploader = try_get(video, lambda x: x['user
']['username
'], str)
243 uploader_id = str_or_none(try_get(
244 video, lambda x: x['user
']['id'], int))
245 channel = try_get(video, lambda x: x['channel
']['name
'], str)
246 channel_id = str_or_none(try_get(
247 video, lambda x: x['channel
']['id'], int))
248 like_count = int_or_none(video.get('likes
'))
249 dislike_count = int_or_none(video.get('dislikes
'))
250 view_count = int_or_none(video.get('playsQty
'))
251 duration = int_or_none(video.get('durationInSeconds
'))
252 timestamp = unified_timestamp(video.get('publishedAt
'))
258 'thumbnail
': thumbnail,
259 'uploader
': uploader or channel,
260 'uploader_id
': uploader_id or channel_id,
262 'channel_id
': channel_id,
263 'timestamp
': timestamp,
264 'like_count
': like_count,
265 'dislike_count
': dislike_count,
266 'view_count
': view_count,
267 'duration
': duration,
272 class PornerBrosIE(FourTubeBaseIE):
273 _VALID_URL = r'https?
://(?
:(?P
<kind
>www|m
)\
.)?pornerbros\
.com
/(?
:videos
/(?P
<display_id
>[^
/]+)_|embed
/)(?P
<id>\d
+)'
274 _URL_TEMPLATE = 'https
://www
.pornerbros
.com
/videos
/video_
%s'
275 _TKN_HOST = 'token
.pornerbros
.com
'
277 'url
': 'https
://www
.pornerbros
.com
/videos
/skinny
-brunette
-takes
-big
-cock
-down
-her
-anal
-hole_181369
',
278 'md5
': '6516c8ac63b03de06bc8eac14362db4f
',
282 'title
': 'Skinny brunette takes big cock down her anal hole
',
283 'uploader
': 'PornerBros HD
',
284 'uploader_id
': 'pornerbros
-hd
',
285 'upload_date
': '20130130',
286 'timestamp
': 1359527401,
293 'skip_download
': True,
296 'url
': 'https
://www
.pornerbros
.com
/embed
/181369',
297 'only_matching
': True,
299 'url
': 'https
://m
.pornerbros
.com
/videos
/skinny
-brunette
-takes
-big
-cock
-down
-her
-anal
-hole_181369
',
300 'only_matching
': True,