]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/daftsex.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_b64decode
16 class DaftsexIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?daftsex\.com/watch/(?P<id>-?\d+_\d+)'
19 'url': 'https://daftsex.com/watch/-156601359_456242791',
21 'id': '-156601359_456242791',
23 'title': 'Skye Blue - Dinner And A Show',
27 def _real_extract(self
, url
):
28 video_id
= self
._match
_id
(url
)
29 webpage
= self
._download
_webpage
(url
, video_id
)
30 title
= get_elements_by_class('heading', webpage
)[-1]
31 duration
= parse_duration(self
._search
_regex
(
32 r
'Duration: ((?:[0-9]{2}:){0,2}[0-9]{2})',
33 webpage
, 'duration', fatal
=False))
34 views
= parse_count(self
._search
_regex
(
36 webpage
, 'views', fatal
=False))
38 player_hash
= self
._search
_regex
(
39 r
'DaxabPlayer\.Init\({[\s\S]*hash:\s*"([0-9a-zA-Z_\-]+)"[\s\S]*}',
40 webpage
, 'player hash')
41 player_color
= self
._search
_regex
(
42 r
'DaxabPlayer\.Init\({[\s\S]*color:\s*"([0-9a-z]+)"[\s\S]*}',
43 webpage
, 'player color', fatal
=False) or ''
45 embed_page
= self
._download
_webpage
(
46 'https://daxab.com/player/%s?color=%s' % (player_hash
, player_color
),
47 video_id
, headers
={'Referer': url}
)
48 video_params
= self
._parse
_json
(
50 r
'window\.globParams\s*=\s*({[\S\s]+})\s*;\s*<\/script>',
51 embed_page
, 'video parameters'),
52 video_id
, transform_source
=js_to_json
)
54 server_domain
= 'https://%s' % compat_b64decode(video_params
['server'][::-1]).decode('utf-8')
56 for format_id
, format_data
in video_params
['video']['cdn_files'].items():
57 ext
, height
= format_id
.split('_')
58 extra_quality_data
= format_data
.split('.')[-1]
59 url
= f
'{server_domain}/videos/{video_id.replace("_", "/")}/{height}.mp4?extra={extra_quality_data}'
61 'format_id': format_id
,
63 'height': int_or_none(height
),
66 self
._sort
_formats
(formats
)
68 thumbnail
= try_get(video_params
,
69 lambda vi
: 'https:' + compat_b64decode(vi
['video']['thumb']).decode('utf-8'))
76 'thumbnail': thumbnail
,