]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/txxx.py
[ie/Canal1,CaracolTvPlay] Add extractors (#7151)
[yt-dlp.git] / yt_dlp / extractor / txxx.py
1 import base64
2 import re
3
4 from .common import InfoExtractor
5 from ..utils import (
6 ExtractorError,
7 int_or_none,
8 js_to_json,
9 merge_dicts,
10 parse_duration,
11 traverse_obj,
12 try_call,
13 urljoin,
14 variadic,
15 )
16
17
18 def decode_base64(text):
19 return base64.b64decode(text.translate(text.maketrans({
20 '\u0405': 'S',
21 '\u0406': 'I',
22 '\u0408': 'J',
23 '\u0410': 'A',
24 '\u0412': 'B',
25 '\u0415': 'E',
26 '\u041a': 'K',
27 '\u041c': 'M',
28 '\u041d': 'H',
29 '\u041e': 'O',
30 '\u0420': 'P',
31 '\u0421': 'C',
32 '\u0425': 'X',
33 ',': '/',
34 '.': '+',
35 '~': '=',
36 }))).decode()
37
38
39 def get_formats(host, video_file):
40 return [{
41 'url': urljoin(f'https://{host}', decode_base64(video['video_url'])),
42 'format_id': try_call(lambda: variadic(video['format'])[0].lstrip('_')),
43 'quality': index,
44 } for index, video in enumerate(video_file) if video.get('video_url')]
45
46
47 class TxxxIE(InfoExtractor):
48 _DOMAINS = (
49 'hclips.com',
50 'hdzog.com',
51 'hdzog.tube',
52 'hotmovs.com',
53 'hotmovs.tube',
54 'inporn.com',
55 'privatehomeclips.com',
56 'tubepornclassic.com',
57 'txxx.com',
58 'txxx.tube',
59 'upornia.com',
60 'upornia.tube',
61 'vjav.com',
62 'vjav.tube',
63 'vxxx.com',
64 'voyeurhit.com',
65 'voyeurhit.tube',
66 )
67 _VALID_URL = rf'''(?x)
68 https?://(?:www\.)?(?P<host>{"|".join(map(re.escape, _DOMAINS))})/
69 (?:videos?[/-]|embed/)(?P<id>\d+)(?:/(?P<display_id>[^/?#]+))?
70 '''
71 _EMBED_REGEX = [rf'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?(?:{"|".join(map(re.escape, _DOMAINS))})/embed/[^"\']*)\1']
72 _TESTS = [{
73 'url': 'https://txxx.com/videos/16574965/digital-desire-malena-morgan/',
74 'md5': 'c54e4ace54320aaf8e2a72df87859391',
75 'info_dict': {
76 'id': '16574965',
77 'display_id': 'digital-desire-malena-morgan',
78 'ext': 'mp4',
79 'title': 'Digital Desire - Malena Morgan',
80 'uploader': 'Lois Argentum',
81 'duration': 694,
82 'view_count': int,
83 'like_count': int,
84 'dislike_count': int,
85 'age_limit': 18,
86 }
87 }, {
88 'url': 'https://txxx.tube/videos/16574965/digital-desire-malena-morgan/',
89 'md5': 'c54e4ace54320aaf8e2a72df87859391',
90 'info_dict': {
91 'id': '16574965',
92 'display_id': 'digital-desire-malena-morgan',
93 'ext': 'mp4',
94 'title': 'Digital Desire - Malena Morgan',
95 'uploader': 'Lois Argentum',
96 'duration': 694,
97 'view_count': int,
98 'like_count': int,
99 'dislike_count': int,
100 'age_limit': 18,
101 }
102 }, {
103 'url': 'https://vxxx.com/video-68925/',
104 'md5': '1fcff3748b0c5b41fe41d0afa22409e1',
105 'info_dict': {
106 'id': '68925',
107 'display_id': '68925',
108 'ext': 'mp4',
109 'title': 'Malena Morgan',
110 'uploader': 'Huge Hughes',
111 'duration': 694,
112 'view_count': int,
113 'like_count': int,
114 'dislike_count': int,
115 'age_limit': 18,
116 }
117 }, {
118 'url': 'https://hclips.com/videos/6291073/malena-morgan-masturbates-her-sweet/',
119 'md5': 'a5dd4f83363972ee043313cff85e7e26',
120 'info_dict': {
121 'id': '6291073',
122 'display_id': 'malena-morgan-masturbates-her-sweet',
123 'ext': 'mp4',
124 'title': 'Malena Morgan masturbates her sweet',
125 'uploader': 'John Salt',
126 'duration': 426,
127 'view_count': int,
128 'like_count': int,
129 'dislike_count': int,
130 'age_limit': 18,
131 }
132 }, {
133 'url': 'https://hdzog.com/videos/67063/gorgeous-malena-morgan-will-seduce-you-at-the-first-glance/',
134 'md5': 'f8bdedafd45d1ec2875c43fe33a846d3',
135 'info_dict': {
136 'id': '67063',
137 'display_id': 'gorgeous-malena-morgan-will-seduce-you-at-the-first-glance',
138 'ext': 'mp4',
139 'title': 'Gorgeous Malena Morgan will seduce you at the first glance',
140 'uploader': 'momlesson',
141 'duration': 601,
142 'view_count': int,
143 'like_count': int,
144 'dislike_count': int,
145 'age_limit': 18,
146 }
147 }, {
148 'url': 'https://hdzog.tube/videos/67063/gorgeous-malena-morgan-will-seduce-you-at-the-first-glance/',
149 'md5': 'f8bdedafd45d1ec2875c43fe33a846d3',
150 'info_dict': {
151 'id': '67063',
152 'display_id': 'gorgeous-malena-morgan-will-seduce-you-at-the-first-glance',
153 'ext': 'mp4',
154 'title': 'Gorgeous Malena Morgan will seduce you at the first glance',
155 'uploader': 'momlesson',
156 'duration': 601,
157 'view_count': int,
158 'like_count': int,
159 'dislike_count': int,
160 'age_limit': 18,
161 }
162 }, {
163 'url': 'https://hotmovs.com/videos/8789287/unbelievable-malena-morgan-performing-in-incredible-masturantion/',
164 'md5': '71d32c51584876472db87e561171a386',
165 'info_dict': {
166 'id': '8789287',
167 'display_id': 'unbelievable-malena-morgan-performing-in-incredible-masturantion',
168 'ext': 'mp4',
169 'title': 'Unbelievable Malena Morgan performing in incredible masturantion',
170 'uploader': 'Davit Sanchez',
171 'duration': 940,
172 'view_count': int,
173 'like_count': int,
174 'dislike_count': int,
175 'age_limit': 18,
176 }
177 }, {
178 'url': 'https://hotmovs.tube/videos/8789287/unbelievable-malena-morgan-performing-in-incredible-masturantion/',
179 'md5': '71d32c51584876472db87e561171a386',
180 'info_dict': {
181 'id': '8789287',
182 'display_id': 'unbelievable-malena-morgan-performing-in-incredible-masturantion',
183 'ext': 'mp4',
184 'title': 'Unbelievable Malena Morgan performing in incredible masturantion',
185 'uploader': 'Davit Sanchez',
186 'duration': 940,
187 'view_count': int,
188 'like_count': int,
189 'dislike_count': int,
190 'age_limit': 18,
191 }
192 }, {
193 'url': 'https://inporn.com/video/517897/malena-morgan-solo/',
194 'md5': '344db467481edf78f193cdf5820a7cfb',
195 'info_dict': {
196 'id': '517897',
197 'display_id': 'malena-morgan-solo',
198 'ext': 'mp4',
199 'title': 'Malena Morgan - Solo',
200 'uploader': 'Ashley Oxy',
201 'duration': 480,
202 'view_count': int,
203 'like_count': int,
204 'dislike_count': int,
205 'age_limit': 18,
206 }
207 }, {
208 'url': 'https://privatehomeclips.com/videos/3630599/malena-morgan-cam-show/',
209 'md5': 'ea657273e352493c5fb6357fbfa4f126',
210 'info_dict': {
211 'id': '3630599',
212 'display_id': 'malena-morgan-cam-show',
213 'ext': 'mp4',
214 'title': 'malena morgan cam show',
215 'uploader': 'Member9915',
216 'duration': 290,
217 'view_count': int,
218 'like_count': int,
219 'dislike_count': int,
220 'age_limit': 18,
221 }
222 }, {
223 'url': 'https://tubepornclassic.com/videos/1015455/mimi-rogers-full-body-massage-nude-compilation/',
224 'md5': '2e9a6cf610c9862e86e0ce24f08f4427',
225 'info_dict': {
226 'id': '1015455',
227 'display_id': 'mimi-rogers-full-body-massage-nude-compilation',
228 'ext': 'mp4',
229 'title': 'Mimi Rogers - Full Body Massage (Nude) compilation',
230 'uploader': '88bhuto',
231 'duration': 286,
232 'view_count': int,
233 'like_count': int,
234 'dislike_count': int,
235 'age_limit': 18,
236 }
237 }, {
238 'url': 'https://upornia.com/videos/1498858/twistys-malena-morgan-starring-at-dr-morgan-baller/',
239 'md5': '7ff7033340bc88a173198b7c22600e4f',
240 'info_dict': {
241 'id': '1498858',
242 'display_id': 'twistys-malena-morgan-starring-at-dr-morgan-baller',
243 'ext': 'mp4',
244 'title': 'Twistys - Malena Morgan starring at Dr. Morgan-Baller',
245 'uploader': 'mindgeek',
246 'duration': 480,
247 'view_count': int,
248 'like_count': int,
249 'dislike_count': int,
250 'age_limit': 18,
251 }
252 }, {
253 'url': 'https://upornia.tube/videos/1498858/twistys-malena-morgan-starring-at-dr-morgan-baller/',
254 'md5': '7ff7033340bc88a173198b7c22600e4f',
255 'info_dict': {
256 'id': '1498858',
257 'display_id': 'twistys-malena-morgan-starring-at-dr-morgan-baller',
258 'ext': 'mp4',
259 'title': 'Twistys - Malena Morgan starring at Dr. Morgan-Baller',
260 'uploader': 'mindgeek',
261 'duration': 480,
262 'view_count': int,
263 'like_count': int,
264 'dislike_count': int,
265 'age_limit': 18,
266 }
267 }, {
268 'url': 'https://vjav.com/videos/11761/yui-hatano-in-if-yui-was-my-girlfriend2/',
269 'md5': '6de5bc1f13bdfc3491a77f23edb1676f',
270 'info_dict': {
271 'id': '11761',
272 'display_id': 'yui-hatano-in-if-yui-was-my-girlfriend2',
273 'ext': 'mp4',
274 'title': 'Yui Hatano in If Yui Was My Girlfriend',
275 'uploader': 'Matheus69',
276 'duration': 3310,
277 'view_count': int,
278 'like_count': int,
279 'dislike_count': int,
280 'age_limit': 18,
281 }
282 }, {
283 'url': 'https://vjav.tube/videos/11761/yui-hatano-in-if-yui-was-my-girlfriend2/',
284 'md5': '6de5bc1f13bdfc3491a77f23edb1676f',
285 'info_dict': {
286 'id': '11761',
287 'display_id': 'yui-hatano-in-if-yui-was-my-girlfriend2',
288 'ext': 'mp4',
289 'title': 'Yui Hatano in If Yui Was My Girlfriend',
290 'uploader': 'Matheus69',
291 'duration': 3310,
292 'view_count': int,
293 'like_count': int,
294 'dislike_count': int,
295 'age_limit': 18,
296 }
297 }, {
298 'url': 'https://voyeurhit.com/videos/332875/charlotte-stokely-elle-alexandra-malena-morgan-lingerie/',
299 'md5': '12b4666e9c3e60dafe9182e5d12aae33',
300 'info_dict': {
301 'id': '332875',
302 'display_id': 'charlotte-stokely-elle-alexandra-malena-morgan-lingerie',
303 'ext': 'mp4',
304 'title': 'Charlotte Stokely, Elle Alexandra, Malena Morgan-Lingerie',
305 'uploader': 'Kyle Roberts',
306 'duration': 655,
307 'view_count': int,
308 'like_count': int,
309 'dislike_count': int,
310 'age_limit': 18,
311 }
312 }, {
313 'url': 'https://voyeurhit.tube/videos/332875/charlotte-stokely-elle-alexandra-malena-morgan-lingerie/',
314 'md5': '12b4666e9c3e60dafe9182e5d12aae33',
315 'info_dict': {
316 'id': '332875',
317 'display_id': 'charlotte-stokely-elle-alexandra-malena-morgan-lingerie',
318 'ext': 'mp4',
319 'title': 'Charlotte Stokely, Elle Alexandra, Malena Morgan-Lingerie',
320 'uploader': 'Kyle Roberts',
321 'duration': 655,
322 'view_count': int,
323 'like_count': int,
324 'dislike_count': int,
325 'age_limit': 18,
326 }
327 }]
328 _WEBPAGE_TESTS = [{
329 'url': 'https://pornzog.com/video/9125519/michelle-malone-dreamgirls-wild-wet-3/',
330 'info_dict': {
331 'id': '5119660',
332 'display_id': '5119660',
333 'ext': 'mp4',
334 'title': 'Michelle Malone - Dreamgirls - Wild Wet 3',
335 'uploader': 'FallenAngel12',
336 'duration': 402,
337 'view_count': int,
338 'like_count': int,
339 'dislike_count': int,
340 'age_limit': 18,
341 }
342 }]
343
344 def _call_api(self, url, video_id, fatal=False, **kwargs):
345 content = self._download_json(url, video_id, fatal=fatal, **kwargs)
346 if traverse_obj(content, 'error'):
347 raise self._error_or_warning(ExtractorError(
348 f'Txxx said: {content["error"]}', expected=True), fatal=fatal)
349 return content or {}
350
351 def _real_extract(self, url):
352 video_id, host, display_id = self._match_valid_url(url).group('id', 'host', 'display_id')
353 headers = {'Referer': url, 'X-Requested-With': 'XMLHttpRequest'}
354
355 video_file = self._call_api(
356 f'https://{host}/api/videofile.php?video_id={video_id}&lifetime=8640000',
357 video_id, fatal=True, note='Downloading video file info', headers=headers)
358
359 slug = f'{int(1E6 * (int(video_id) // 1E6))}/{1000 * (int(video_id) // 1000)}'
360 video_info = self._call_api(
361 f'https://{host}/api/json/video/86400/{slug}/{video_id}.json',
362 video_id, note='Downloading video info', headers=headers)
363
364 return {
365 'id': video_id,
366 'display_id': display_id,
367 'title': traverse_obj(video_info, ('video', 'title')),
368 'uploader': traverse_obj(video_info, ('video', 'user', 'username')),
369 'duration': parse_duration(traverse_obj(video_info, ('video', 'duration'))),
370 'view_count': int_or_none(traverse_obj(video_info, ('video', 'statistics', 'viewed'))),
371 'like_count': int_or_none(traverse_obj(video_info, ('video', 'statistics', 'likes'))),
372 'dislike_count': int_or_none(traverse_obj(video_info, ('video', 'statistics', 'dislikes'))),
373 'age_limit': 18,
374 'formats': get_formats(host, video_file),
375 }
376
377
378 class PornTopIE(InfoExtractor):
379 _VALID_URL = r'https?://(?P<host>(?:www\.)?porntop\.com)/video/(?P<id>\d+)(?:/(?P<display_id>[^/?]+))?'
380 _TESTS = [{
381 'url': 'https://porntop.com/video/101569/triple-threat-with-lia-lor-malena-morgan-and-dani-daniels/',
382 'md5': '612ba7b3cb99455b382972948e200b08',
383 'info_dict': {
384 'id': '101569',
385 'display_id': 'triple-threat-with-lia-lor-malena-morgan-and-dani-daniels',
386 'ext': 'mp4',
387 'title': 'Triple Threat With Lia Lor, Malena Morgan And Dani Daniels',
388 'description': 'md5:285357d9d3a00ce5acb29f39f826dbf6',
389 'uploader': 'PatrickBush',
390 'duration': 480,
391 'view_count': int,
392 'like_count': int,
393 'dislike_count': int,
394 'age_limit': 18,
395 'timestamp': 1609455029,
396 'upload_date': '20201231',
397 'thumbnail': 'https://tn.porntop.com/media/tn/sources/101569_1.jpg',
398 }
399 }]
400
401 def _real_extract(self, url):
402 video_id, host, display_id = self._match_valid_url(url).group('id', 'host', 'display_id')
403 webpage = self._download_webpage(url, video_id)
404
405 json_ld = self._json_ld(self._search_json(
406 r'\bschemaJson\s*=', webpage, 'JSON-LD', video_id, transform_source=js_to_json,
407 contains_pattern='{[^<]+?VideoObject[^<]+};'), video_id, fatal=True)
408
409 video_file = self._parse_json(decode_base64(self._search_regex(
410 r"window\.initPlayer\(.*}}},\s*'(?P<json_b64c>[^']+)'",
411 webpage, 'json_urls', group='json_b64c')), video_id)
412
413 return merge_dicts({
414 'id': video_id,
415 'display_id': display_id,
416 'age_limit': 18,
417 'formats': get_formats(host, video_file),
418 }, json_ld)