]>
Commit | Line | Data |
---|---|---|
4a77fb1d | 1 | from .common import InfoExtractor |
2 | from ..compat import compat_b64decode | |
3 | from ..utils import ( | |
4a77fb1d | 4 | int_or_none, |
5 | js_to_json, | |
6 | parse_count, | |
7 | parse_duration, | |
497a6c5f | 8 | traverse_obj, |
4a77fb1d | 9 | try_get, |
497a6c5f | 10 | unified_timestamp, |
4a77fb1d | 11 | ) |
12 | ||
13 | ||
14 | class DaftsexIE(InfoExtractor): | |
15 | _VALID_URL = r'https?://(?:www\.)?daftsex\.com/watch/(?P<id>-?\d+_\d+)' | |
16 | _TESTS = [{ | |
497a6c5f S |
17 | 'url': 'https://daftsex.com/watch/-35370899_456246186', |
18 | 'md5': 'd95135e6cea2d905bea20dbe82cda64a', | |
19 | 'info_dict': { | |
20 | 'id': '-35370899_456246186', | |
21 | 'ext': 'mp4', | |
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', | |
27 | }, | |
28 | }, { | |
4a77fb1d | 29 | 'url': 'https://daftsex.com/watch/-156601359_456242791', |
30 | 'info_dict': { | |
31 | 'id': '-156601359_456242791', | |
32 | 'ext': 'mp4', | |
33 | 'title': 'Skye Blue - Dinner And A Show', | |
497a6c5f S |
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', | |
4a77fb1d | 38 | }, |
39 | }] | |
40 | ||
41 | def _real_extract(self, url): | |
42 | video_id = self._match_id(url) | |
43 | webpage = self._download_webpage(url, video_id) | |
497a6c5f S |
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) | |
47 | ||
4a77fb1d | 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( | |
52 | r'Views: ([0-9 ]+)', | |
53 | webpage, 'views', fatal=False)) | |
54 | ||
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 '' | |
61 | ||
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( | |
66 | self._search_regex( | |
67 | r'window\.globParams\s*=\s*({[\S\s]+})\s*;\s*<\/script>', | |
68 | embed_page, 'video parameters'), | |
69 | video_id, transform_source=js_to_json) | |
70 | ||
71 | server_domain = 'https://%s' % compat_b64decode(video_params['server'][::-1]).decode('utf-8') | |
497a6c5f S |
72 | |
73 | cdn_files = traverse_obj(video_params, ('video', 'cdn_files')) or {} | |
74 | if cdn_files: | |
75 | formats = [] | |
76 | for format_id, format_data in cdn_files.items(): | |
77 | ext, height = format_id.split('_') | |
78 | formats.append({ | |
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), | |
82 | 'ext': ext, | |
83 | }) | |
497a6c5f S |
84 | |
85 | return { | |
86 | 'id': video_id, | |
87 | 'title': title, | |
88 | 'formats': formats, | |
89 | 'description': description, | |
90 | 'duration': duration, | |
91 | 'thumbnail': try_get(video_params, lambda vi: 'https:' + compat_b64decode(vi['video']['thumb']).decode('utf-8')), | |
92 | 'timestamp': timestamp, | |
93 | 'view_count': views, | |
94 | 'age_limit': 18, | |
95 | } | |
96 | ||
97 | item = self._download_json( | |
98 | f'{server_domain}/method/video.get/{video_id}', video_id, | |
99 | headers={'Referer': url}, query={ | |
100 | 'token': video_params['video']['access_token'], | |
101 | 'videos': video_id, | |
102 | 'ckey': video_params['c_key'], | |
103 | 'credentials': video_params['video']['credentials'], | |
104 | })['response']['items'][0] | |
105 | ||
4a77fb1d | 106 | formats = [] |
497a6c5f S |
107 | for f_id, f_url in item.get('files', {}).items(): |
108 | if f_id == 'external': | |
109 | return self.url_result(f_url) | |
110 | ext, height = f_id.split('_') | |
111 | height_extra_key = traverse_obj(video_params, ('video', 'partial', 'quality', height)) | |
112 | if height_extra_key: | |
113 | formats.append({ | |
114 | 'format_id': f'{height}p', | |
115 | 'url': f'{server_domain}/{f_url[8:]}&videos={video_id}&extra_key={height_extra_key}', | |
116 | 'height': int_or_none(height), | |
117 | 'ext': ext, | |
118 | }) | |
4a77fb1d | 119 | |
497a6c5f S |
120 | thumbnails = [] |
121 | for k, v in item.items(): | |
122 | if k.startswith('photo_') and v: | |
123 | width = k.replace('photo_', '') | |
124 | thumbnails.append({ | |
125 | 'id': width, | |
126 | 'url': v, | |
127 | 'width': int_or_none(width), | |
128 | }) | |
4a77fb1d | 129 | |
130 | return { | |
131 | 'id': video_id, | |
132 | 'title': title, | |
133 | 'formats': formats, | |
497a6c5f S |
134 | 'comment_count': int_or_none(item.get('comments')), |
135 | 'description': description, | |
4a77fb1d | 136 | 'duration': duration, |
497a6c5f S |
137 | 'thumbnails': thumbnails, |
138 | 'timestamp': timestamp, | |
4a77fb1d | 139 | 'view_count': views, |
140 | 'age_limit': 18, | |
141 | } |