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