]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/daftsex.py
1 from .common
import InfoExtractor
2 from ..compat
import compat_b64decode
14 class DaftsexIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?daftsex\.com/watch/(?P<id>-?\d+_\d+)'
17 'url': 'https://daftsex.com/watch/-35370899_456246186',
18 'md5': 'd95135e6cea2d905bea20dbe82cda64a',
20 'id': '-35370899_456246186',
22 'title': 'just relaxing',
23 'description': 'just relaxing - Watch video Watch video in high quality',
24 'upload_date': '20201113',
25 'timestamp': 1605261911,
26 'thumbnail': r
're:https://[^/]+/impf/-43BuMDIawmBGr3GLcZ93CYwWf2PBv_tVWoS1A/dnu41DnARU4\.jpg\?size=800x450&quality=96&keep_aspect_ratio=1&background=000000&sign=6af2c26ff4a45e55334189301c867384&type=video_thumb',
29 'url': 'https://daftsex.com/watch/-156601359_456242791',
31 'id': '-156601359_456242791',
33 'title': 'Skye Blue - Dinner And A Show',
34 'description': 'Skye Blue - Dinner And A Show - Watch video Watch video in high quality',
35 'upload_date': '20200916',
36 'timestamp': 1600250735,
37 'thumbnail': 'https://psv153-1.crazycloud.ru/videos/-156601359/456242791/thumb.jpg?extra=i3D32KaBbBFf9TqDRMAVmQ',
41 def _real_extract(self
, url
):
42 video_id
= self
._match
_id
(url
)
43 webpage
= self
._download
_webpage
(url
, video_id
)
44 title
= self
._html
_search
_meta
('name', webpage
, 'title')
45 timestamp
= unified_timestamp(self
._html
_search
_meta
('uploadDate', webpage
, 'Upload Date', default
=None))
46 description
= self
._html
_search
_meta
('description', webpage
, 'Description', default
=None)
48 duration
= parse_duration(self
._search
_regex
(
49 r
'Duration: ((?:[0-9]{2}:){0,2}[0-9]{2})',
50 webpage
, 'duration', fatal
=False))
51 views
= parse_count(self
._search
_regex
(
53 webpage
, 'views', fatal
=False))
55 player_hash
= self
._search
_regex
(
56 r
'DaxabPlayer\.Init\({[\s\S]*hash:\s*"([0-9a-zA-Z_\-]+)"[\s\S]*}',
57 webpage
, 'player hash')
58 player_color
= self
._search
_regex
(
59 r
'DaxabPlayer\.Init\({[\s\S]*color:\s*"([0-9a-z]+)"[\s\S]*}',
60 webpage
, 'player color', fatal
=False) or ''
62 embed_page
= self
._download
_webpage
(
63 'https://daxab.com/player/%s?color=%s' % (player_hash
, player_color
),
64 video_id
, headers
={'Referer': url}
)
65 video_params
= self
._parse
_json
(
67 r
'window\.globParams\s*=\s*({[\S\s]+})\s*;\s*<\/script>',
68 embed_page
, 'video parameters'),
69 video_id
, transform_source
=js_to_json
)
71 server_domain
= 'https://%s' % compat_b64decode(video_params
['server'][::-1]).decode('utf-8')
73 cdn_files
= traverse_obj(video_params
, ('video', 'cdn_files')) or {}
76 for format_id
, format_data
in cdn_files
.items():
77 ext
, height
= format_id
.split('_')
79 'format_id': format_id
,
80 'url': f
'{server_domain}/videos/{video_id.replace("_", "/")}/{height}.mp4?extra={format_data.split(".")[-1]}',
81 'height': int_or_none(height
),
84 self
._sort
_formats
(formats
)
90 'description': description
,
92 'thumbnail': try_get(video_params
, lambda vi
: 'https:' + compat_b64decode(vi
['video']['thumb']).decode('utf-8')),
93 'timestamp': timestamp
,
98 item
= self
._download
_json
(
99 f
'{server_domain}/method/video.get/{video_id}', video_id
,
100 headers
={'Referer': url}
, query
={
101 'token': video_params
['video']['access_token'],
103 'ckey': video_params
['c_key'],
104 'credentials': video_params
['video']['credentials'],
105 })['response']['items'][0]
108 for f_id
, f_url
in item
.get('files', {}).items():
109 if f_id
== 'external':
110 return self
.url_result(f_url
)
111 ext
, height
= f_id
.split('_')
112 height_extra_key
= traverse_obj(video_params
, ('video', 'partial', 'quality', height
))
115 'format_id': f
'{height}p',
116 'url': f
'{server_domain}/{f_url[8:]}&videos={video_id}&extra_key={height_extra_key}',
117 'height': int_or_none(height
),
120 self
._sort
_formats
(formats
)
123 for k
, v
in item
.items():
124 if k
.startswith('photo_') and v
:
125 width
= k
.replace('photo_', '')
129 'width': int_or_none(width
),
136 'comment_count': int_or_none(item
.get('comments')),
137 'description': description
,
138 'duration': duration
,
139 'thumbnails': thumbnails
,
140 'timestamp': timestamp
,