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