]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
14719565 JMF |
2 | |
3 | from __future__ import unicode_literals | |
4 | ||
5 | # Allow direct execution | |
cb252080 | 6 | import io |
14719565 JMF |
7 | import os |
8 | import sys | |
9 | import unittest | |
10 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
11 | ||
95e42d73 | 12 | from test.helper import FakeYDL, expect_dict, expect_value, http_server_port |
7a5c1cfe P |
13 | from yt_dlp.compat import compat_etree_fromstring, compat_http_server |
14 | from yt_dlp.extractor.common import InfoExtractor | |
15 | from yt_dlp.extractor import YoutubeIE, get_info_extractor | |
16 | from yt_dlp.utils import encode_data_uri, strip_jsonp, ExtractorError, RegexNotFoundError | |
95e42d73 XDG |
17 | import threading |
18 | ||
19 | ||
20 | TEAPOT_RESPONSE_STATUS = 418 | |
21 | TEAPOT_RESPONSE_BODY = "<h1>418 I'm a teapot</h1>" | |
22 | ||
23 | ||
24 | class InfoExtractorTestRequestHandler(compat_http_server.BaseHTTPRequestHandler): | |
25 | def log_message(self, format, *args): | |
26 | pass | |
27 | ||
28 | def do_GET(self): | |
29 | if self.path == '/teapot': | |
30 | self.send_response(TEAPOT_RESPONSE_STATUS) | |
31 | self.send_header('Content-Type', 'text/html; charset=utf-8') | |
32 | self.end_headers() | |
33 | self.wfile.write(TEAPOT_RESPONSE_BODY.encode()) | |
34 | else: | |
35 | assert False | |
14719565 JMF |
36 | |
37 | ||
060ac762 | 38 | class DummyIE(InfoExtractor): |
14719565 JMF |
39 | pass |
40 | ||
41 | ||
42 | class TestInfoExtractor(unittest.TestCase): | |
43 | def setUp(self): | |
060ac762 | 44 | self.ie = DummyIE(FakeYDL()) |
14719565 JMF |
45 | |
46 | def test_ie_key(self): | |
47 | self.assertEqual(get_info_extractor(YoutubeIE.ie_key()), YoutubeIE) | |
48 | ||
49 | def test_html_search_regex(self): | |
50 | html = '<p id="foo">Watch this <a href="http://www.youtube.com/watch?v=BaW_jenozKc">video</a></p>' | |
51 | search = lambda re, *args: self.ie._html_search_regex(re, html, *args) | |
52 | self.assertEqual(search(r'<p id="foo">(.+?)</p>', 'foo'), 'Watch this video') | |
53 | ||
54 | def test_opengraph(self): | |
55 | ie = self.ie | |
56 | html = ''' | |
57 | <meta name="og:title" content='Foo'/> | |
58 | <meta content="Some video's description " name="og:description"/> | |
59 | <meta property='og:image' content='http://domain.com/pic.jpg?key1=val1&key2=val2'/> | |
1c29e81e | 60 | <meta content='application/x-shockwave-flash' property='og:video:type'> |
db0a8ad9 | 61 | <meta content='Foo' property=og:foobar> |
448ef1f3 S |
62 | <meta name="og:test1" content='foo > < bar'/> |
63 | <meta name="og:test2" content="foo >//< bar"/> | |
22f5f5c6 | 64 | <meta property=og-test3 content='Ill-formatted opengraph'/> |
14719565 JMF |
65 | ''' |
66 | self.assertEqual(ie._og_search_title(html), 'Foo') | |
67 | self.assertEqual(ie._og_search_description(html), 'Some video\'s description ') | |
68 | self.assertEqual(ie._og_search_thumbnail(html), 'http://domain.com/pic.jpg?key1=val1&key2=val2') | |
1c29e81e | 69 | self.assertEqual(ie._og_search_video_url(html, default=None), None) |
db0a8ad9 | 70 | self.assertEqual(ie._og_search_property('foobar', html), 'Foo') |
448ef1f3 S |
71 | self.assertEqual(ie._og_search_property('test1', html), 'foo > < bar') |
72 | self.assertEqual(ie._og_search_property('test2', html), 'foo >//< bar') | |
22f5f5c6 | 73 | self.assertEqual(ie._og_search_property('test3', html), 'Ill-formatted opengraph') |
b070564e S |
74 | self.assertEqual(ie._og_search_property(('test0', 'test1'), html), 'foo > < bar') |
75 | self.assertRaises(RegexNotFoundError, ie._og_search_property, 'test0', html, None, fatal=True) | |
76 | self.assertRaises(RegexNotFoundError, ie._og_search_property, ('test0', 'test00'), html, None, fatal=True) | |
14719565 | 77 | |
bec22481 PH |
78 | def test_html_search_meta(self): |
79 | ie = self.ie | |
80 | html = ''' | |
81 | <meta name="a" content="1" /> | |
82 | <meta name='b' content='2'> | |
83 | <meta name="c" content='3'> | |
84 | <meta name=d content='4'> | |
85 | <meta property="e" content='5' > | |
86 | <meta content="6" name="f"> | |
87 | ''' | |
88 | ||
89 | self.assertEqual(ie._html_search_meta('a', html), '1') | |
90 | self.assertEqual(ie._html_search_meta('b', html), '2') | |
91 | self.assertEqual(ie._html_search_meta('c', html), '3') | |
92 | self.assertEqual(ie._html_search_meta('d', html), '4') | |
93 | self.assertEqual(ie._html_search_meta('e', html), '5') | |
94 | self.assertEqual(ie._html_search_meta('f', html), '6') | |
88d9f6c0 S |
95 | self.assertEqual(ie._html_search_meta(('a', 'b', 'c'), html), '1') |
96 | self.assertEqual(ie._html_search_meta(('c', 'b', 'a'), html), '3') | |
97 | self.assertEqual(ie._html_search_meta(('z', 'x', 'c'), html), '3') | |
98 | self.assertRaises(RegexNotFoundError, ie._html_search_meta, 'z', html, None, fatal=True) | |
99 | self.assertRaises(RegexNotFoundError, ie._html_search_meta, ('z', 'x'), html, None, fatal=True) | |
bec22481 | 100 | |
29f7c58a | 101 | def test_search_json_ld_realworld(self): |
d5c32548 ZM |
102 | _TESTS = [ |
103 | # https://github.com/ytdl-org/youtube-dl/issues/23306 | |
104 | ( | |
105 | r'''<script type="application/ld+json"> | |
29f7c58a | 106 | { |
107 | "@context": "http://schema.org/", | |
108 | "@type": "VideoObject", | |
109 | "name": "1 On 1 With Kleio", | |
110 | "url": "https://www.eporner.com/hd-porn/xN49A1cT3eB/1-On-1-With-Kleio/", | |
111 | "duration": "PT0H12M23S", | |
112 | "thumbnailUrl": ["https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg", "https://imggen.eporner.com/780814/1920/1080/9.jpg"], | |
113 | "contentUrl": "https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4", | |
114 | "embedUrl": "https://www.eporner.com/embed/xN49A1cT3eB/1-On-1-With-Kleio/", | |
115 | "image": "https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg", | |
116 | "width": "1920", | |
117 | "height": "1080", | |
118 | "encodingFormat": "mp4", | |
119 | "bitrate": "6617kbps", | |
120 | "isFamilyFriendly": "False", | |
121 | "description": "Kleio Valentien", | |
122 | "uploadDate": "2015-12-05T21:24:35+01:00", | |
123 | "interactionStatistic": { | |
124 | "@type": "InteractionCounter", | |
125 | "interactionType": { "@type": "http://schema.org/WatchAction" }, | |
126 | "userInteractionCount": 1120958 | |
127 | }, "aggregateRating": { | |
128 | "@type": "AggregateRating", | |
129 | "ratingValue": "88", | |
130 | "ratingCount": "630", | |
131 | "bestRating": "100", | |
132 | "worstRating": "0" | |
133 | }, "actor": [{ | |
134 | "@type": "Person", | |
135 | "name": "Kleio Valentien", | |
136 | "url": "https://www.eporner.com/pornstar/kleio-valentien/" | |
137 | }]} | |
d5c32548 ZM |
138 | </script>''', |
139 | { | |
140 | 'title': '1 On 1 With Kleio', | |
141 | 'description': 'Kleio Valentien', | |
142 | 'url': 'https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4', | |
143 | 'timestamp': 1449347075, | |
144 | 'duration': 743.0, | |
145 | 'view_count': 1120958, | |
146 | 'width': 1920, | |
147 | 'height': 1080, | |
148 | }, | |
149 | {}, | |
150 | ), | |
151 | ( | |
152 | r'''<script type="application/ld+json"> | |
153 | { | |
154 | "@context": "https://schema.org", | |
155 | "@graph": [ | |
156 | { | |
157 | "@type": "NewsArticle", | |
158 | "mainEntityOfPage": { | |
159 | "@type": "WebPage", | |
160 | "@id": "https://www.ant1news.gr/Society/article/620286/symmoria-anilikon-dikigoros-thymaton-ithelan-na-toys-apoteleiosoyn" | |
161 | }, | |
162 | "headline": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν", | |
163 | "name": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν", | |
164 | "description": "Τα παιδιά δέχθηκαν την επίθεση επειδή αρνήθηκαν να γίνουν μέλη της συμμορίας, ανέφερε ο Γ. Ζαχαρόπουλος.", | |
165 | "image": { | |
166 | "@type": "ImageObject", | |
167 | "url": "https://ant1media.azureedge.net/imgHandler/1100/a635c968-be71-447c-bf9c-80d843ece21e.jpg", | |
168 | "width": 1100, | |
169 | "height": 756 }, | |
170 | "datePublished": "2021-11-10T08:50:00+03:00", | |
171 | "dateModified": "2021-11-10T08:52:53+03:00", | |
172 | "author": { | |
173 | "@type": "Person", | |
174 | "@id": "https://www.ant1news.gr/", | |
175 | "name": "Ant1news", | |
176 | "image": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png", | |
177 | "url": "https://www.ant1news.gr/" | |
178 | }, | |
179 | "publisher": { | |
180 | "@type": "Organization", | |
181 | "@id": "https://www.ant1news.gr#publisher", | |
182 | "name": "Ant1news", | |
183 | "url": "https://www.ant1news.gr", | |
184 | "logo": { | |
185 | "@type": "ImageObject", | |
186 | "url": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png", | |
187 | "width": 400, | |
188 | "height": 400 }, | |
189 | "sameAs": [ | |
190 | "https://www.facebook.com/Ant1news.gr", | |
191 | "https://twitter.com/antennanews", | |
192 | "https://www.youtube.com/channel/UC0smvAbfczoN75dP0Hw4Pzw", | |
193 | "https://www.instagram.com/ant1news/" | |
194 | ] | |
195 | }, | |
196 | ||
197 | "keywords": "μαχαίρωμα,συμμορία ανηλίκων,ΕΙΔΗΣΕΙΣ,ΕΙΔΗΣΕΙΣ ΣΗΜΕΡΑ,ΝΕΑ,Κοινωνία - Ant1news", | |
198 | ||
199 | ||
200 | "articleSection": "Κοινωνία" | |
201 | } | |
202 | ] | |
203 | } | |
204 | </script>''', | |
205 | { | |
206 | 'timestamp': 1636523400, | |
207 | 'title': 'md5:91fe569e952e4d146485740ae927662b', | |
208 | }, | |
209 | {'expected_type': 'NewsArticle'}, | |
210 | ), | |
211 | ] | |
212 | for html, expected_dict, search_json_ld_kwargs in _TESTS: | |
213 | expect_dict( | |
214 | self, | |
215 | self.ie._search_json_ld(html, None, **search_json_ld_kwargs), | |
216 | expected_dict | |
217 | ) | |
29f7c58a | 218 | |
6a801f44 JMF |
219 | def test_download_json(self): |
220 | uri = encode_data_uri(b'{"foo": "blah"}', 'application/json') | |
221 | self.assertEqual(self.ie._download_json(uri, None), {'foo': 'blah'}) | |
222 | uri = encode_data_uri(b'callback({"foo": "blah"})', 'application/javascript') | |
223 | self.assertEqual(self.ie._download_json(uri, None, transform_source=strip_jsonp), {'foo': 'blah'}) | |
224 | uri = encode_data_uri(b'{"foo": invalid}', 'application/json') | |
225 | self.assertRaises(ExtractorError, self.ie._download_json, uri, None) | |
226 | self.assertEqual(self.ie._download_json(uri, None, fatal=False), None) | |
227 | ||
d493f15c | 228 | def test_parse_html5_media_entries(self): |
29f7c58a | 229 | # inline video tag |
230 | expect_dict( | |
231 | self, | |
232 | self.ie._parse_html5_media_entries( | |
233 | 'https://127.0.0.1/video.html', | |
234 | r'<html><video src="/vid.mp4" /></html>', None)[0], | |
235 | { | |
236 | 'formats': [{ | |
237 | 'url': 'https://127.0.0.1/vid.mp4', | |
238 | }], | |
239 | }) | |
240 | ||
d493f15c S |
241 | # from https://www.r18.com/ |
242 | # with kpbs in label | |
243 | expect_dict( | |
244 | self, | |
245 | self.ie._parse_html5_media_entries( | |
246 | 'https://www.r18.com/', | |
247 | r''' | |
248 | <video id="samplevideo_amateur" class="js-samplevideo video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" width="400" height="225" poster="//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg"> | |
249 | <source id="video_source" src="https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4" type="video/mp4" res="240" label="300kbps"> | |
250 | <source id="video_source" src="https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4" type="video/mp4" res="480" label="1000kbps"> | |
251 | <source id="video_source" src="https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4" type="video/mp4" res="740" label="1500kbps"> | |
252 | <p>Your browser does not support the video tag.</p> | |
253 | </video> | |
254 | ''', None)[0], | |
255 | { | |
256 | 'formats': [{ | |
257 | 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4', | |
258 | 'ext': 'mp4', | |
259 | 'format_id': '300kbps', | |
260 | 'height': 240, | |
261 | 'tbr': 300, | |
262 | }, { | |
263 | 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4', | |
264 | 'ext': 'mp4', | |
265 | 'format_id': '1000kbps', | |
266 | 'height': 480, | |
267 | 'tbr': 1000, | |
268 | }, { | |
269 | 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4', | |
270 | 'ext': 'mp4', | |
271 | 'format_id': '1500kbps', | |
272 | 'height': 740, | |
273 | 'tbr': 1500, | |
274 | }], | |
275 | 'thumbnail': '//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg' | |
276 | }) | |
277 | ||
278 | # from https://www.csfd.cz/ | |
279 | # with width and height | |
280 | expect_dict( | |
281 | self, | |
282 | self.ie._parse_html5_media_entries( | |
283 | 'https://www.csfd.cz/', | |
284 | r''' | |
285 | <video width="770" height="328" preload="none" controls poster="https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360" > | |
286 | <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4" type="video/mp4" width="640" height="360"> | |
287 | <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4" type="video/mp4" width="1280" height="720"> | |
288 | <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4" type="video/mp4" width="1920" height="1080"> | |
289 | <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm" type="video/webm" width="640" height="360"> | |
290 | <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm" type="video/webm" width="1280" height="720"> | |
291 | <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm" type="video/webm" width="1920" height="1080"> | |
292 | <track src="https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt" type="text/x-srt" kind="subtitles" srclang="cs" label="cs"> | |
293 | </video> | |
294 | ''', None)[0], | |
295 | { | |
296 | 'formats': [{ | |
297 | 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4', | |
298 | 'ext': 'mp4', | |
299 | 'width': 640, | |
300 | 'height': 360, | |
301 | }, { | |
302 | 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4', | |
303 | 'ext': 'mp4', | |
304 | 'width': 1280, | |
305 | 'height': 720, | |
306 | }, { | |
307 | 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4', | |
308 | 'ext': 'mp4', | |
309 | 'width': 1920, | |
310 | 'height': 1080, | |
311 | }, { | |
312 | 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm', | |
313 | 'ext': 'webm', | |
314 | 'width': 640, | |
315 | 'height': 360, | |
316 | }, { | |
317 | 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm', | |
318 | 'ext': 'webm', | |
319 | 'width': 1280, | |
320 | 'height': 720, | |
321 | }, { | |
322 | 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm', | |
323 | 'ext': 'webm', | |
324 | 'width': 1920, | |
325 | 'height': 1080, | |
326 | }], | |
327 | 'subtitles': { | |
328 | 'cs': [{'url': 'https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt'}] | |
329 | }, | |
330 | 'thumbnail': 'https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360' | |
331 | }) | |
332 | ||
333 | # from https://tamasha.com/v/Kkdjw | |
334 | # with height in label | |
335 | expect_dict( | |
336 | self, | |
337 | self.ie._parse_html5_media_entries( | |
338 | 'https://tamasha.com/v/Kkdjw', | |
339 | r''' | |
340 | <video crossorigin="anonymous"> | |
341 | <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4" label="AUTO" res="0"/> | |
342 | <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4" | |
343 | label="240p" res="240"/> | |
344 | <source src="https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4" type="video/mp4" | |
345 | label="144p" res="144"/> | |
346 | </video> | |
347 | ''', None)[0], | |
348 | { | |
349 | 'formats': [{ | |
350 | 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4', | |
351 | }, { | |
352 | 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4', | |
353 | 'ext': 'mp4', | |
354 | 'format_id': '240p', | |
355 | 'height': 240, | |
356 | }, { | |
357 | 'url': 'https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4', | |
358 | 'ext': 'mp4', | |
359 | 'format_id': '144p', | |
360 | 'height': 144, | |
361 | }] | |
362 | }) | |
363 | ||
364 | # from https://www.directvnow.com | |
365 | # with data-src | |
366 | expect_dict( | |
367 | self, | |
368 | self.ie._parse_html5_media_entries( | |
369 | 'https://www.directvnow.com', | |
370 | r''' | |
371 | <video id="vid1" class="header--video-masked active" muted playsinline> | |
372 | <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" /> | |
373 | </video> | |
374 | ''', None)[0], | |
375 | { | |
376 | 'formats': [{ | |
377 | 'ext': 'mp4', | |
378 | 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4', | |
379 | }] | |
380 | }) | |
381 | ||
382 | # from https://www.directvnow.com | |
383 | # with data-src | |
384 | expect_dict( | |
385 | self, | |
386 | self.ie._parse_html5_media_entries( | |
387 | 'https://www.directvnow.com', | |
388 | r''' | |
389 | <video id="vid1" class="header--video-masked active" muted playsinline> | |
390 | <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" /> | |
391 | </video> | |
392 | ''', None)[0], | |
393 | { | |
394 | 'formats': [{ | |
395 | 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4', | |
396 | 'ext': 'mp4', | |
397 | }] | |
398 | }) | |
399 | ||
400 | # from https://www.klarna.com/uk/ | |
401 | # with data-video-src | |
402 | expect_dict( | |
403 | self, | |
404 | self.ie._parse_html5_media_entries( | |
405 | 'https://www.directvnow.com', | |
406 | r''' | |
407 | <video loop autoplay muted class="responsive-video block-kl__video video-on-medium"> | |
408 | <source src="" data-video-desktop data-video-src="https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4" type="video/mp4" /> | |
409 | </video> | |
410 | ''', None)[0], | |
411 | { | |
412 | 'formats': [{ | |
413 | 'url': 'https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4', | |
414 | 'ext': 'mp4', | |
415 | }], | |
416 | }) | |
417 | ||
7f3590c4 S |
418 | def test_extract_jwplayer_data_realworld(self): |
419 | # from http://www.suffolk.edu/sjc/ | |
420 | expect_dict( | |
421 | self, | |
422 | self.ie._extract_jwplayer_data(r''' | |
423 | <script type='text/javascript'> | |
424 | jwplayer('my-video').setup({ | |
425 | file: 'rtmp://192.138.214.154/live/sjclive', | |
426 | fallback: 'true', | |
427 | width: '95%', | |
428 | aspectratio: '16:9', | |
429 | primary: 'flash', | |
430 | mediaid:'XEgvuql4' | |
431 | }); | |
432 | </script> | |
433 | ''', None, require_title=False), | |
434 | { | |
435 | 'id': 'XEgvuql4', | |
436 | 'formats': [{ | |
437 | 'url': 'rtmp://192.138.214.154/live/sjclive', | |
438 | 'ext': 'flv' | |
439 | }] | |
440 | }) | |
441 | ||
442 | # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/ | |
443 | expect_dict( | |
444 | self, | |
445 | self.ie._extract_jwplayer_data(r''' | |
446 | <script type="text/javascript"> | |
447 | jwplayer("mediaplayer").setup({ | |
448 | 'videoid': "7564", | |
449 | 'width': "100%", | |
450 | 'aspectratio': "16:9", | |
451 | 'stretching': "exactfit", | |
452 | 'autostart': 'false', | |
453 | 'flashplayer': "https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf", | |
454 | 'file': "https://cdn.pornoxo.com/key=MF+oEbaxqTKb50P-w9G3nA,end=1489689259,ip=104.199.146.27/ip=104.199.146.27/speed=6573765/buffer=3.0/2009-12/4b2157147afe5efa93ce1978e0265289c193874e02597.flv", | |
455 | 'image': "https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg", | |
456 | 'filefallback': "https://cdn.pornoxo.com/key=9ZPsTR5EvPLQrBaak2MUGA,end=1489689259,ip=104.199.146.27/ip=104.199.146.27/speed=6573765/buffer=3.0/2009-12/m_4b2157147afe5efa93ce1978e0265289c193874e02597.mp4", | |
457 | 'logo.hide': true, | |
458 | 'skin': "https://t04.vipstreamservice.com/jwplayer/skin/modieus-blk.zip", | |
459 | 'plugins': "https://t04.vipstreamservice.com/jwplayer/dock/dockableskinnableplugin.swf", | |
460 | 'dockableskinnableplugin.piclink': "/index.php?key=ajax-videothumbsn&vid=7564&data=2009-12--14--4b2157147afe5efa93ce1978e0265289c193874e02597.flv--17370", | |
461 | 'controlbar': 'bottom', | |
462 | 'modes': [ | |
463 | {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'} | |
464 | ], | |
465 | 'provider': 'http' | |
466 | }); | |
467 | //noinspection JSAnnotator | |
468 | invideo.setup({ | |
469 | adsUrl: "/banner-iframe/?zoneId=32", | |
470 | adsUrl2: "", | |
471 | autostart: false | |
472 | }); | |
473 | </script> | |
474 | ''', 'dummy', require_title=False), | |
475 | { | |
476 | 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg', | |
477 | 'formats': [{ | |
478 | 'url': 'https://cdn.pornoxo.com/key=MF+oEbaxqTKb50P-w9G3nA,end=1489689259,ip=104.199.146.27/ip=104.199.146.27/speed=6573765/buffer=3.0/2009-12/4b2157147afe5efa93ce1978e0265289c193874e02597.flv', | |
479 | 'ext': 'flv' | |
480 | }] | |
481 | }) | |
482 | ||
483 | # from http://www.indiedb.com/games/king-machine/videos | |
484 | expect_dict( | |
485 | self, | |
486 | self.ie._extract_jwplayer_data(r''' | |
487 | <script> | |
488 | jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/\/www.indiedb.com\/","displaytitle":false,"autostart":false,"repeat":false,"title":"king machine trailer 1","sharing":{"link":"http:\/\/www.indiedb.com\/games\/king-machine\/videos\/king-machine-trailer-1","code":"<iframe width=\"560\" height=\"315\" src=\"http:\/\/www.indiedb.com\/media\/iframe\/1522983\" frameborder=\"0\" allowfullscreen><\/iframe><br><a href=\"http:\/\/www.indiedb.com\/games\/king-machine\/videos\/king-machine-trailer-1\">king machine trailer 1 - Indie DB<\/a>"},"related":{"file":"http:\/\/rss.indiedb.com\/media\/recommended\/1522983\/feed\/rss.xml","dimensions":"160x120","onclick":"link"},"sources":[{"file":"http:\/\/cdn.dbolical.com\/cache\/videos\/games\/1\/50\/49678\/encode_mp4\/king-machine-trailer.mp4","label":"360p SD","default":"true"},{"file":"http:\/\/cdn.dbolical.com\/cache\/videos\/games\/1\/50\/49678\/encode720p_mp4\/king-machine-trailer.mp4","label":"720p HD"}],"image":"http:\/\/media.indiedb.com\/cache\/images\/games\/1\/50\/49678\/thumb_620x2000\/king-machine-trailer.mp4.jpg","advertising":{"client":"vast","tag":"http:\/\/ads.intergi.com\/adrawdata\/3.0\/5205\/4251742\/0\/1013\/ADTECH;cors=yes;width=560;height=315;referring_url=http:\/\/www.indiedb.com\/games\/king-machine\/videos\/king-machine-trailer-1;content_url=http:\/\/www.indiedb.com\/games\/king-machine\/videos\/king-machine-trailer-1;media_id=1522983;title=king+machine+trailer+1;device=__DEVICE__;model=__MODEL__;os=Windows+OS;osversion=__OSVERSION__;ua=__UA__;ip=109.171.17.81;uniqueid=1522983;tags=__TAGS__;number=58cac25928151;time=1489683033"},"width":620,"height":349}).once("play", function(event) { | |
489 | videoAnalytics("play"); | |
490 | }).once("complete", function(event) { | |
491 | videoAnalytics("completed"); | |
492 | }); | |
493 | </script> | |
494 | ''', 'dummy'), | |
495 | { | |
496 | 'title': 'king machine trailer 1', | |
497 | 'thumbnail': 'http://media.indiedb.com/cache/images/games/1/50/49678/thumb_620x2000/king-machine-trailer.mp4.jpg', | |
498 | 'formats': [{ | |
499 | 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4', | |
500 | 'height': 360, | |
501 | 'ext': 'mp4' | |
502 | }, { | |
503 | 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4', | |
504 | 'height': 720, | |
505 | 'ext': 'mp4' | |
506 | }] | |
507 | }) | |
508 | ||
cb252080 S |
509 | def test_parse_m3u8_formats(self): |
510 | _TEST_CASES = [ | |
511 | ( | |
310c2ed2 | 512 | # https://github.com/ytdl-org/youtube-dl/issues/11995 |
513 | # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor | |
514 | 'img_bipbop_adv_example_fmp4', | |
515 | 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 516 | [{ |
310c2ed2 | 517 | 'format_id': 'aud1-English', |
518 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a1/prog_index.m3u8', | |
519 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
520 | 'language': 'en', | |
cb252080 | 521 | 'ext': 'mp4', |
177877c5 | 522 | 'protocol': 'm3u8_native', |
310c2ed2 | 523 | 'audio_ext': 'mp4', |
cb252080 | 524 | }, { |
310c2ed2 | 525 | 'format_id': 'aud2-English', |
526 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a2/prog_index.m3u8', | |
527 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
528 | 'language': 'en', | |
cb252080 | 529 | 'ext': 'mp4', |
177877c5 | 530 | 'protocol': 'm3u8_native', |
310c2ed2 | 531 | 'audio_ext': 'mp4', |
cb252080 | 532 | }, { |
310c2ed2 | 533 | 'format_id': 'aud3-English', |
534 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a3/prog_index.m3u8', | |
535 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
536 | 'language': 'en', | |
cb252080 | 537 | 'ext': 'mp4', |
177877c5 | 538 | 'protocol': 'm3u8_native', |
310c2ed2 | 539 | 'audio_ext': 'mp4', |
cb252080 | 540 | }, { |
310c2ed2 | 541 | 'format_id': '530', |
542 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8', | |
543 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 544 | 'ext': 'mp4', |
177877c5 | 545 | 'protocol': 'm3u8_native', |
310c2ed2 | 546 | 'width': 480, |
547 | 'height': 270, | |
548 | 'vcodec': 'avc1.640015', | |
cb252080 | 549 | }, { |
310c2ed2 | 550 | 'format_id': '561', |
551 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8', | |
552 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 553 | 'ext': 'mp4', |
177877c5 | 554 | 'protocol': 'm3u8_native', |
310c2ed2 | 555 | 'width': 480, |
556 | 'height': 270, | |
557 | 'vcodec': 'avc1.640015', | |
558 | }, { | |
559 | 'format_id': '753', | |
560 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8', | |
561 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 562 | 'ext': 'mp4', |
177877c5 | 563 | 'protocol': 'm3u8_native', |
310c2ed2 | 564 | 'width': 480, |
565 | 'height': 270, | |
566 | 'vcodec': 'avc1.640015', | |
cb252080 | 567 | }, { |
310c2ed2 | 568 | 'format_id': '895', |
569 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8', | |
570 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 571 | 'ext': 'mp4', |
177877c5 | 572 | 'protocol': 'm3u8_native', |
310c2ed2 | 573 | 'width': 640, |
574 | 'height': 360, | |
575 | 'vcodec': 'avc1.64001e', | |
cb252080 | 576 | }, { |
310c2ed2 | 577 | 'format_id': '926', |
578 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8', | |
579 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 580 | 'ext': 'mp4', |
177877c5 | 581 | 'protocol': 'm3u8_native', |
310c2ed2 | 582 | 'width': 640, |
583 | 'height': 360, | |
584 | 'vcodec': 'avc1.64001e', | |
cb252080 | 585 | }, { |
310c2ed2 | 586 | 'format_id': '1118', |
587 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8', | |
588 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 589 | 'ext': 'mp4', |
177877c5 | 590 | 'protocol': 'm3u8_native', |
310c2ed2 | 591 | 'width': 640, |
592 | 'height': 360, | |
593 | 'vcodec': 'avc1.64001e', | |
cb252080 | 594 | }, { |
310c2ed2 | 595 | 'format_id': '1265', |
596 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8', | |
597 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 598 | 'ext': 'mp4', |
177877c5 | 599 | 'protocol': 'm3u8_native', |
310c2ed2 | 600 | 'width': 768, |
601 | 'height': 432, | |
602 | 'vcodec': 'avc1.64001e', | |
cb252080 | 603 | }, { |
310c2ed2 | 604 | 'format_id': '1295', |
605 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8', | |
606 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 607 | 'ext': 'mp4', |
177877c5 | 608 | 'protocol': 'm3u8_native', |
310c2ed2 | 609 | 'width': 768, |
610 | 'height': 432, | |
611 | 'vcodec': 'avc1.64001e', | |
cb252080 | 612 | }, { |
310c2ed2 | 613 | 'format_id': '1487', |
614 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8', | |
615 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 616 | 'ext': 'mp4', |
177877c5 | 617 | 'protocol': 'm3u8_native', |
310c2ed2 | 618 | 'width': 768, |
619 | 'height': 432, | |
620 | 'vcodec': 'avc1.64001e', | |
621 | }, { | |
622 | 'format_id': '2168', | |
623 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8', | |
624 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 625 | 'ext': 'mp4', |
177877c5 | 626 | 'protocol': 'm3u8_native', |
310c2ed2 | 627 | 'width': 960, |
628 | 'height': 540, | |
629 | 'vcodec': 'avc1.640020', | |
cb252080 | 630 | }, { |
310c2ed2 | 631 | 'format_id': '2198', |
632 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8', | |
633 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 634 | 'ext': 'mp4', |
177877c5 | 635 | 'protocol': 'm3u8_native', |
310c2ed2 | 636 | 'width': 960, |
637 | 'height': 540, | |
638 | 'vcodec': 'avc1.640020', | |
cb252080 | 639 | }, { |
310c2ed2 | 640 | 'format_id': '2390', |
641 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8', | |
642 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 643 | 'ext': 'mp4', |
177877c5 | 644 | 'protocol': 'm3u8_native', |
310c2ed2 | 645 | 'width': 960, |
646 | 'height': 540, | |
647 | 'vcodec': 'avc1.640020', | |
cb252080 | 648 | }, { |
310c2ed2 | 649 | 'format_id': '3168', |
650 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8', | |
651 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 652 | 'ext': 'mp4', |
177877c5 | 653 | 'protocol': 'm3u8_native', |
310c2ed2 | 654 | 'width': 1280, |
655 | 'height': 720, | |
656 | 'vcodec': 'avc1.640020', | |
cb252080 | 657 | }, { |
310c2ed2 | 658 | 'format_id': '3199', |
659 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8', | |
660 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 661 | 'ext': 'mp4', |
177877c5 | 662 | 'protocol': 'm3u8_native', |
310c2ed2 | 663 | 'width': 1280, |
664 | 'height': 720, | |
665 | 'vcodec': 'avc1.640020', | |
cb252080 | 666 | }, { |
310c2ed2 | 667 | 'format_id': '3391', |
668 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8', | |
669 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 670 | 'ext': 'mp4', |
177877c5 | 671 | 'protocol': 'm3u8_native', |
310c2ed2 | 672 | 'width': 1280, |
673 | 'height': 720, | |
674 | 'vcodec': 'avc1.640020', | |
675 | }, { | |
676 | 'format_id': '4670', | |
677 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8', | |
678 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 679 | 'ext': 'mp4', |
177877c5 | 680 | 'protocol': 'm3u8_native', |
310c2ed2 | 681 | 'width': 1920, |
682 | 'height': 1080, | |
683 | 'vcodec': 'avc1.64002a', | |
cb252080 | 684 | }, { |
310c2ed2 | 685 | 'format_id': '4701', |
686 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8', | |
687 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 688 | 'ext': 'mp4', |
177877c5 | 689 | 'protocol': 'm3u8_native', |
310c2ed2 | 690 | 'width': 1920, |
691 | 'height': 1080, | |
692 | 'vcodec': 'avc1.64002a', | |
cb252080 | 693 | }, { |
310c2ed2 | 694 | 'format_id': '4893', |
695 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8', | |
696 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 697 | 'ext': 'mp4', |
177877c5 | 698 | 'protocol': 'm3u8_native', |
310c2ed2 | 699 | 'width': 1920, |
700 | 'height': 1080, | |
701 | 'vcodec': 'avc1.64002a', | |
cb252080 | 702 | }, { |
310c2ed2 | 703 | 'format_id': '6170', |
704 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8', | |
705 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 706 | 'ext': 'mp4', |
177877c5 | 707 | 'protocol': 'm3u8_native', |
310c2ed2 | 708 | 'width': 1920, |
709 | 'height': 1080, | |
710 | 'vcodec': 'avc1.64002a', | |
cb252080 | 711 | }, { |
310c2ed2 | 712 | 'format_id': '6200', |
713 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8', | |
714 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 715 | 'ext': 'mp4', |
177877c5 | 716 | 'protocol': 'm3u8_native', |
310c2ed2 | 717 | 'width': 1920, |
718 | 'height': 1080, | |
719 | 'vcodec': 'avc1.64002a', | |
cb252080 | 720 | }, { |
310c2ed2 | 721 | 'format_id': '6392', |
722 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8', | |
723 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
cb252080 | 724 | 'ext': 'mp4', |
177877c5 | 725 | 'protocol': 'm3u8_native', |
310c2ed2 | 726 | 'width': 1920, |
727 | 'height': 1080, | |
728 | 'vcodec': 'avc1.64002a', | |
729 | }, { | |
730 | 'format_id': '7968', | |
731 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8', | |
732 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
ddd258f9 | 733 | 'ext': 'mp4', |
177877c5 | 734 | 'protocol': 'm3u8_native', |
310c2ed2 | 735 | 'width': 1920, |
736 | 'height': 1080, | |
737 | 'vcodec': 'avc1.64002a', | |
ddd258f9 | 738 | }, { |
310c2ed2 | 739 | 'format_id': '7998', |
740 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8', | |
741 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
ddd258f9 | 742 | 'ext': 'mp4', |
177877c5 | 743 | 'protocol': 'm3u8_native', |
310c2ed2 | 744 | 'width': 1920, |
745 | 'height': 1080, | |
746 | 'vcodec': 'avc1.64002a', | |
ddd258f9 | 747 | }, { |
310c2ed2 | 748 | 'format_id': '8190', |
749 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8', | |
750 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8', | |
ddd258f9 | 751 | 'ext': 'mp4', |
177877c5 | 752 | 'protocol': 'm3u8_native', |
310c2ed2 | 753 | 'width': 1920, |
754 | 'height': 1080, | |
755 | 'vcodec': 'avc1.64002a', | |
a0c3b2d5 F |
756 | }], |
757 | {} | |
fc746c3f | 758 | ), |
73b9088a F |
759 | ( |
760 | 'bipbop_16x9', | |
761 | 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8', | |
762 | [{ | |
177877c5 | 763 | 'format_id': 'bipbop_audio-BipBop Audio 2', |
764 | 'format_index': None, | |
765 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/alternate_audio_aac/prog_index.m3u8', | |
766 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8', | |
767 | 'language': 'eng', | |
768 | 'ext': 'mp4', | |
769 | 'protocol': 'm3u8_native', | |
770 | 'preference': None, | |
771 | 'quality': None, | |
772 | 'vcodec': 'none', | |
773 | 'audio_ext': 'mp4', | |
774 | 'video_ext': 'none', | |
775 | }, { | |
776 | 'format_id': '41', | |
777 | 'format_index': None, | |
778 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8', | |
779 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8', | |
780 | 'tbr': 41.457, | |
781 | 'ext': 'mp4', | |
782 | 'fps': None, | |
783 | 'protocol': 'm3u8_native', | |
784 | 'preference': None, | |
785 | 'quality': None, | |
786 | 'vcodec': 'none', | |
787 | 'acodec': 'mp4a.40.2', | |
788 | 'audio_ext': 'mp4', | |
789 | 'video_ext': 'none', | |
790 | 'abr': 41.457, | |
791 | }, { | |
792 | 'format_id': '263', | |
793 | 'format_index': None, | |
794 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8', | |
795 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8', | |
796 | 'tbr': 263.851, | |
797 | 'ext': 'mp4', | |
798 | 'fps': None, | |
799 | 'protocol': 'm3u8_native', | |
800 | 'preference': None, | |
801 | 'quality': None, | |
802 | 'width': 416, | |
803 | 'height': 234, | |
804 | 'vcodec': 'avc1.4d400d', | |
805 | 'acodec': 'mp4a.40.2', | |
806 | 'video_ext': 'mp4', | |
807 | 'audio_ext': 'none', | |
808 | 'vbr': 263.851, | |
809 | 'abr': 0, | |
810 | }, { | |
811 | 'format_id': '577', | |
812 | 'format_index': None, | |
813 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8', | |
814 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8', | |
815 | 'tbr': 577.61, | |
816 | 'ext': 'mp4', | |
817 | 'fps': None, | |
818 | 'protocol': 'm3u8_native', | |
819 | 'preference': None, | |
820 | 'quality': None, | |
821 | 'width': 640, | |
822 | 'height': 360, | |
823 | 'vcodec': 'avc1.4d401e', | |
824 | 'acodec': 'mp4a.40.2', | |
825 | 'video_ext': 'mp4', | |
826 | 'audio_ext': 'none', | |
827 | 'vbr': 577.61, | |
828 | 'abr': 0, | |
829 | }, { | |
830 | 'format_id': '915', | |
831 | 'format_index': None, | |
832 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8', | |
833 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8', | |
834 | 'tbr': 915.905, | |
835 | 'ext': 'mp4', | |
836 | 'fps': None, | |
837 | 'protocol': 'm3u8_native', | |
838 | 'preference': None, | |
839 | 'quality': None, | |
840 | 'width': 960, | |
841 | 'height': 540, | |
842 | 'vcodec': 'avc1.4d401f', | |
843 | 'acodec': 'mp4a.40.2', | |
844 | 'video_ext': 'mp4', | |
845 | 'audio_ext': 'none', | |
846 | 'vbr': 915.905, | |
847 | 'abr': 0, | |
848 | }, { | |
849 | 'format_id': '1030', | |
850 | 'format_index': None, | |
851 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8', | |
852 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8', | |
853 | 'tbr': 1030.138, | |
854 | 'ext': 'mp4', | |
855 | 'fps': None, | |
856 | 'protocol': 'm3u8_native', | |
857 | 'preference': None, | |
858 | 'quality': None, | |
859 | 'width': 1280, | |
860 | 'height': 720, | |
861 | 'vcodec': 'avc1.4d401f', | |
862 | 'acodec': 'mp4a.40.2', | |
863 | 'video_ext': 'mp4', | |
864 | 'audio_ext': 'none', | |
865 | 'vbr': 1030.138, | |
866 | 'abr': 0, | |
867 | }, { | |
868 | 'format_id': '1924', | |
869 | 'format_index': None, | |
870 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8', | |
871 | 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8', | |
872 | 'tbr': 1924.009, | |
873 | 'ext': 'mp4', | |
874 | 'fps': None, | |
875 | 'protocol': 'm3u8_native', | |
876 | 'preference': None, | |
877 | 'quality': None, | |
878 | 'width': 1920, | |
879 | 'height': 1080, | |
880 | 'vcodec': 'avc1.4d401f', | |
881 | 'acodec': 'mp4a.40.2', | |
882 | 'video_ext': 'mp4', | |
883 | 'audio_ext': 'none', | |
884 | 'vbr': 1924.009, | |
885 | 'abr': 0, | |
73b9088a F |
886 | }], |
887 | { | |
177877c5 | 888 | 'en': [{ |
889 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng/prog_index.m3u8', | |
890 | 'ext': 'vtt', | |
891 | 'protocol': 'm3u8_native' | |
73b9088a | 892 | }, { |
177877c5 | 893 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng_forced/prog_index.m3u8', |
894 | 'ext': 'vtt', | |
895 | 'protocol': 'm3u8_native' | |
73b9088a | 896 | }], |
177877c5 | 897 | 'fr': [{ |
898 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra/prog_index.m3u8', | |
899 | 'ext': 'vtt', | |
900 | 'protocol': 'm3u8_native' | |
73b9088a | 901 | }, { |
177877c5 | 902 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra_forced/prog_index.m3u8', |
903 | 'ext': 'vtt', | |
904 | 'protocol': 'm3u8_native' | |
73b9088a | 905 | }], |
177877c5 | 906 | 'es': [{ |
907 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa/prog_index.m3u8', | |
908 | 'ext': 'vtt', | |
909 | 'protocol': 'm3u8_native' | |
73b9088a | 910 | }, { |
177877c5 | 911 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa_forced/prog_index.m3u8', |
912 | 'ext': 'vtt', | |
913 | 'protocol': 'm3u8_native' | |
73b9088a | 914 | }], |
177877c5 | 915 | 'ja': [{ |
916 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn/prog_index.m3u8', | |
917 | 'ext': 'vtt', | |
918 | 'protocol': 'm3u8_native' | |
73b9088a | 919 | }, { |
177877c5 | 920 | 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn_forced/prog_index.m3u8', |
921 | 'ext': 'vtt', | |
922 | 'protocol': 'm3u8_native' | |
73b9088a F |
923 | }], |
924 | } | |
925 | ), | |
cb252080 S |
926 | ] |
927 | ||
a0c3b2d5 | 928 | for m3u8_file, m3u8_url, expected_formats, expected_subs in _TEST_CASES: |
cb252080 S |
929 | with io.open('./test/testdata/m3u8/%s.m3u8' % m3u8_file, |
930 | mode='r', encoding='utf-8') as f: | |
a0c3b2d5 | 931 | formats, subs = self.ie._parse_m3u8_formats_and_subtitles( |
cb252080 S |
932 | f.read(), m3u8_url, ext='mp4') |
933 | self.ie._sort_formats(formats) | |
934 | expect_value(self, formats, expected_formats, None) | |
a0c3b2d5 | 935 | expect_value(self, subs, expected_subs, None) |
cb252080 | 936 | |
48504785 S |
937 | def test_parse_mpd_formats(self): |
938 | _TEST_CASES = [ | |
939 | ( | |
067aa17e | 940 | # https://github.com/ytdl-org/youtube-dl/issues/13919 |
9d6ac71c | 941 | # Also tests duplicate representation ids, see |
067aa17e | 942 | # https://github.com/ytdl-org/youtube-dl/issues/15111 |
48504785 | 943 | 'float_duration', |
2e27421c S |
944 | 'http://unknown/manifest.mpd', # mpd_url |
945 | None, # mpd_base_url | |
48504785 | 946 | [{ |
9d6ac71c S |
947 | 'manifest_url': 'http://unknown/manifest.mpd', |
948 | 'ext': 'm4a', | |
949 | 'format_id': '318597', | |
950 | 'format_note': 'DASH audio', | |
951 | 'protocol': 'http_dash_segments', | |
952 | 'acodec': 'mp4a.40.2', | |
953 | 'vcodec': 'none', | |
954 | 'tbr': 61.587, | |
955 | }, { | |
48504785 S |
956 | 'manifest_url': 'http://unknown/manifest.mpd', |
957 | 'ext': 'mp4', | |
958 | 'format_id': '318597', | |
959 | 'format_note': 'DASH video', | |
960 | 'protocol': 'http_dash_segments', | |
961 | 'acodec': 'none', | |
962 | 'vcodec': 'avc1.42001f', | |
963 | 'tbr': 318.597, | |
964 | 'width': 340, | |
965 | 'height': 192, | |
966 | }, { | |
967 | 'manifest_url': 'http://unknown/manifest.mpd', | |
968 | 'ext': 'mp4', | |
969 | 'format_id': '638590', | |
970 | 'format_note': 'DASH video', | |
971 | 'protocol': 'http_dash_segments', | |
972 | 'acodec': 'none', | |
973 | 'vcodec': 'avc1.42001f', | |
974 | 'tbr': 638.59, | |
975 | 'width': 512, | |
976 | 'height': 288, | |
977 | }, { | |
978 | 'manifest_url': 'http://unknown/manifest.mpd', | |
979 | 'ext': 'mp4', | |
980 | 'format_id': '1022565', | |
981 | 'format_note': 'DASH video', | |
982 | 'protocol': 'http_dash_segments', | |
983 | 'acodec': 'none', | |
984 | 'vcodec': 'avc1.4d001f', | |
985 | 'tbr': 1022.565, | |
986 | 'width': 688, | |
987 | 'height': 384, | |
988 | }, { | |
989 | 'manifest_url': 'http://unknown/manifest.mpd', | |
990 | 'ext': 'mp4', | |
991 | 'format_id': '2046506', | |
992 | 'format_note': 'DASH video', | |
993 | 'protocol': 'http_dash_segments', | |
994 | 'acodec': 'none', | |
995 | 'vcodec': 'avc1.4d001f', | |
996 | 'tbr': 2046.506, | |
997 | 'width': 1024, | |
998 | 'height': 576, | |
999 | }, { | |
1000 | 'manifest_url': 'http://unknown/manifest.mpd', | |
1001 | 'ext': 'mp4', | |
1002 | 'format_id': '3998017', | |
1003 | 'format_note': 'DASH video', | |
1004 | 'protocol': 'http_dash_segments', | |
1005 | 'acodec': 'none', | |
1006 | 'vcodec': 'avc1.640029', | |
1007 | 'tbr': 3998.017, | |
1008 | 'width': 1280, | |
1009 | 'height': 720, | |
1010 | }, { | |
1011 | 'manifest_url': 'http://unknown/manifest.mpd', | |
1012 | 'ext': 'mp4', | |
1013 | 'format_id': '5997485', | |
1014 | 'format_note': 'DASH video', | |
1015 | 'protocol': 'http_dash_segments', | |
1016 | 'acodec': 'none', | |
1017 | 'vcodec': 'avc1.640032', | |
1018 | 'tbr': 5997.485, | |
1019 | 'width': 1920, | |
1020 | 'height': 1080, | |
becdc7f8 F |
1021 | }], |
1022 | {}, | |
41bf647e | 1023 | ), ( |
067aa17e | 1024 | # https://github.com/ytdl-org/youtube-dl/pull/14844 |
41bf647e | 1025 | 'urls_only', |
2e27421c S |
1026 | 'http://unknown/manifest.mpd', # mpd_url |
1027 | None, # mpd_base_url | |
41bf647e PN |
1028 | [{ |
1029 | 'manifest_url': 'http://unknown/manifest.mpd', | |
1030 | 'ext': 'mp4', | |
1031 | 'format_id': 'h264_aac_144p_m4s', | |
1032 | 'format_note': 'DASH video', | |
1033 | 'protocol': 'http_dash_segments', | |
1034 | 'acodec': 'mp4a.40.2', | |
1035 | 'vcodec': 'avc3.42c01e', | |
1036 | 'tbr': 200, | |
1037 | 'width': 256, | |
1038 | 'height': 144, | |
1039 | }, { | |
1040 | 'manifest_url': 'http://unknown/manifest.mpd', | |
1041 | 'ext': 'mp4', | |
1042 | 'format_id': 'h264_aac_240p_m4s', | |
1043 | 'format_note': 'DASH video', | |
1044 | 'protocol': 'http_dash_segments', | |
1045 | 'acodec': 'mp4a.40.2', | |
1046 | 'vcodec': 'avc3.42c01e', | |
1047 | 'tbr': 400, | |
1048 | 'width': 424, | |
1049 | 'height': 240, | |
1050 | }, { | |
1051 | 'manifest_url': 'http://unknown/manifest.mpd', | |
1052 | 'ext': 'mp4', | |
1053 | 'format_id': 'h264_aac_360p_m4s', | |
1054 | 'format_note': 'DASH video', | |
1055 | 'protocol': 'http_dash_segments', | |
1056 | 'acodec': 'mp4a.40.2', | |
1057 | 'vcodec': 'avc3.42c01e', | |
1058 | 'tbr': 800, | |
1059 | 'width': 640, | |
1060 | 'height': 360, | |
1061 | }, { | |
1062 | 'manifest_url': 'http://unknown/manifest.mpd', | |
1063 | 'ext': 'mp4', | |
1064 | 'format_id': 'h264_aac_480p_m4s', | |
1065 | 'format_note': 'DASH video', | |
1066 | 'protocol': 'http_dash_segments', | |
1067 | 'acodec': 'mp4a.40.2', | |
1068 | 'vcodec': 'avc3.42c01e', | |
1069 | 'tbr': 1200, | |
1070 | 'width': 856, | |
1071 | 'height': 480, | |
1072 | }, { | |
1073 | 'manifest_url': 'http://unknown/manifest.mpd', | |
1074 | 'ext': 'mp4', | |
1075 | 'format_id': 'h264_aac_576p_m4s', | |
1076 | 'format_note': 'DASH video', | |
1077 | 'protocol': 'http_dash_segments', | |
1078 | 'acodec': 'mp4a.40.2', | |
1079 | 'vcodec': 'avc3.42c01e', | |
1080 | 'tbr': 1600, | |
1081 | 'width': 1024, | |
1082 | 'height': 576, | |
1083 | }, { | |
1084 | 'manifest_url': 'http://unknown/manifest.mpd', | |
1085 | 'ext': 'mp4', | |
1086 | 'format_id': 'h264_aac_720p_m4s', | |
1087 | 'format_note': 'DASH video', | |
1088 | 'protocol': 'http_dash_segments', | |
1089 | 'acodec': 'mp4a.40.2', | |
1090 | 'vcodec': 'avc3.42c01e', | |
1091 | 'tbr': 2400, | |
1092 | 'width': 1280, | |
1093 | 'height': 720, | |
1094 | }, { | |
1095 | 'manifest_url': 'http://unknown/manifest.mpd', | |
1096 | 'ext': 'mp4', | |
1097 | 'format_id': 'h264_aac_1080p_m4s', | |
1098 | 'format_note': 'DASH video', | |
1099 | 'protocol': 'http_dash_segments', | |
1100 | 'acodec': 'mp4a.40.2', | |
1101 | 'vcodec': 'avc3.42c01e', | |
1102 | 'tbr': 4400, | |
1103 | 'width': 1920, | |
1104 | 'height': 1080, | |
becdc7f8 F |
1105 | }], |
1106 | {}, | |
2e27421c S |
1107 | ), ( |
1108 | # https://github.com/ytdl-org/youtube-dl/issues/20346 | |
1109 | # Media considered unfragmented even though it contains | |
1110 | # Initialization tag | |
1111 | 'unfragmented', | |
1112 | 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', # mpd_url | |
1113 | 'https://v.redd.it/hw1x7rcg7zl21', # mpd_base_url | |
1114 | [{ | |
1115 | 'url': 'https://v.redd.it/hw1x7rcg7zl21/audio', | |
1116 | 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', | |
1117 | 'ext': 'm4a', | |
1118 | 'format_id': 'AUDIO-1', | |
1119 | 'format_note': 'DASH audio', | |
1120 | 'container': 'm4a_dash', | |
1121 | 'acodec': 'mp4a.40.2', | |
1122 | 'vcodec': 'none', | |
1123 | 'tbr': 129.87, | |
1124 | 'asr': 48000, | |
1125 | ||
1126 | }, { | |
1127 | 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240', | |
1128 | 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', | |
1129 | 'ext': 'mp4', | |
1130 | 'format_id': 'VIDEO-2', | |
1131 | 'format_note': 'DASH video', | |
1132 | 'container': 'mp4_dash', | |
1133 | 'acodec': 'none', | |
1134 | 'vcodec': 'avc1.4d401e', | |
1135 | 'tbr': 608.0, | |
1136 | 'width': 240, | |
1137 | 'height': 240, | |
1138 | 'fps': 30, | |
1139 | }, { | |
1140 | 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_360', | |
1141 | 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', | |
1142 | 'ext': 'mp4', | |
1143 | 'format_id': 'VIDEO-1', | |
1144 | 'format_note': 'DASH video', | |
1145 | 'container': 'mp4_dash', | |
1146 | 'acodec': 'none', | |
1147 | 'vcodec': 'avc1.4d401e', | |
1148 | 'tbr': 804.261, | |
1149 | 'width': 360, | |
1150 | 'height': 360, | |
1151 | 'fps': 30, | |
becdc7f8 F |
1152 | }], |
1153 | {}, | |
1154 | ), ( | |
1155 | 'subtitles', | |
1156 | 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1157 | 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/', | |
1158 | [{ | |
177877c5 | 1159 | 'format_id': 'audio=128001', |
1160 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1161 | 'ext': 'm4a', | |
1162 | 'tbr': 128.001, | |
1163 | 'asr': 48000, | |
1164 | 'format_note': 'DASH audio', | |
1165 | 'container': 'm4a_dash', | |
1166 | 'vcodec': 'none', | |
1167 | 'acodec': 'mp4a.40.2', | |
1168 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1169 | 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/', | |
1170 | 'protocol': 'http_dash_segments', | |
1171 | 'audio_ext': 'm4a', | |
1172 | 'video_ext': 'none', | |
1173 | 'abr': 128.001, | |
1174 | }, { | |
1175 | 'format_id': 'video=100000', | |
1176 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1177 | 'ext': 'mp4', | |
1178 | 'width': 336, | |
1179 | 'height': 144, | |
1180 | 'tbr': 100, | |
1181 | 'format_note': 'DASH video', | |
1182 | 'container': 'mp4_dash', | |
1183 | 'vcodec': 'avc1.4D401F', | |
1184 | 'acodec': 'none', | |
1185 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1186 | 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/', | |
1187 | 'protocol': 'http_dash_segments', | |
1188 | 'video_ext': 'mp4', | |
1189 | 'audio_ext': 'none', | |
1190 | 'vbr': 100, | |
1191 | }, { | |
1192 | 'format_id': 'video=326000', | |
1193 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1194 | 'ext': 'mp4', | |
1195 | 'width': 562, | |
1196 | 'height': 240, | |
1197 | 'tbr': 326, | |
1198 | 'format_note': 'DASH video', | |
1199 | 'container': 'mp4_dash', | |
1200 | 'vcodec': 'avc1.4D401F', | |
1201 | 'acodec': 'none', | |
1202 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1203 | 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/', | |
1204 | 'protocol': 'http_dash_segments', | |
1205 | 'video_ext': 'mp4', | |
1206 | 'audio_ext': 'none', | |
1207 | 'vbr': 326, | |
1208 | }, { | |
1209 | 'format_id': 'video=698000', | |
1210 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1211 | 'ext': 'mp4', | |
1212 | 'width': 844, | |
1213 | 'height': 360, | |
1214 | 'tbr': 698, | |
1215 | 'format_note': 'DASH video', | |
1216 | 'container': 'mp4_dash', | |
1217 | 'vcodec': 'avc1.4D401F', | |
1218 | 'acodec': 'none', | |
1219 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1220 | 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/', | |
1221 | 'protocol': 'http_dash_segments', | |
1222 | 'video_ext': 'mp4', | |
1223 | 'audio_ext': 'none', | |
1224 | 'vbr': 698, | |
1225 | }, { | |
1226 | 'format_id': 'video=1493000', | |
1227 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1228 | 'ext': 'mp4', | |
1229 | 'width': 1126, | |
1230 | 'height': 480, | |
1231 | 'tbr': 1493, | |
1232 | 'format_note': 'DASH video', | |
1233 | 'container': 'mp4_dash', | |
1234 | 'vcodec': 'avc1.4D401F', | |
1235 | 'acodec': 'none', | |
1236 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1237 | 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/', | |
1238 | 'protocol': 'http_dash_segments', | |
1239 | 'video_ext': 'mp4', | |
1240 | 'audio_ext': 'none', | |
1241 | 'vbr': 1493, | |
1242 | }, { | |
1243 | 'format_id': 'video=4482000', | |
1244 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1245 | 'ext': 'mp4', | |
1246 | 'width': 1688, | |
1247 | 'height': 720, | |
1248 | 'tbr': 4482, | |
1249 | 'format_note': 'DASH video', | |
1250 | 'container': 'mp4_dash', | |
1251 | 'vcodec': 'avc1.4D401F', | |
1252 | 'acodec': 'none', | |
1253 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1254 | 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/', | |
1255 | 'protocol': 'http_dash_segments', | |
1256 | 'video_ext': 'mp4', | |
1257 | 'audio_ext': 'none', | |
1258 | 'vbr': 4482, | |
becdc7f8 F |
1259 | }], |
1260 | { | |
177877c5 | 1261 | 'en': [ |
becdc7f8 | 1262 | { |
177877c5 | 1263 | 'ext': 'mp4', |
1264 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1265 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', | |
1266 | 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/', | |
1267 | 'protocol': 'http_dash_segments', | |
becdc7f8 F |
1268 | } |
1269 | ] | |
1270 | }, | |
41bf647e | 1271 | ) |
48504785 S |
1272 | ] |
1273 | ||
becdc7f8 | 1274 | for mpd_file, mpd_url, mpd_base_url, expected_formats, expected_subtitles in _TEST_CASES: |
48504785 S |
1275 | with io.open('./test/testdata/mpd/%s.mpd' % mpd_file, |
1276 | mode='r', encoding='utf-8') as f: | |
becdc7f8 | 1277 | formats, subtitles = self.ie._parse_mpd_formats_and_subtitles( |
48504785 | 1278 | compat_etree_fromstring(f.read().encode('utf-8')), |
2e27421c | 1279 | mpd_base_url=mpd_base_url, mpd_url=mpd_url) |
48504785 S |
1280 | self.ie._sort_formats(formats) |
1281 | expect_value(self, formats, expected_formats, None) | |
becdc7f8 | 1282 | expect_value(self, subtitles, expected_subtitles, None) |
48504785 | 1283 | |
5fbcebed F |
1284 | def test_parse_ism_formats(self): |
1285 | _TEST_CASES = [ | |
1286 | ( | |
1287 | 'sintel', | |
1288 | 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1289 | [{ | |
177877c5 | 1290 | 'format_id': 'audio-128', |
1291 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1292 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1293 | 'ext': 'isma', | |
1294 | 'tbr': 128, | |
1295 | 'asr': 48000, | |
1296 | 'vcodec': 'none', | |
1297 | 'acodec': 'AACL', | |
1298 | 'protocol': 'ism', | |
1299 | '_download_params': { | |
1300 | 'stream_type': 'audio', | |
1301 | 'duration': 8880746666, | |
1302 | 'timescale': 10000000, | |
1303 | 'width': 0, | |
1304 | 'height': 0, | |
1305 | 'fourcc': 'AACL', | |
1306 | 'codec_private_data': '1190', | |
1307 | 'sampling_rate': 48000, | |
1308 | 'channels': 2, | |
1309 | 'bits_per_sample': 16, | |
1310 | 'nal_unit_length_field': 4 | |
5fbcebed | 1311 | }, |
177877c5 | 1312 | 'audio_ext': 'isma', |
1313 | 'video_ext': 'none', | |
1314 | 'abr': 128, | |
1315 | }, { | |
1316 | 'format_id': 'video-100', | |
1317 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1318 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1319 | 'ext': 'ismv', | |
1320 | 'width': 336, | |
1321 | 'height': 144, | |
1322 | 'tbr': 100, | |
1323 | 'vcodec': 'AVC1', | |
1324 | 'acodec': 'none', | |
1325 | 'protocol': 'ism', | |
1326 | '_download_params': { | |
1327 | 'stream_type': 'video', | |
1328 | 'duration': 8880746666, | |
1329 | 'timescale': 10000000, | |
1330 | 'width': 336, | |
1331 | 'height': 144, | |
1332 | 'fourcc': 'AVC1', | |
1333 | 'codec_private_data': '00000001674D401FDA0544EFFC2D002CBC40000003004000000C03C60CA80000000168EF32C8', | |
1334 | 'channels': 2, | |
1335 | 'bits_per_sample': 16, | |
1336 | 'nal_unit_length_field': 4 | |
5fbcebed | 1337 | }, |
177877c5 | 1338 | 'video_ext': 'ismv', |
1339 | 'audio_ext': 'none', | |
1340 | 'vbr': 100, | |
1341 | }, { | |
1342 | 'format_id': 'video-326', | |
1343 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1344 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1345 | 'ext': 'ismv', | |
1346 | 'width': 562, | |
1347 | 'height': 240, | |
1348 | 'tbr': 326, | |
1349 | 'vcodec': 'AVC1', | |
1350 | 'acodec': 'none', | |
1351 | 'protocol': 'ism', | |
1352 | '_download_params': { | |
1353 | 'stream_type': 'video', | |
1354 | 'duration': 8880746666, | |
1355 | 'timescale': 10000000, | |
1356 | 'width': 562, | |
1357 | 'height': 240, | |
1358 | 'fourcc': 'AVC1', | |
1359 | 'codec_private_data': '00000001674D401FDA0241FE23FFC3BC83BA44000003000400000300C03C60CA800000000168EF32C8', | |
1360 | 'channels': 2, | |
1361 | 'bits_per_sample': 16, | |
1362 | 'nal_unit_length_field': 4 | |
5fbcebed | 1363 | }, |
177877c5 | 1364 | 'video_ext': 'ismv', |
1365 | 'audio_ext': 'none', | |
1366 | 'vbr': 326, | |
1367 | }, { | |
1368 | 'format_id': 'video-698', | |
1369 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1370 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1371 | 'ext': 'ismv', | |
1372 | 'width': 844, | |
1373 | 'height': 360, | |
1374 | 'tbr': 698, | |
1375 | 'vcodec': 'AVC1', | |
1376 | 'acodec': 'none', | |
1377 | 'protocol': 'ism', | |
1378 | '_download_params': { | |
1379 | 'stream_type': 'video', | |
1380 | 'duration': 8880746666, | |
1381 | 'timescale': 10000000, | |
1382 | 'width': 844, | |
1383 | 'height': 360, | |
1384 | 'fourcc': 'AVC1', | |
1385 | 'codec_private_data': '00000001674D401FDA0350BFB97FF06AF06AD1000003000100000300300F1832A00000000168EF32C8', | |
1386 | 'channels': 2, | |
1387 | 'bits_per_sample': 16, | |
1388 | 'nal_unit_length_field': 4 | |
5fbcebed | 1389 | }, |
177877c5 | 1390 | 'video_ext': 'ismv', |
1391 | 'audio_ext': 'none', | |
1392 | 'vbr': 698, | |
1393 | }, { | |
1394 | 'format_id': 'video-1493', | |
1395 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1396 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1397 | 'ext': 'ismv', | |
1398 | 'width': 1126, | |
1399 | 'height': 480, | |
1400 | 'tbr': 1493, | |
1401 | 'vcodec': 'AVC1', | |
1402 | 'acodec': 'none', | |
1403 | 'protocol': 'ism', | |
1404 | '_download_params': { | |
1405 | 'stream_type': 'video', | |
1406 | 'duration': 8880746666, | |
1407 | 'timescale': 10000000, | |
1408 | 'width': 1126, | |
1409 | 'height': 480, | |
1410 | 'fourcc': 'AVC1', | |
1411 | 'codec_private_data': '00000001674D401FDA011C3DE6FFF0D890D871000003000100000300300F1832A00000000168EF32C8', | |
1412 | 'channels': 2, | |
1413 | 'bits_per_sample': 16, | |
1414 | 'nal_unit_length_field': 4 | |
5fbcebed | 1415 | }, |
177877c5 | 1416 | 'video_ext': 'ismv', |
1417 | 'audio_ext': 'none', | |
1418 | 'vbr': 1493, | |
1419 | }, { | |
1420 | 'format_id': 'video-4482', | |
1421 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1422 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1423 | 'ext': 'ismv', | |
1424 | 'width': 1688, | |
1425 | 'height': 720, | |
1426 | 'tbr': 4482, | |
1427 | 'vcodec': 'AVC1', | |
1428 | 'acodec': 'none', | |
1429 | 'protocol': 'ism', | |
1430 | '_download_params': { | |
1431 | 'stream_type': 'video', | |
1432 | 'duration': 8880746666, | |
1433 | 'timescale': 10000000, | |
1434 | 'width': 1688, | |
1435 | 'height': 720, | |
1436 | 'fourcc': 'AVC1', | |
1437 | 'codec_private_data': '00000001674D401FDA01A816F97FFC1ABC1AB440000003004000000C03C60CA80000000168EF32C8', | |
1438 | 'channels': 2, | |
1439 | 'bits_per_sample': 16, | |
1440 | 'nal_unit_length_field': 4 | |
5fbcebed | 1441 | }, |
177877c5 | 1442 | 'video_ext': 'ismv', |
1443 | 'audio_ext': 'none', | |
1444 | 'vbr': 4482, | |
5fbcebed F |
1445 | }], |
1446 | { | |
177877c5 | 1447 | 'eng': [ |
5fbcebed | 1448 | { |
177877c5 | 1449 | 'ext': 'ismt', |
1450 | 'protocol': 'ism', | |
1451 | 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1452 | 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest', | |
1453 | '_download_params': { | |
1454 | 'stream_type': 'text', | |
1455 | 'duration': 8880746666, | |
1456 | 'timescale': 10000000, | |
1457 | 'fourcc': 'TTML', | |
1458 | 'codec_private_data': '' | |
5fbcebed F |
1459 | } |
1460 | } | |
1461 | ] | |
1462 | }, | |
1463 | ), | |
1464 | ] | |
1465 | ||
1466 | for ism_file, ism_url, expected_formats, expected_subtitles in _TEST_CASES: | |
1467 | with io.open('./test/testdata/ism/%s.Manifest' % ism_file, | |
1468 | mode='r', encoding='utf-8') as f: | |
1469 | formats, subtitles = self.ie._parse_ism_formats_and_subtitles( | |
1470 | compat_etree_fromstring(f.read().encode('utf-8')), ism_url=ism_url) | |
1471 | self.ie._sort_formats(formats) | |
1472 | expect_value(self, formats, expected_formats, None) | |
1473 | expect_value(self, subtitles, expected_subtitles, None) | |
1474 | ||
181e381f S |
1475 | def test_parse_f4m_formats(self): |
1476 | _TEST_CASES = [ | |
1477 | ( | |
067aa17e | 1478 | # https://github.com/ytdl-org/youtube-dl/issues/14660 |
181e381f S |
1479 | 'custom_base_url', |
1480 | 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m', | |
1481 | [{ | |
1482 | 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m', | |
1483 | 'ext': 'flv', | |
1484 | 'format_id': '2148', | |
1485 | 'protocol': 'f4m', | |
1486 | 'tbr': 2148, | |
1487 | 'width': 1280, | |
1488 | 'height': 720, | |
1489 | }] | |
1490 | ), | |
1491 | ] | |
1492 | ||
1493 | for f4m_file, f4m_url, expected_formats in _TEST_CASES: | |
1494 | with io.open('./test/testdata/f4m/%s.f4m' % f4m_file, | |
1495 | mode='r', encoding='utf-8') as f: | |
1496 | formats = self.ie._parse_f4m_formats( | |
1497 | compat_etree_fromstring(f.read().encode('utf-8')), | |
1498 | f4m_url, None) | |
1499 | self.ie._sort_formats(formats) | |
1500 | expect_value(self, formats, expected_formats, None) | |
582be358 | 1501 | |
96b8b9ab RC |
1502 | def test_parse_xspf(self): |
1503 | _TEST_CASES = [ | |
1504 | ( | |
1505 | 'foo_xspf', | |
47a5cb77 | 1506 | 'https://example.org/src/foo_xspf.xspf', |
96b8b9ab | 1507 | [{ |
47a5cb77 S |
1508 | 'id': 'foo_xspf', |
1509 | 'title': 'Pandemonium', | |
96b8b9ab RC |
1510 | 'description': 'Visit http://bigbrother404.bandcamp.com', |
1511 | 'duration': 202.416, | |
47a5cb77 S |
1512 | 'formats': [{ |
1513 | 'manifest_url': 'https://example.org/src/foo_xspf.xspf', | |
1514 | 'url': 'https://example.org/src/cd1/track%201.mp3', | |
1515 | }], | |
1516 | }, { | |
96b8b9ab | 1517 | 'id': 'foo_xspf', |
47a5cb77 | 1518 | 'title': 'Final Cartridge (Nichico Twelve Remix)', |
96b8b9ab RC |
1519 | 'description': 'Visit http://bigbrother404.bandcamp.com', |
1520 | 'duration': 255.857, | |
47a5cb77 S |
1521 | 'formats': [{ |
1522 | 'manifest_url': 'https://example.org/src/foo_xspf.xspf', | |
1523 | 'url': 'https://example.org/%E3%83%88%E3%83%A9%E3%83%83%E3%82%AF%E3%80%80%EF%BC%92.mp3', | |
1524 | }], | |
1525 | }, { | |
96b8b9ab | 1526 | 'id': 'foo_xspf', |
47a5cb77 | 1527 | 'title': 'Rebuilding Nightingale', |
96b8b9ab RC |
1528 | 'description': 'Visit http://bigbrother404.bandcamp.com', |
1529 | 'duration': 287.915, | |
47a5cb77 S |
1530 | 'formats': [{ |
1531 | 'manifest_url': 'https://example.org/src/foo_xspf.xspf', | |
1532 | 'url': 'https://example.org/src/track3.mp3', | |
1533 | }, { | |
1534 | 'manifest_url': 'https://example.org/src/foo_xspf.xspf', | |
1535 | 'url': 'https://example.com/track3.mp3', | |
1536 | }] | |
96b8b9ab RC |
1537 | }] |
1538 | ), | |
1539 | ] | |
1540 | ||
47a5cb77 | 1541 | for xspf_file, xspf_url, expected_entries in _TEST_CASES: |
96b8b9ab RC |
1542 | with io.open('./test/testdata/xspf/%s.xspf' % xspf_file, |
1543 | mode='r', encoding='utf-8') as f: | |
1544 | entries = self.ie._parse_xspf( | |
1545 | compat_etree_fromstring(f.read().encode('utf-8')), | |
47a5cb77 | 1546 | xspf_file, xspf_url=xspf_url, xspf_base_url=xspf_url) |
96b8b9ab RC |
1547 | expect_value(self, entries, expected_entries, None) |
1548 | for i in range(len(entries)): | |
1549 | expect_dict(self, entries[i], expected_entries[i]) | |
1550 | ||
95e42d73 XDG |
1551 | def test_response_with_expected_status_returns_content(self): |
1552 | # Checks for mitigations against the effects of | |
1553 | # <https://bugs.python.org/issue15002> that affect Python 3.4.1+, which | |
1554 | # manifest as `_download_webpage`, `_download_xml`, `_download_json`, | |
1555 | # or the underlying `_download_webpage_handle` returning no content | |
1556 | # when a response matches `expected_status`. | |
1557 | ||
1558 | httpd = compat_http_server.HTTPServer( | |
1559 | ('127.0.0.1', 0), InfoExtractorTestRequestHandler) | |
1560 | port = http_server_port(httpd) | |
1561 | server_thread = threading.Thread(target=httpd.serve_forever) | |
1562 | server_thread.daemon = True | |
1563 | server_thread.start() | |
1564 | ||
1565 | (content, urlh) = self.ie._download_webpage_handle( | |
1566 | 'http://127.0.0.1:%d/teapot' % port, None, | |
1567 | expected_status=TEAPOT_RESPONSE_STATUS) | |
1568 | self.assertEqual(content, TEAPOT_RESPONSE_BODY) | |
1569 | ||
f58a5060 | 1570 | |
14719565 JMF |
1571 | if __name__ == '__main__': |
1572 | unittest.main() |