3 # Allow direct execution
8 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
14 from test
.helper
import FakeYDL
, expect_dict
, expect_value
, http_server_port
15 from yt_dlp
.compat
import compat_etree_fromstring
16 from yt_dlp
.extractor
import YoutubeIE
, get_info_extractor
17 from yt_dlp
.extractor
.common
import InfoExtractor
18 from yt_dlp
.utils
import (
25 TEAPOT_RESPONSE_STATUS
= 418
26 TEAPOT_RESPONSE_BODY
= "<h1>418 I'm a teapot</h1>"
29 class InfoExtractorTestRequestHandler(http
.server
.BaseHTTPRequestHandler
):
30 def log_message(self
, format
, *args
):
34 if self
.path
== '/teapot':
35 self
.send_response(TEAPOT_RESPONSE_STATUS
)
36 self
.send_header('Content-Type', 'text/html; charset=utf-8')
38 self
.wfile
.write(TEAPOT_RESPONSE_BODY
.encode())
43 class DummyIE(InfoExtractor
):
44 def _sort_formats(self
, formats
, field_preference
=[]):
45 self
._downloader
.sort_formats(
46 {'formats': formats
, '_format_sort_fields': field_preference
})
49 class TestInfoExtractor(unittest
.TestCase
):
51 self
.ie
= DummyIE(FakeYDL())
53 def test_ie_key(self
):
54 self
.assertEqual(get_info_extractor(YoutubeIE
.ie_key()), YoutubeIE
)
56 def test_get_netrc_login_info(self
):
58 {'usenetrc': True, 'netrc_location': './test/testdata/netrc/netrc'},
59 {'netrc_cmd': f
'{sys.executable} ./test/testdata/netrc/print_netrc.py'},
61 ie
= DummyIE(FakeYDL(params
))
62 self
.assertEqual(ie
._get
_netrc
_login
_info
(netrc_machine
='normal_use'), ('user', 'pass'))
63 self
.assertEqual(ie
._get
_netrc
_login
_info
(netrc_machine
='empty_user'), ('', 'pass'))
64 self
.assertEqual(ie
._get
_netrc
_login
_info
(netrc_machine
='empty_pass'), ('user', ''))
65 self
.assertEqual(ie
._get
_netrc
_login
_info
(netrc_machine
='both_empty'), ('', ''))
66 self
.assertEqual(ie
._get
_netrc
_login
_info
(netrc_machine
='nonexistent'), (None, None))
68 def test_html_search_regex(self
):
69 html
= '<p id="foo">Watch this <a href="http://www.youtube.com/watch?v=BaW_jenozKc">video</a></p>'
70 search
= lambda re
, *args
: self
.ie
._html
_search
_regex
(re
, html
, *args
)
71 self
.assertEqual(search(r
'<p id="foo">(.+?)</p>', 'foo'), 'Watch this video')
73 def test_opengraph(self
):
76 <meta name="og:title" content='Foo'/>
77 <meta content="Some video's description " name="og:description"/>
78 <meta property='og:image' content='http://domain.com/pic.jpg?key1=val1&key2=val2'/>
79 <meta content='application/x-shockwave-flash' property='og:video:type'>
80 <meta content='Foo' property=og:foobar>
81 <meta name="og:test1" content='foo > < bar'/>
82 <meta name="og:test2" content="foo >//< bar"/>
83 <meta property=og-test3 content='Ill-formatted opengraph'/>
84 <meta property=og:test4 content=unquoted-value/>
86 self
.assertEqual(ie
._og
_search
_title
(html
), 'Foo')
87 self
.assertEqual(ie
._og
_search
_description
(html
), 'Some video\'s description ')
88 self
.assertEqual(ie
._og
_search
_thumbnail
(html
), 'http://domain.com/pic.jpg?key1=val1&key2=val2')
89 self
.assertEqual(ie
._og
_search
_video
_url
(html
, default
=None), None)
90 self
.assertEqual(ie
._og
_search
_property
('foobar', html
), 'Foo')
91 self
.assertEqual(ie
._og
_search
_property
('test1', html
), 'foo > < bar')
92 self
.assertEqual(ie
._og
_search
_property
('test2', html
), 'foo >//< bar')
93 self
.assertEqual(ie
._og
_search
_property
('test3', html
), 'Ill-formatted opengraph')
94 self
.assertEqual(ie
._og
_search
_property
(('test0', 'test1'), html
), 'foo > < bar')
95 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, 'test0', html
, None, fatal
=True)
96 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, ('test0', 'test00'), html
, None, fatal
=True)
97 self
.assertEqual(ie
._og
_search
_property
('test4', html
), 'unquoted-value')
99 def test_html_search_meta(self
):
102 <meta name="a" content="1" />
103 <meta name='b' content='2'>
104 <meta name="c" content='3'>
105 <meta name=d content='4'>
106 <meta property="e" content='5' >
107 <meta content="6" name="f">
110 self
.assertEqual(ie
._html
_search
_meta
('a', html
), '1')
111 self
.assertEqual(ie
._html
_search
_meta
('b', html
), '2')
112 self
.assertEqual(ie
._html
_search
_meta
('c', html
), '3')
113 self
.assertEqual(ie
._html
_search
_meta
('d', html
), '4')
114 self
.assertEqual(ie
._html
_search
_meta
('e', html
), '5')
115 self
.assertEqual(ie
._html
_search
_meta
('f', html
), '6')
116 self
.assertEqual(ie
._html
_search
_meta
(('a', 'b', 'c'), html
), '1')
117 self
.assertEqual(ie
._html
_search
_meta
(('c', 'b', 'a'), html
), '3')
118 self
.assertEqual(ie
._html
_search
_meta
(('z', 'x', 'c'), html
), '3')
119 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, 'z', html
, None, fatal
=True)
120 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, ('z', 'x'), html
, None, fatal
=True)
122 def test_search_json_ld_realworld(self
):
124 # https://github.com/ytdl-org/youtube-dl/issues/23306
126 r
'''<script type="application/ld+json">
128 "@context": "http://schema.org/",
129 "@type": "VideoObject",
130 "name": "1 On 1 With Kleio",
131 "url": "https://www.eporner.com/hd-porn/xN49A1cT3eB/1-On-1-With-Kleio/",
132 "duration": "PT0H12M23S",
133 "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"],
134 "contentUrl": "https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4",
135 "embedUrl": "https://www.eporner.com/embed/xN49A1cT3eB/1-On-1-With-Kleio/",
136 "image": "https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg",
139 "encodingFormat": "mp4",
140 "bitrate": "6617kbps",
141 "isFamilyFriendly": "False",
142 "description": "Kleio Valentien",
143 "uploadDate": "2015-12-05T21:24:35+01:00",
144 "interactionStatistic": {
145 "@type": "InteractionCounter",
146 "interactionType": { "@type": "http://schema.org/WatchAction" },
147 "userInteractionCount": 1120958
148 }, "aggregateRating": {
149 "@type": "AggregateRating",
151 "ratingCount": "630",
156 "name": "Kleio Valentien",
157 "url": "https://www.eporner.com/pornstar/kleio-valentien/"
161 'title': '1 On 1 With Kleio',
162 'description': 'Kleio Valentien',
163 'url': 'https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4',
164 'timestamp': 1449347075,
166 'view_count': 1120958,
173 r
'''<script type="application/ld+json">
175 "@context": "https://schema.org",
178 "@type": "NewsArticle",
179 "mainEntityOfPage": {
181 "@id": "https://www.ant1news.gr/Society/article/620286/symmoria-anilikon-dikigoros-thymaton-ithelan-na-toys-apoteleiosoyn"
183 "headline": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
184 "name": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
185 "description": "Τα παιδιά δέχθηκαν την επίθεση επειδή αρνήθηκαν να γίνουν μέλη της συμμορίας, ανέφερε ο Γ. Ζαχαρόπουλος.",
187 "@type": "ImageObject",
188 "url": "https://ant1media.azureedge.net/imgHandler/1100/a635c968-be71-447c-bf9c-80d843ece21e.jpg",
191 "datePublished": "2021-11-10T08:50:00+03:00",
192 "dateModified": "2021-11-10T08:52:53+03:00",
195 "@id": "https://www.ant1news.gr/",
197 "image": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
198 "url": "https://www.ant1news.gr/"
201 "@type": "Organization",
202 "@id": "https://www.ant1news.gr#publisher",
204 "url": "https://www.ant1news.gr",
206 "@type": "ImageObject",
207 "url": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
211 "https://www.facebook.com/Ant1news.gr",
212 "https://twitter.com/antennanews",
213 "https://www.youtube.com/channel/UC0smvAbfczoN75dP0Hw4Pzw",
214 "https://www.instagram.com/ant1news/"
218 "keywords": "μαχαίρωμα,συμμορία ανηλίκων,ΕΙΔΗΣΕΙΣ,ΕΙΔΗΣΕΙΣ ΣΗΜΕΡΑ,ΝΕΑ,Κοινωνία - Ant1news",
221 "articleSection": "Κοινωνία"
227 'timestamp': 1636523400,
228 'title': 'md5:91fe569e952e4d146485740ae927662b',
230 {'expected_type': 'NewsArticle'},
233 r
'''<script type="application/ld+json">
234 {"url":"/vrtnu/a-z/het-journaal/2021/het-journaal-het-journaal-19u-20211231/",
235 "name":"Het journaal 19u",
236 "description":"Het journaal 19u van vrijdag 31 december 2021.",
237 "potentialAction":{"url":"https://vrtnu.page.link/pfVy6ihgCAJKgHqe8","@type":"ShareAction"},
238 "mainEntityOfPage":{"@id":"1640092242445","@type":"WebPage"},
240 "startDate":"2021-12-31T19:00:00.000+01:00",
241 "endDate":"2022-01-30T23:55:00.000+01:00",
242 "publishedBy":{"name":"een","@type":"Organization"},
243 "publishedOn":{"url":"https://www.vrt.be/vrtnu/","name":"VRT NU","@type":"BroadcastService"},
244 "@id":"pbs-pub-3a7ec233-da95-4c1e-9b2b-cf5fdfebcbe8",
245 "@type":"BroadcastEvent"
248 "name":"Het journaal - Aflevering 365 (Seizoen 2021)",
249 "description":"Het journaal 19u van vrijdag 31 december 2021. Bekijk aflevering 365 van seizoen 2021 met VRT NU via de site of app.",
250 "thumbnailUrl":"//images.vrt.be/width1280/2021/12/31/80d5ed00-6a64-11ec-b07d-02b7b76bf47f.jpg",
251 "expires":"2022-01-30T23:55:00.000+01:00",
253 {"name":"Explosie Turnhout","startOffset":70,"@type":"Clip"},
254 {"name":"Jaarwisseling","startOffset":440,"@type":"Clip"},
255 {"name":"Natuurbranden Colorado","startOffset":1179,"@type":"Clip"},
256 {"name":"Klimaatverandering","startOffset":1263,"@type":"Clip"},
257 {"name":"Zacht weer","startOffset":1367,"@type":"Clip"},
258 {"name":"Financiële balans","startOffset":1383,"@type":"Clip"},
259 {"name":"Club Brugge","startOffset":1484,"@type":"Clip"},
260 {"name":"Mentale gezondheid bij topsporters","startOffset":1575,"@type":"Clip"},
261 {"name":"Olympische Winterspelen","startOffset":1728,"@type":"Clip"},
262 {"name":"Sober oudjaar in Nederland","startOffset":1873,"@type":"Clip"}
264 "duration":"PT34M39.23S",
265 "uploadDate":"2021-12-31T19:00:00.000+01:00",
266 "@id":"vid-9457d0c6-b8ac-4aba-b5e1-15aa3a3295b5",
267 "@type":"VideoObject"
269 "genre":["Nieuws en actua"],
271 "partOfSeries":{"name":"Het journaal","@id":"222831405527","@type":"TVSeries"},
272 "partOfSeason":{"name":"Seizoen 2021","@id":"961809365527","@type":"TVSeason"},
273 "@context":"https://schema.org","@id":"961685295527","@type":"TVEpisode"}</script>
277 {'title': 'Explosie Turnhout', 'start_time': 70, 'end_time': 440},
278 {'title': 'Jaarwisseling', 'start_time': 440, 'end_time': 1179},
279 {'title': 'Natuurbranden Colorado', 'start_time': 1179, 'end_time': 1263},
280 {'title': 'Klimaatverandering', 'start_time': 1263, 'end_time': 1367},
281 {'title': 'Zacht weer', 'start_time': 1367, 'end_time': 1383},
282 {'title': 'Financiële balans', 'start_time': 1383, 'end_time': 1484},
283 {'title': 'Club Brugge', 'start_time': 1484, 'end_time': 1575},
284 {'title': 'Mentale gezondheid bij topsporters', 'start_time': 1575, 'end_time': 1728},
285 {'title': 'Olympische Winterspelen', 'start_time': 1728, 'end_time': 1873},
286 {'title': 'Sober oudjaar in Nederland', 'start_time': 1873, 'end_time': 2079.23},
288 'title': 'Het journaal - Aflevering 365 (Seizoen 2021)',
292 # test multiple thumbnails in a list
294 <script type="application/ld+json">
295 {"@context":"https://schema.org",
296 "@type":"VideoObject",
297 "thumbnailUrl":["https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"]}
300 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}],
305 # test single thumbnail
307 <script type="application/ld+json">
308 {"@context":"https://schema.org",
309 "@type":"VideoObject",
310 "thumbnailUrl":"https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"}
313 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}],
318 for html
, expected_dict
, search_json_ld_kwargs
in _TESTS
:
321 self
.ie
._search
_json
_ld
(html
, None, **search_json_ld_kwargs
),
325 def test_download_json(self
):
326 uri
= encode_data_uri(b
'{"foo": "blah"}', 'application/json')
327 self
.assertEqual(self
.ie
._download
_json
(uri
, None), {'foo': 'blah'})
328 uri
= encode_data_uri(b
'callback({"foo": "blah"})', 'application/javascript')
329 self
.assertEqual(self
.ie
._download
_json
(uri
, None, transform_source
=strip_jsonp
), {'foo': 'blah'})
330 uri
= encode_data_uri(b
'{"foo": invalid}', 'application/json')
331 self
.assertRaises(ExtractorError
, self
.ie
._download
_json
, uri
, None)
332 self
.assertEqual(self
.ie
._download
_json
(uri
, None, fatal
=False), None)
334 def test_parse_html5_media_entries(self
):
338 self
.ie
._parse
_html
5_media
_entries
(
339 'https://127.0.0.1/video.html',
340 r
'<html><video src="/vid.mp4" /></html>', None)[0],
343 'url': 'https://127.0.0.1/vid.mp4',
347 # from https://www.r18.com/
351 self
.ie
._parse
_html
5_media
_entries
(
352 'https://www.r18.com/',
354 <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">
355 <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">
356 <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">
357 <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">
358 <p>Your browser does not support the video tag.</p>
363 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4',
365 'format_id': '300kbps',
369 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4',
371 'format_id': '1000kbps',
375 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4',
377 'format_id': '1500kbps',
381 'thumbnail': '//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg',
384 # from https://www.csfd.cz/
385 # with width and height
388 self
.ie
._parse
_html
5_media
_entries
(
389 'https://www.csfd.cz/',
391 <video width="770" height="328" preload="none" controls poster="https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360" >
392 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4" type="video/mp4" width="640" height="360">
393 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4" type="video/mp4" width="1280" height="720">
394 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4" type="video/mp4" width="1920" height="1080">
395 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm" type="video/webm" width="640" height="360">
396 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm" type="video/webm" width="1280" height="720">
397 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm" type="video/webm" width="1920" height="1080">
398 <track src="https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt" type="text/x-srt" kind="subtitles" srclang="cs" label="cs">
403 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4',
408 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4',
413 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4',
418 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm',
423 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm',
428 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm',
434 'cs': [{'url': 'https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt'}],
436 'thumbnail': 'https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360',
439 # from https://tamasha.com/v/Kkdjw
440 # with height in label
443 self
.ie
._parse
_html
5_media
_entries
(
444 'https://tamasha.com/v/Kkdjw',
446 <video crossorigin="anonymous">
447 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4" label="AUTO" res="0"/>
448 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4"
449 label="240p" res="240"/>
450 <source src="https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4" type="video/mp4"
451 label="144p" res="144"/>
456 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
458 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
463 'url': 'https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4',
470 # from https://www.directvnow.com
474 self
.ie
._parse
_html
5_media
_entries
(
475 'https://www.directvnow.com',
477 <video id="vid1" class="header--video-masked active" muted playsinline>
478 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
484 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
488 # from https://www.directvnow.com
492 self
.ie
._parse
_html
5_media
_entries
(
493 'https://www.directvnow.com',
495 <video id="vid1" class="header--video-masked active" muted playsinline>
496 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
501 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
506 # from https://www.klarna.com/uk/
507 # with data-video-src
510 self
.ie
._parse
_html
5_media
_entries
(
511 'https://www.directvnow.com',
513 <video loop autoplay muted class="responsive-video block-kl__video video-on-medium">
514 <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" />
519 'url': 'https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4',
524 # from https://0000.studio/
525 # with type attribute but without extension in URL
528 self
.ie
._parse
_html
5_media
_entries
(
529 'https://0000.studio',
531 <video src="https://d1ggyt9m8pwf3g.cloudfront.net/protected/ap-northeast-1:1864af40-28d5-492b-b739-b32314b1a527/archive/clip/838db6a7-8973-4cd6-840d-8517e4093c92"
532 controls="controls" type="video/mp4" preload="metadata" autoplay="autoplay" playsinline class="object-contain">
537 'url': 'https://d1ggyt9m8pwf3g.cloudfront.net/protected/ap-northeast-1:1864af40-28d5-492b-b739-b32314b1a527/archive/clip/838db6a7-8973-4cd6-840d-8517e4093c92',
542 def test_extract_jwplayer_data_realworld(self
):
543 # from http://www.suffolk.edu/sjc/
546 self
.ie
._extract
_jwplayer
_data
(r
'''
547 <script type='text/javascript'>
548 jwplayer('my-video').setup({
549 file: 'rtmp://192.138.214.154/live/sjclive',
557 ''', None, require_title
=False),
561 'url': 'rtmp://192.138.214.154/live/sjclive',
566 # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/
569 self
.ie
._extract
_jwplayer
_data
(r
'''
570 <script type="text/javascript">
571 jwplayer("mediaplayer").setup({
574 'aspectratio': "16:9",
575 'stretching': "exactfit",
576 'autostart': 'false',
577 'flashplayer': "https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf",
578 '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",
579 'image': "https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg",
580 '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",
582 'skin': "https://t04.vipstreamservice.com/jwplayer/skin/modieus-blk.zip",
583 'plugins': "https://t04.vipstreamservice.com/jwplayer/dock/dockableskinnableplugin.swf",
584 'dockableskinnableplugin.piclink': "/index.php?key=ajax-videothumbsn&vid=7564&data=2009-12--14--4b2157147afe5efa93ce1978e0265289c193874e02597.flv--17370",
585 'controlbar': 'bottom',
587 {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'}
591 //noinspection JSAnnotator
593 adsUrl: "/banner-iframe/?zoneId=32",
598 ''', 'dummy', require_title
=False),
600 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg',
602 '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',
607 # from http://www.indiedb.com/games/king-machine/videos
610 self
.ie
._extract
_jwplayer
_data
(r
'''
612 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) {
613 videoAnalytics("play");
614 }).once("complete", function(event) {
615 videoAnalytics("completed");
620 'title': 'king machine trailer 1',
621 'thumbnail': 'http://media.indiedb.com/cache/images/games/1/50/49678/thumb_620x2000/king-machine-trailer.mp4.jpg',
623 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4',
627 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4',
633 def test_parse_m3u8_formats(self
):
636 # https://github.com/ytdl-org/youtube-dl/issues/11995
637 # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor
638 'img_bipbop_adv_example_fmp4',
639 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
641 'format_id': 'aud1-English',
642 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a1/prog_index.m3u8',
643 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
646 'protocol': 'm3u8_native',
649 'format_id': 'aud2-English',
650 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a2/prog_index.m3u8',
651 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
654 'protocol': 'm3u8_native',
657 'format_id': 'aud3-English',
658 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a3/prog_index.m3u8',
659 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
662 'protocol': 'm3u8_native',
666 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
667 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
669 'protocol': 'm3u8_native',
672 'vcodec': 'avc1.640015',
675 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
676 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
678 'protocol': 'm3u8_native',
681 'vcodec': 'avc1.640015',
684 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
685 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
687 'protocol': 'm3u8_native',
690 'vcodec': 'avc1.640015',
693 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
694 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
696 'protocol': 'm3u8_native',
699 'vcodec': 'avc1.64001e',
702 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
703 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
705 'protocol': 'm3u8_native',
708 'vcodec': 'avc1.64001e',
711 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
712 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
714 'protocol': 'm3u8_native',
717 'vcodec': 'avc1.64001e',
720 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
721 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
723 'protocol': 'm3u8_native',
726 'vcodec': 'avc1.64001e',
729 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
730 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
732 'protocol': 'm3u8_native',
735 'vcodec': 'avc1.64001e',
738 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
739 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
741 'protocol': 'm3u8_native',
744 'vcodec': 'avc1.64001e',
747 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
748 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
750 'protocol': 'm3u8_native',
753 'vcodec': 'avc1.640020',
756 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
757 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
759 'protocol': 'm3u8_native',
762 'vcodec': 'avc1.640020',
765 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
766 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
768 'protocol': 'm3u8_native',
771 'vcodec': 'avc1.640020',
774 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
775 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
777 'protocol': 'm3u8_native',
780 'vcodec': 'avc1.640020',
783 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
784 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
786 'protocol': 'm3u8_native',
789 'vcodec': 'avc1.640020',
792 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
793 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
795 'protocol': 'm3u8_native',
798 'vcodec': 'avc1.640020',
801 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
802 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
804 'protocol': 'm3u8_native',
807 'vcodec': 'avc1.64002a',
810 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
811 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
813 'protocol': 'm3u8_native',
816 'vcodec': 'avc1.64002a',
819 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
820 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
822 'protocol': 'm3u8_native',
825 'vcodec': 'avc1.64002a',
828 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
829 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
831 'protocol': 'm3u8_native',
834 'vcodec': 'avc1.64002a',
837 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
838 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
840 'protocol': 'm3u8_native',
843 'vcodec': 'avc1.64002a',
846 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
847 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
849 'protocol': 'm3u8_native',
852 'vcodec': 'avc1.64002a',
855 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
856 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
858 'protocol': 'm3u8_native',
861 'vcodec': 'avc1.64002a',
864 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
865 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
867 'protocol': 'm3u8_native',
870 'vcodec': 'avc1.64002a',
873 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
874 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
876 'protocol': 'm3u8_native',
879 'vcodec': 'avc1.64002a',
885 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
887 'format_id': 'bipbop_audio-BipBop Audio 2',
888 'format_index': None,
889 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/alternate_audio_aac/prog_index.m3u8',
890 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
893 'protocol': 'm3u8_native',
901 'format_index': None,
902 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8',
903 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
907 'protocol': 'm3u8_native',
911 'acodec': 'mp4a.40.2',
917 'format_index': None,
918 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8',
919 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
923 'protocol': 'm3u8_native',
928 'vcodec': 'avc1.4d400d',
929 'acodec': 'mp4a.40.2',
934 'format_index': None,
935 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8',
936 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
940 'protocol': 'm3u8_native',
945 'vcodec': 'avc1.4d401e',
946 'acodec': 'mp4a.40.2',
951 'format_index': None,
952 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8',
953 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
957 'protocol': 'm3u8_native',
962 'vcodec': 'avc1.4d401f',
963 'acodec': 'mp4a.40.2',
968 'format_index': None,
969 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8',
970 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
974 'protocol': 'm3u8_native',
979 'vcodec': 'avc1.4d401f',
980 'acodec': 'mp4a.40.2',
985 'format_index': None,
986 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8',
987 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
991 'protocol': 'm3u8_native',
996 'vcodec': 'avc1.4d401f',
997 'acodec': 'mp4a.40.2',
1003 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng/prog_index.m3u8',
1005 'protocol': 'm3u8_native',
1007 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng_forced/prog_index.m3u8',
1009 'protocol': 'm3u8_native',
1012 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra/prog_index.m3u8',
1014 'protocol': 'm3u8_native',
1016 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra_forced/prog_index.m3u8',
1018 'protocol': 'm3u8_native',
1021 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa/prog_index.m3u8',
1023 'protocol': 'm3u8_native',
1025 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa_forced/prog_index.m3u8',
1027 'protocol': 'm3u8_native',
1030 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn/prog_index.m3u8',
1032 'protocol': 'm3u8_native',
1034 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn_forced/prog_index.m3u8',
1036 'protocol': 'm3u8_native',
1042 for m3u8_file
, m3u8_url
, expected_formats
, expected_subs
in _TEST_CASES
:
1043 with
open(f
'./test/testdata/m3u8/{m3u8_file}.m3u8', encoding
='utf-8') as f
:
1044 formats
, subs
= self
.ie
._parse
_m
3u8_formats
_and
_subtitles
(
1045 f
.read(), m3u8_url
, ext
='mp4')
1046 self
.ie
._sort
_formats
(formats
)
1047 expect_value(self
, formats
, expected_formats
, None)
1048 expect_value(self
, subs
, expected_subs
, None)
1050 def test_parse_mpd_formats(self
):
1053 # https://github.com/ytdl-org/youtube-dl/issues/13919
1054 # Also tests duplicate representation ids, see
1055 # https://github.com/ytdl-org/youtube-dl/issues/15111
1057 'http://unknown/manifest.mpd', # mpd_url
1058 None, # mpd_base_url
1060 'manifest_url': 'http://unknown/manifest.mpd',
1062 'format_id': '318597',
1063 'format_note': 'DASH audio',
1064 'protocol': 'http_dash_segments',
1065 'acodec': 'mp4a.40.2',
1069 'manifest_url': 'http://unknown/manifest.mpd',
1071 'format_id': '318597',
1072 'format_note': 'DASH video',
1073 'protocol': 'http_dash_segments',
1075 'vcodec': 'avc1.42001f',
1080 'manifest_url': 'http://unknown/manifest.mpd',
1082 'format_id': '638590',
1083 'format_note': 'DASH video',
1084 'protocol': 'http_dash_segments',
1086 'vcodec': 'avc1.42001f',
1091 'manifest_url': 'http://unknown/manifest.mpd',
1093 'format_id': '1022565',
1094 'format_note': 'DASH video',
1095 'protocol': 'http_dash_segments',
1097 'vcodec': 'avc1.4d001f',
1102 'manifest_url': 'http://unknown/manifest.mpd',
1104 'format_id': '2046506',
1105 'format_note': 'DASH video',
1106 'protocol': 'http_dash_segments',
1108 'vcodec': 'avc1.4d001f',
1113 'manifest_url': 'http://unknown/manifest.mpd',
1115 'format_id': '3998017',
1116 'format_note': 'DASH video',
1117 'protocol': 'http_dash_segments',
1119 'vcodec': 'avc1.640029',
1124 'manifest_url': 'http://unknown/manifest.mpd',
1126 'format_id': '5997485',
1127 'format_note': 'DASH video',
1128 'protocol': 'http_dash_segments',
1130 'vcodec': 'avc1.640032',
1137 # https://github.com/ytdl-org/youtube-dl/pull/14844
1139 'http://unknown/manifest.mpd', # mpd_url
1140 None, # mpd_base_url
1142 'manifest_url': 'http://unknown/manifest.mpd',
1144 'format_id': 'h264_aac_144p_m4s',
1145 'format_note': 'DASH video',
1146 'protocol': 'http_dash_segments',
1147 'acodec': 'mp4a.40.2',
1148 'vcodec': 'avc3.42c01e',
1153 'manifest_url': 'http://unknown/manifest.mpd',
1155 'format_id': 'h264_aac_240p_m4s',
1156 'format_note': 'DASH video',
1157 'protocol': 'http_dash_segments',
1158 'acodec': 'mp4a.40.2',
1159 'vcodec': 'avc3.42c01e',
1164 'manifest_url': 'http://unknown/manifest.mpd',
1166 'format_id': 'h264_aac_360p_m4s',
1167 'format_note': 'DASH video',
1168 'protocol': 'http_dash_segments',
1169 'acodec': 'mp4a.40.2',
1170 'vcodec': 'avc3.42c01e',
1175 'manifest_url': 'http://unknown/manifest.mpd',
1177 'format_id': 'h264_aac_480p_m4s',
1178 'format_note': 'DASH video',
1179 'protocol': 'http_dash_segments',
1180 'acodec': 'mp4a.40.2',
1181 'vcodec': 'avc3.42c01e',
1186 'manifest_url': 'http://unknown/manifest.mpd',
1188 'format_id': 'h264_aac_576p_m4s',
1189 'format_note': 'DASH video',
1190 'protocol': 'http_dash_segments',
1191 'acodec': 'mp4a.40.2',
1192 'vcodec': 'avc3.42c01e',
1197 'manifest_url': 'http://unknown/manifest.mpd',
1199 'format_id': 'h264_aac_720p_m4s',
1200 'format_note': 'DASH video',
1201 'protocol': 'http_dash_segments',
1202 'acodec': 'mp4a.40.2',
1203 'vcodec': 'avc3.42c01e',
1208 'manifest_url': 'http://unknown/manifest.mpd',
1210 'format_id': 'h264_aac_1080p_m4s',
1211 'format_note': 'DASH video',
1212 'protocol': 'http_dash_segments',
1213 'acodec': 'mp4a.40.2',
1214 'vcodec': 'avc3.42c01e',
1221 # https://github.com/ytdl-org/youtube-dl/issues/20346
1222 # Media considered unfragmented even though it contains
1223 # Initialization tag
1225 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', # mpd_url
1226 'https://v.redd.it/hw1x7rcg7zl21', # mpd_base_url
1228 'url': 'https://v.redd.it/hw1x7rcg7zl21/audio',
1229 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1231 'format_id': 'AUDIO-1',
1232 'format_note': 'DASH audio',
1233 'container': 'm4a_dash',
1234 'acodec': 'mp4a.40.2',
1240 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240',
1241 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1243 'format_id': 'VIDEO-2',
1244 'format_note': 'DASH video',
1245 'container': 'mp4_dash',
1247 'vcodec': 'avc1.4d401e',
1253 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_360',
1254 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1256 'format_id': 'VIDEO-1',
1257 'format_note': 'DASH video',
1258 'container': 'mp4_dash',
1260 'vcodec': 'avc1.4d401e',
1269 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1270 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/',
1272 'format_id': 'audio=128001',
1273 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1277 'format_note': 'DASH audio',
1278 'container': 'm4a_dash',
1280 'acodec': 'mp4a.40.2',
1281 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1282 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1283 'protocol': 'http_dash_segments',
1285 'video_ext': 'none',
1288 'format_id': 'video=100000',
1289 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1294 'format_note': 'DASH video',
1295 'container': 'mp4_dash',
1296 'vcodec': 'avc1.4D401F',
1298 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1299 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1300 'protocol': 'http_dash_segments',
1302 'audio_ext': 'none',
1305 'format_id': 'video=326000',
1306 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1311 'format_note': 'DASH video',
1312 'container': 'mp4_dash',
1313 'vcodec': 'avc1.4D401F',
1315 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1316 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1317 'protocol': 'http_dash_segments',
1319 'audio_ext': 'none',
1322 'format_id': 'video=698000',
1323 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1328 'format_note': 'DASH video',
1329 'container': 'mp4_dash',
1330 'vcodec': 'avc1.4D401F',
1332 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1333 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1334 'protocol': 'http_dash_segments',
1336 'audio_ext': 'none',
1339 'format_id': 'video=1493000',
1340 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1345 'format_note': 'DASH video',
1346 'container': 'mp4_dash',
1347 'vcodec': 'avc1.4D401F',
1349 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1350 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1351 'protocol': 'http_dash_segments',
1353 'audio_ext': 'none',
1356 'format_id': 'video=4482000',
1357 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1362 'format_note': 'DASH video',
1363 'container': 'mp4_dash',
1364 'vcodec': 'avc1.4D401F',
1366 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1367 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1368 'protocol': 'http_dash_segments',
1370 'audio_ext': 'none',
1377 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1378 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1379 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1380 'protocol': 'http_dash_segments',
1387 for mpd_file
, mpd_url
, mpd_base_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1388 with
open(f
'./test/testdata/mpd/{mpd_file}.mpd', encoding
='utf-8') as f
:
1389 formats
, subtitles
= self
.ie
._parse
_mpd
_formats
_and
_subtitles
(
1390 compat_etree_fromstring(f
.read().encode()),
1391 mpd_base_url
=mpd_base_url
, mpd_url
=mpd_url
)
1392 self
.ie
._sort
_formats
(formats
)
1393 expect_value(self
, formats
, expected_formats
, None)
1394 expect_value(self
, subtitles
, expected_subtitles
, None)
1396 def test_parse_ism_formats(self
):
1400 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1402 'format_id': 'audio-128',
1403 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1404 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1411 'audio_channels': 2,
1412 '_download_params': {
1413 'stream_type': 'audio',
1414 'duration': 8880746666,
1415 'timescale': 10000000,
1419 'codec_private_data': '1190',
1420 'sampling_rate': 48000,
1422 'bits_per_sample': 16,
1423 'nal_unit_length_field': 4,
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',
1436 '_download_params': {
1437 'stream_type': 'video',
1438 'duration': 8880746666,
1439 'timescale': 10000000,
1443 'codec_private_data': '00000001674D401FDA0544EFFC2D002CBC40000003004000000C03C60CA80000000168EF32C8',
1445 'bits_per_sample': 16,
1446 'nal_unit_length_field': 4,
1449 'format_id': 'video-326',
1450 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1451 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1459 '_download_params': {
1460 'stream_type': 'video',
1461 'duration': 8880746666,
1462 'timescale': 10000000,
1466 'codec_private_data': '00000001674D401FDA0241FE23FFC3BC83BA44000003000400000300C03C60CA800000000168EF32C8',
1468 'bits_per_sample': 16,
1469 'nal_unit_length_field': 4,
1472 'format_id': 'video-698',
1473 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1474 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1482 '_download_params': {
1483 'stream_type': 'video',
1484 'duration': 8880746666,
1485 'timescale': 10000000,
1489 'codec_private_data': '00000001674D401FDA0350BFB97FF06AF06AD1000003000100000300300F1832A00000000168EF32C8',
1491 'bits_per_sample': 16,
1492 'nal_unit_length_field': 4,
1495 'format_id': 'video-1493',
1496 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1497 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1505 '_download_params': {
1506 'stream_type': 'video',
1507 'duration': 8880746666,
1508 'timescale': 10000000,
1512 'codec_private_data': '00000001674D401FDA011C3DE6FFF0D890D871000003000100000300300F1832A00000000168EF32C8',
1514 'bits_per_sample': 16,
1515 'nal_unit_length_field': 4,
1518 'format_id': 'video-4482',
1519 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1520 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1528 '_download_params': {
1529 'stream_type': 'video',
1530 'duration': 8880746666,
1531 'timescale': 10000000,
1535 'codec_private_data': '00000001674D401FDA01A816F97FFC1ABC1AB440000003004000000C03C60CA80000000168EF32C8',
1537 'bits_per_sample': 16,
1538 'nal_unit_length_field': 4,
1546 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1547 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1548 '_download_params': {
1549 'stream_type': 'text',
1550 'duration': 8880746666,
1551 'timescale': 10000000,
1553 'codec_private_data': '',
1561 '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',
1563 'format_id': 'audio_deu-127',
1564 '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',
1565 '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',
1573 'audio_channels': 2,
1574 '_download_params': {
1575 'stream_type': 'audio',
1576 'duration': 370000000,
1577 'timescale': 10000000,
1582 'codec_private_data': '1190',
1583 'sampling_rate': 48000,
1585 'bits_per_sample': 16,
1586 'nal_unit_length_field': 4,
1589 'format_id': 'audio_deu_1-224',
1590 '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',
1591 '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',
1599 'audio_channels': 6,
1600 '_download_params': {
1601 'stream_type': 'audio',
1602 'duration': 370000000,
1603 'timescale': 10000000,
1608 'codec_private_data': '00063F000000AF87FBA7022DFB42A4D405CD93843BDD0700200F00',
1609 'sampling_rate': 48000,
1611 'bits_per_sample': 16,
1612 'nal_unit_length_field': 4,
1615 'format_id': 'video_deu-23',
1616 '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',
1617 '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',
1626 '_download_params': {
1627 'stream_type': 'video',
1628 'duration': 370000000,
1629 'timescale': 10000000,
1634 'codec_private_data': '000000016742C00CDB06077E5C05A808080A00000300020000030009C0C02EE0177CC6300F142AE00000000168CA8DC8',
1636 'bits_per_sample': 16,
1637 'nal_unit_length_field': 4,
1640 'format_id': 'video_deu-403',
1641 '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',
1642 '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',
1651 '_download_params': {
1652 'stream_type': 'video',
1653 'duration': 370000000,
1654 'timescale': 10000000,
1659 'codec_private_data': '00000001674D4014E98323B602D4040405000003000100000300320F1429380000000168EAECF2',
1661 'bits_per_sample': 16,
1662 'nal_unit_length_field': 4,
1665 'format_id': 'video_deu-680',
1666 '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',
1667 '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',
1676 '_download_params': {
1677 'stream_type': 'video',
1678 'duration': 370000000,
1679 'timescale': 10000000,
1684 'codec_private_data': '00000001674D401EE981405FF2E02D4040405000000300100000030320F162D3800000000168EAECF2',
1686 'bits_per_sample': 16,
1687 'nal_unit_length_field': 4,
1690 'format_id': 'video_deu-1253',
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',
1702 '_download_params': {
1703 'stream_type': 'video',
1704 'duration': 370000000,
1705 'timescale': 10000000,
1710 'codec_private_data': '00000001674D401EE981405FF2E02D4040405000000300100000030320F162D3800000000168EAECF2',
1712 'bits_per_sample': 16,
1713 'nal_unit_length_field': 4,
1716 'format_id': 'video_deu-2121',
1717 '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',
1718 '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',
1727 '_download_params': {
1728 'stream_type': 'video',
1729 'duration': 370000000,
1730 'timescale': 10000000,
1735 'codec_private_data': '00000001674D401EECA0601BD80B50101014000003000400000300C83C58B6580000000168E93B3C80',
1737 'bits_per_sample': 16,
1738 'nal_unit_length_field': 4,
1741 'format_id': 'video_deu-3275',
1742 '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',
1743 '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',
1752 '_download_params': {
1753 'stream_type': 'video',
1754 'duration': 370000000,
1755 'timescale': 10000000,
1760 'codec_private_data': '00000001674D4020ECA02802DD80B501010140000003004000000C83C60C65800000000168E93B3C80',
1762 'bits_per_sample': 16,
1763 'nal_unit_length_field': 4,
1766 'format_id': 'video_deu-5300',
1767 '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',
1768 '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 '_download_params': {
1778 'stream_type': 'video',
1779 'duration': 370000000,
1780 'timescale': 10000000,
1785 'codec_private_data': '00000001674D4028ECA03C0113F2E02D4040405000000300100000030320F18319600000000168E93B3C80',
1787 'bits_per_sample': 16,
1788 'nal_unit_length_field': 4,
1791 'format_id': 'video_deu-8079',
1792 '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',
1793 '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',
1802 '_download_params': {
1803 'stream_type': 'video',
1804 'duration': 370000000,
1805 'timescale': 10000000,
1810 'codec_private_data': '00000001674D4028ECA03C0113F2E02D4040405000000300100000030320F18319600000000168E93B3C80',
1812 'bits_per_sample': 16,
1813 'nal_unit_length_field': 4,
1820 for ism_file
, ism_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1821 with
open(f
'./test/testdata/ism/{ism_file}.Manifest', encoding
='utf-8') as f
:
1822 formats
, subtitles
= self
.ie
._parse
_ism
_formats
_and
_subtitles
(
1823 compat_etree_fromstring(f
.read().encode()), ism_url
=ism_url
)
1824 self
.ie
._sort
_formats
(formats
)
1825 expect_value(self
, formats
, expected_formats
, None)
1826 expect_value(self
, subtitles
, expected_subtitles
, None)
1828 def test_parse_f4m_formats(self
):
1831 # https://github.com/ytdl-org/youtube-dl/issues/14660
1833 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1835 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1837 'format_id': '2148',
1846 for f4m_file
, f4m_url
, expected_formats
in _TEST_CASES
:
1847 with
open(f
'./test/testdata/f4m/{f4m_file}.f4m', encoding
='utf-8') as f
:
1848 formats
= self
.ie
._parse
_f
4m
_formats
(
1849 compat_etree_fromstring(f
.read().encode()),
1851 self
.ie
._sort
_formats
(formats
)
1852 expect_value(self
, formats
, expected_formats
, None)
1854 def test_parse_xspf(self
):
1858 'https://example.org/src/foo_xspf.xspf',
1861 'title': 'Pandemonium',
1862 'description': 'Visit http://bigbrother404.bandcamp.com',
1863 'duration': 202.416,
1865 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1866 'url': 'https://example.org/src/cd1/track%201.mp3',
1870 'title': 'Final Cartridge (Nichico Twelve Remix)',
1871 'description': 'Visit http://bigbrother404.bandcamp.com',
1872 'duration': 255.857,
1874 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1875 'url': 'https://example.org/%E3%83%88%E3%83%A9%E3%83%83%E3%82%AF%E3%80%80%EF%BC%92.mp3',
1879 'title': 'Rebuilding Nightingale',
1880 'description': 'Visit http://bigbrother404.bandcamp.com',
1881 'duration': 287.915,
1883 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1884 'url': 'https://example.org/src/track3.mp3',
1886 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1887 'url': 'https://example.com/track3.mp3',
1893 for xspf_file
, xspf_url
, expected_entries
in _TEST_CASES
:
1894 with
open(f
'./test/testdata/xspf/{xspf_file}.xspf', encoding
='utf-8') as f
:
1895 entries
= self
.ie
._parse
_xspf
(
1896 compat_etree_fromstring(f
.read().encode()),
1897 xspf_file
, xspf_url
=xspf_url
, xspf_base_url
=xspf_url
)
1898 expect_value(self
, entries
, expected_entries
, None)
1899 for i
in range(len(entries
)):
1900 expect_dict(self
, entries
[i
], expected_entries
[i
])
1902 def test_response_with_expected_status_returns_content(self
):
1903 # Checks for mitigations against the effects of
1904 # <https://bugs.python.org/issue15002> that affect Python 3.4.1+, which
1905 # manifest as `_download_webpage`, `_download_xml`, `_download_json`,
1906 # or the underlying `_download_webpage_handle` returning no content
1907 # when a response matches `expected_status`.
1909 httpd
= http
.server
.HTTPServer(
1910 ('127.0.0.1', 0), InfoExtractorTestRequestHandler
)
1911 port
= http_server_port(httpd
)
1912 server_thread
= threading
.Thread(target
=httpd
.serve_forever
)
1913 server_thread
.daemon
= True
1914 server_thread
.start()
1916 (content
, urlh
) = self
.ie
._download
_webpage
_handle
(
1917 f
'http://127.0.0.1:{port}/teapot', None,
1918 expected_status
=TEAPOT_RESPONSE_STATUS
)
1919 self
.assertEqual(content
, TEAPOT_RESPONSE_BODY
)
1921 def test_search_nextjs_data(self
):
1922 data
= '<script id="__NEXT_DATA__" type="application/json">{"props":{}}</script>'
1923 self
.assertEqual(self
.ie
._search
_nextjs
_data
(data
, None), {'props': {}})
1924 self
.assertEqual(self
.ie
._search
_nextjs
_data
('', None, fatal
=False), {})
1925 self
.assertEqual(self
.ie
._search
_nextjs
_data
('', None, default
=None), None)
1926 self
.assertEqual(self
.ie
._search
_nextjs
_data
('', None, default
={}), {})
1927 with self
.assertWarns(DeprecationWarning):
1928 self
.assertEqual(self
.ie
._search
_nextjs
_data
('', None, default
='{}'), {})
1931 if __name__
== '__main__':