]>
Commit | Line | Data |
---|---|---|
cbf46c73 | 1 | import re |
add96eb9 | 2 | import urllib.parse |
cbf46c73 PH |
3 | |
4 | from .common import InfoExtractor | |
1cc79574 | 5 | from ..utils import ( |
e897bd82 | 6 | ExtractorError, |
3217377b | 7 | clean_html, |
964afd06 | 8 | determine_ext, |
6ec371cd | 9 | int_or_none, |
13081db1 | 10 | parse_duration, |
cbf46c73 PH |
11 | ) |
12 | ||
13 | ||
14 | class XVideosIE(InfoExtractor): | |
cf5f6ed5 S |
15 | _VALID_URL = r'''(?x) |
16 | https?:// | |
17 | (?: | |
aa7e9ae4 | 18 | (?:[^/]+\.)?xvideos2?\.com/video\.?| |
19 | (?:www\.)?xvideos\.es/video\.?| | |
849d699a | 20 | (?:www|flashservice)\.xvideos\.com/embedframe/| |
cf5f6ed5 S |
21 | static-hw\.xvideos\.com/swf/xv-player\.swf\?.*?\bid_video= |
22 | ) | |
aa7e9ae4 | 23 | (?P<id>[0-9a-z]+) |
cf5f6ed5 S |
24 | ''' |
25 | _TESTS = [{ | |
aa7e9ae4 | 26 | 'url': 'http://xvideos.com/video.ucuvbkfda4e/a_beautiful_red-haired_stranger_was_refused_but_still_came_to_my_room_for_sex', |
27 | 'md5': '396255a900a6bddb3e98985f0b86c3fd', | |
d7975ea2 | 28 | 'info_dict': { |
aa7e9ae4 | 29 | 'id': 'ucuvbkfda4e', |
98affc1a | 30 | 'ext': 'mp4', |
aa7e9ae4 | 31 | 'title': 'A Beautiful Red-Haired Stranger Was Refused, But Still Came To My Room For Sex', |
32 | 'duration': 1238, | |
a6ffb92f | 33 | 'age_limit': 18, |
aa7e9ae4 | 34 | 'thumbnail': r're:^https://cdn\d+-pic.xvideos-cdn.com/.+\.jpg', |
add96eb9 | 35 | }, |
8efffafa M |
36 | }, { |
37 | # Broken HLS formats | |
38 | 'url': 'https://www.xvideos.com/video65982001/what_s_her_name', | |
aa7e9ae4 | 39 | 'md5': '56742808292c8fa1418e4538c262c58b', |
8efffafa M |
40 | 'info_dict': { |
41 | 'id': '65982001', | |
42 | 'ext': 'mp4', | |
43 | 'title': 'what\'s her name?', | |
44 | 'duration': 120, | |
45 | 'age_limit': 18, | |
aa7e9ae4 | 46 | 'thumbnail': r're:^https://cdn\d+-pic.xvideos-cdn.com/.+\.jpg', |
add96eb9 | 47 | }, |
cf5f6ed5 S |
48 | }, { |
49 | 'url': 'https://flashservice.xvideos.com/embedframe/4588838', | |
50 | 'only_matching': True, | |
849d699a | 51 | }, { |
52 | 'url': 'https://www.xvideos.com/embedframe/4588838', | |
53 | 'only_matching': True, | |
cf5f6ed5 S |
54 | }, { |
55 | 'url': 'http://static-hw.xvideos.com/swf/xv-player.swf?id_video=4588838', | |
56 | 'only_matching': True, | |
4e72d02f S |
57 | }, { |
58 | 'url': 'http://xvideos.com/video4588838/biker_takes_his_girl', | |
add96eb9 | 59 | 'only_matching': True, |
4e72d02f S |
60 | }, { |
61 | 'url': 'https://xvideos.com/video4588838/biker_takes_his_girl', | |
add96eb9 | 62 | 'only_matching': True, |
4e72d02f S |
63 | }, { |
64 | 'url': 'https://xvideos.es/video4588838/biker_takes_his_girl', | |
add96eb9 | 65 | 'only_matching': True, |
4e72d02f S |
66 | }, { |
67 | 'url': 'https://www.xvideos.es/video4588838/biker_takes_his_girl', | |
add96eb9 | 68 | 'only_matching': True, |
4e72d02f S |
69 | }, { |
70 | 'url': 'http://xvideos.es/video4588838/biker_takes_his_girl', | |
add96eb9 | 71 | 'only_matching': True, |
4e72d02f S |
72 | }, { |
73 | 'url': 'http://www.xvideos.es/video4588838/biker_takes_his_girl', | |
add96eb9 | 74 | 'only_matching': True, |
4e72d02f S |
75 | }, { |
76 | 'url': 'http://fr.xvideos.com/video4588838/biker_takes_his_girl', | |
add96eb9 | 77 | 'only_matching': True, |
4e72d02f S |
78 | }, { |
79 | 'url': 'https://fr.xvideos.com/video4588838/biker_takes_his_girl', | |
add96eb9 | 80 | 'only_matching': True, |
4e72d02f S |
81 | }, { |
82 | 'url': 'http://it.xvideos.com/video4588838/biker_takes_his_girl', | |
add96eb9 | 83 | 'only_matching': True, |
4e72d02f S |
84 | }, { |
85 | 'url': 'https://it.xvideos.com/video4588838/biker_takes_his_girl', | |
add96eb9 | 86 | 'only_matching': True, |
4e72d02f S |
87 | }, { |
88 | 'url': 'http://de.xvideos.com/video4588838/biker_takes_his_girl', | |
add96eb9 | 89 | 'only_matching': True, |
4e72d02f S |
90 | }, { |
91 | 'url': 'https://de.xvideos.com/video4588838/biker_takes_his_girl', | |
add96eb9 | 92 | 'only_matching': True, |
aa7e9ae4 | 93 | }, { |
94 | 'url': 'https://flashservice.xvideos.com/embedframe/ucuvbkfda4e', | |
95 | 'only_matching': True, | |
96 | }, { | |
97 | 'url': 'https://www.xvideos.com/embedframe/ucuvbkfda4e', | |
98 | 'only_matching': True, | |
99 | }, { | |
100 | 'url': 'http://static-hw.xvideos.com/swf/xv-player.swf?id_video=ucuvbkfda4e', | |
101 | 'only_matching': True, | |
102 | }, { | |
103 | 'url': 'https://xvideos.es/video.ucuvbkfda4e/a_beautiful_red-haired_stranger_was_refused_but_still_came_to_my_room_for_sex', | |
add96eb9 | 104 | 'only_matching': True, |
cf5f6ed5 | 105 | }] |
cbf46c73 PH |
106 | |
107 | def _real_extract(self, url): | |
1cc79574 | 108 | video_id = self._match_id(url) |
2abf0815 | 109 | webpage = self._download_webpage(url, video_id) |
cbf46c73 | 110 | |
3217377b S |
111 | mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage) |
112 | if mobj: | |
add96eb9 | 113 | raise ExtractorError(f'{self.IE_NAME} said: {clean_html(mobj.group(1))}', expected=True) |
3217377b | 114 | |
cf5f6ed5 S |
115 | title = self._html_search_regex( |
116 | (r'<title>(?P<title>.+?)\s+-\s+XVID', | |
117 | r'setVideoTitle\s*\(\s*(["\'])(?P<title>(?:(?!\1).)+)\1'), | |
118 | webpage, 'title', default=None, | |
119 | group='title') or self._og_search_title(webpage) | |
120 | ||
f4da8080 S |
121 | thumbnails = [] |
122 | for preference, thumbnail in enumerate(('', '169')): | |
123 | thumbnail_url = self._search_regex( | |
add96eb9 | 124 | rf'setThumbUrl{thumbnail}\(\s*(["\'])(?P<thumbnail>(?:(?!\1).)+)\1', |
f4da8080 S |
125 | webpage, 'thumbnail', default=None, group='thumbnail') |
126 | if thumbnail_url: | |
127 | thumbnails.append({ | |
128 | 'url': thumbnail_url, | |
129 | 'preference': preference, | |
130 | }) | |
131 | ||
cf5f6ed5 | 132 | duration = int_or_none(self._og_search_property( |
6ec371cd S |
133 | 'duration', webpage, default=None)) or parse_duration( |
134 | self._search_regex( | |
135 | r'<span[^>]+class=["\']duration["\'][^>]*>.*?(\d[^<]+)', | |
136 | webpage, 'duration', fatal=False)) | |
cbf46c73 | 137 | |
69c9cc27 | 138 | formats = [] |
964afd06 | 139 | |
add96eb9 | 140 | video_url = urllib.parse.unquote(self._search_regex( |
69c9cc27 S |
141 | r'flv_url=(.+?)&', webpage, 'video URL', default='')) |
142 | if video_url: | |
70a2829f S |
143 | formats.append({ |
144 | 'url': video_url, | |
145 | 'format_id': 'flv', | |
146 | }) | |
964afd06 | 147 | |
70a2829f S |
148 | for kind, _, format_url in re.findall( |
149 | r'setVideo([^(]+)\((["\'])(http.+?)\2\)', webpage): | |
150 | format_id = kind.lower() | |
151 | if format_id == 'hls': | |
8efffafa | 152 | hls_formats = self._extract_m3u8_formats( |
70a2829f | 153 | format_url, video_id, 'mp4', |
8efffafa M |
154 | entry_protocol='m3u8_native', m3u8_id='hls', fatal=False) |
155 | self._check_formats(hls_formats, video_id) | |
156 | formats.extend(hls_formats) | |
70a2829f S |
157 | elif format_id in ('urllow', 'urlhigh'): |
158 | formats.append({ | |
159 | 'url': format_url, | |
add96eb9 | 160 | 'format_id': '{}-{}'.format(determine_ext(format_url, 'mp4'), format_id[3:]), |
70a2829f S |
161 | 'quality': -2 if format_id.endswith('low') else None, |
162 | }) | |
964afd06 | 163 | |
d7975ea2 | 164 | return { |
cbf46c73 | 165 | 'id': video_id, |
964afd06 | 166 | 'formats': formats, |
cf5f6ed5 S |
167 | 'title': title, |
168 | 'duration': duration, | |
f4da8080 | 169 | 'thumbnails': thumbnails, |
8ed6b344 | 170 | 'age_limit': 18, |
cbf46c73 | 171 | } |
283a0b5b Y |
172 | |
173 | ||
174 | class XVideosQuickiesIE(InfoExtractor): | |
175 | IE_NAME = 'xvideos:quickies' | |
b207d26f | 176 | _VALID_URL = r'https?://(?P<domain>(?:[^/?#]+\.)?xvideos2?\.com)/(?:profiles/|amateur-channels/)?[^/?#]+#quickies/a/(?P<id>\w+)' |
283a0b5b | 177 | _TESTS = [{ |
b207d26f JF |
178 | 'url': 'https://www.xvideos.com/lili_love#quickies/a/ipdtikh1a4c', |
179 | 'md5': 'f9e4f518ff1de14b99a400bbd0fc5ee0', | |
180 | 'info_dict': { | |
181 | 'id': 'ipdtikh1a4c', | |
182 | 'ext': 'mp4', | |
183 | 'title': 'Mexican chichóna putisima', | |
184 | 'age_limit': 18, | |
185 | 'duration': 81, | |
186 | 'thumbnail': r're:^https://cdn.*-pic.xvideos-cdn.com/.+\.jpg', | |
add96eb9 | 187 | }, |
b207d26f JF |
188 | }, { |
189 | 'url': 'https://www.xvideos.com/profiles/lili_love#quickies/a/ipphaob6fd1', | |
190 | 'md5': '5340938aac6b46e19ebdd1d84535862e', | |
191 | 'info_dict': { | |
192 | 'id': 'ipphaob6fd1', | |
193 | 'ext': 'mp4', | |
194 | 'title': 'Puta chichona mexicana squirting', | |
195 | 'age_limit': 18, | |
196 | 'duration': 56, | |
197 | 'thumbnail': r're:^https://cdn.*-pic.xvideos-cdn.com/.+\.jpg', | |
add96eb9 | 198 | }, |
b207d26f JF |
199 | }, { |
200 | 'url': 'https://www.xvideos.com/amateur-channels/lili_love#quickies/a/hfmffmd7661', | |
201 | 'md5': '92428518bbabcb4c513e55922e022491', | |
202 | 'info_dict': { | |
203 | 'id': 'hfmffmd7661', | |
204 | 'ext': 'mp4', | |
205 | 'title': 'Chichona mexican slut', | |
206 | 'age_limit': 18, | |
207 | 'duration': 9, | |
208 | 'thumbnail': r're:^https://cdn.*-pic.xvideos-cdn.com/.+\.jpg', | |
add96eb9 | 209 | }, |
b207d26f | 210 | }, { |
283a0b5b Y |
211 | 'url': 'https://www.xvideos.com/amateur-channels/wifeluna#quickies/a/47258683', |
212 | 'md5': '16e322a93282667f1963915568f782c1', | |
213 | 'info_dict': { | |
214 | 'id': '47258683', | |
215 | 'ext': 'mp4', | |
216 | 'title': 'Verification video', | |
217 | 'age_limit': 18, | |
218 | 'duration': 16, | |
219 | 'thumbnail': r're:^https://cdn.*-pic.xvideos-cdn.com/.+\.jpg', | |
add96eb9 | 220 | }, |
283a0b5b Y |
221 | }] |
222 | ||
223 | def _real_extract(self, url): | |
224 | domain, id_ = self._match_valid_url(url).group('domain', 'id') | |
b207d26f | 225 | return self.url_result(f'https://{domain}/video{"" if id_.isdecimal() else "."}{id_}/_', XVideosIE, id_) |