3 from __future__
import unicode_literals
5 # Allow direct execution
10 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
12 from test
.helper
import FakeYDL
, expect_dict
, expect_value
, http_server_port
13 from yt_dlp
.compat
import compat_etree_fromstring
, compat_http_server
14 from yt_dlp
.extractor
.common
import InfoExtractor
15 from yt_dlp
.extractor
import YoutubeIE
, get_info_extractor
16 from yt_dlp
.utils
import encode_data_uri
, strip_jsonp
, ExtractorError
, RegexNotFoundError
20 TEAPOT_RESPONSE_STATUS
= 418
21 TEAPOT_RESPONSE_BODY
= "<h1>418 I'm a teapot</h1>"
24 class InfoExtractorTestRequestHandler(compat_http_server
.BaseHTTPRequestHandler
):
25 def log_message(self
, format
, *args
):
29 if self
.path
== '/teapot':
30 self
.send_response(TEAPOT_RESPONSE_STATUS
)
31 self
.send_header('Content-Type', 'text/html; charset=utf-8')
33 self
.wfile
.write(TEAPOT_RESPONSE_BODY
.encode())
38 class DummyIE(InfoExtractor
):
42 class TestInfoExtractor(unittest
.TestCase
):
44 self
.ie
= DummyIE(FakeYDL())
46 def test_ie_key(self
):
47 self
.assertEqual(get_info_extractor(YoutubeIE
.ie_key()), YoutubeIE
)
49 def test_html_search_regex(self
):
50 html
= '<p id="foo">Watch this <a href="http://www.youtube.com/watch?v=BaW_jenozKc">video</a></p>'
51 search
= lambda re
, *args
: self
.ie
._html
_search
_regex
(re
, html
, *args
)
52 self
.assertEqual(search(r
'<p id="foo">(.+?)</p>', 'foo'), 'Watch this video')
54 def test_opengraph(self
):
57 <meta name="og:title" content='Foo'/>
58 <meta content="Some video's description " name="og:description"/>
59 <meta property='og:image' content='http://domain.com/pic.jpg?key1=val1&key2=val2'/>
60 <meta content='application/x-shockwave-flash' property='og:video:type'>
61 <meta content='Foo' property=og:foobar>
62 <meta name="og:test1" content='foo > < bar'/>
63 <meta name="og:test2" content="foo >//< bar"/>
64 <meta property=og-test3 content='Ill-formatted opengraph'/>
66 self
.assertEqual(ie
._og
_search
_title
(html
), 'Foo')
67 self
.assertEqual(ie
._og
_search
_description
(html
), 'Some video\'s description ')
68 self
.assertEqual(ie
._og
_search
_thumbnail
(html
), 'http://domain.com/pic.jpg?key1=val1&key2=val2')
69 self
.assertEqual(ie
._og
_search
_video
_url
(html
, default
=None), None)
70 self
.assertEqual(ie
._og
_search
_property
('foobar', html
), 'Foo')
71 self
.assertEqual(ie
._og
_search
_property
('test1', html
), 'foo > < bar')
72 self
.assertEqual(ie
._og
_search
_property
('test2', html
), 'foo >//< bar')
73 self
.assertEqual(ie
._og
_search
_property
('test3', html
), 'Ill-formatted opengraph')
74 self
.assertEqual(ie
._og
_search
_property
(('test0', 'test1'), html
), 'foo > < bar')
75 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, 'test0', html
, None, fatal
=True)
76 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, ('test0', 'test00'), html
, None, fatal
=True)
78 def test_html_search_meta(self
):
81 <meta name="a" content="1" />
82 <meta name='b' content='2'>
83 <meta name="c" content='3'>
84 <meta name=d content='4'>
85 <meta property="e" content='5' >
86 <meta content="6" name="f">
89 self
.assertEqual(ie
._html
_search
_meta
('a', html
), '1')
90 self
.assertEqual(ie
._html
_search
_meta
('b', html
), '2')
91 self
.assertEqual(ie
._html
_search
_meta
('c', html
), '3')
92 self
.assertEqual(ie
._html
_search
_meta
('d', html
), '4')
93 self
.assertEqual(ie
._html
_search
_meta
('e', html
), '5')
94 self
.assertEqual(ie
._html
_search
_meta
('f', html
), '6')
95 self
.assertEqual(ie
._html
_search
_meta
(('a', 'b', 'c'), html
), '1')
96 self
.assertEqual(ie
._html
_search
_meta
(('c', 'b', 'a'), html
), '3')
97 self
.assertEqual(ie
._html
_search
_meta
(('z', 'x', 'c'), html
), '3')
98 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, 'z', html
, None, fatal
=True)
99 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, ('z', 'x'), html
, None, fatal
=True)
101 def test_search_json_ld_realworld(self
):
103 # https://github.com/ytdl-org/youtube-dl/issues/23306
105 r
'''<script type="application/ld+json">
107 "@context": "http://schema.org/",
108 "@type": "VideoObject",
109 "name": "1 On 1 With Kleio",
110 "url": "https://www.eporner.com/hd-porn/xN49A1cT3eB/1-On-1-With-Kleio/",
111 "duration": "PT0H12M23S",
112 "thumbnailUrl": ["https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg", "https://imggen.eporner.com/780814/1920/1080/9.jpg"],
113 "contentUrl": "https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4",
114 "embedUrl": "https://www.eporner.com/embed/xN49A1cT3eB/1-On-1-With-Kleio/",
115 "image": "https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg",
118 "encodingFormat": "mp4",
119 "bitrate": "6617kbps",
120 "isFamilyFriendly": "False",
121 "description": "Kleio Valentien",
122 "uploadDate": "2015-12-05T21:24:35+01:00",
123 "interactionStatistic": {
124 "@type": "InteractionCounter",
125 "interactionType": { "@type": "http://schema.org/WatchAction" },
126 "userInteractionCount": 1120958
127 }, "aggregateRating": {
128 "@type": "AggregateRating",
130 "ratingCount": "630",
135 "name": "Kleio Valentien",
136 "url": "https://www.eporner.com/pornstar/kleio-valentien/"
140 'title': '1 On 1 With Kleio',
141 'description': 'Kleio Valentien',
142 'url': 'https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4',
143 'timestamp': 1449347075,
145 'view_count': 1120958,
152 r
'''<script type="application/ld+json">
154 "@context": "https://schema.org",
157 "@type": "NewsArticle",
158 "mainEntityOfPage": {
160 "@id": "https://www.ant1news.gr/Society/article/620286/symmoria-anilikon-dikigoros-thymaton-ithelan-na-toys-apoteleiosoyn"
162 "headline": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
163 "name": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
164 "description": "Τα παιδιά δέχθηκαν την επίθεση επειδή αρνήθηκαν να γίνουν μέλη της συμμορίας, ανέφερε ο Γ. Ζαχαρόπουλος.",
166 "@type": "ImageObject",
167 "url": "https://ant1media.azureedge.net/imgHandler/1100/a635c968-be71-447c-bf9c-80d843ece21e.jpg",
170 "datePublished": "2021-11-10T08:50:00+03:00",
171 "dateModified": "2021-11-10T08:52:53+03:00",
174 "@id": "https://www.ant1news.gr/",
176 "image": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
177 "url": "https://www.ant1news.gr/"
180 "@type": "Organization",
181 "@id": "https://www.ant1news.gr#publisher",
183 "url": "https://www.ant1news.gr",
185 "@type": "ImageObject",
186 "url": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
190 "https://www.facebook.com/Ant1news.gr",
191 "https://twitter.com/antennanews",
192 "https://www.youtube.com/channel/UC0smvAbfczoN75dP0Hw4Pzw",
193 "https://www.instagram.com/ant1news/"
197 "keywords": "μαχαίρωμα,συμμορία ανηλίκων,ΕΙΔΗΣΕΙΣ,ΕΙΔΗΣΕΙΣ ΣΗΜΕΡΑ,ΝΕΑ,Κοινωνία - Ant1news",
200 "articleSection": "Κοινωνία"
206 'timestamp': 1636523400,
207 'title': 'md5:91fe569e952e4d146485740ae927662b',
209 {'expected_type': 'NewsArticle'}
,
212 for html
, expected_dict
, search_json_ld_kwargs
in _TESTS
:
215 self
.ie
._search
_json
_ld
(html
, None, **search_json_ld_kwargs
),
219 def test_download_json(self
):
220 uri
= encode_data_uri(b
'{"foo": "blah"}', 'application/json')
221 self
.assertEqual(self
.ie
._download
_json
(uri
, None), {'foo': 'blah'}
)
222 uri
= encode_data_uri(b
'callback({"foo": "blah"})', 'application/javascript')
223 self
.assertEqual(self
.ie
._download
_json
(uri
, None, transform_source
=strip_jsonp
), {'foo': 'blah'}
)
224 uri
= encode_data_uri(b
'{"foo": invalid}', 'application/json')
225 self
.assertRaises(ExtractorError
, self
.ie
._download
_json
, uri
, None)
226 self
.assertEqual(self
.ie
._download
_json
(uri
, None, fatal
=False), None)
228 def test_parse_html5_media_entries(self
):
232 self
.ie
._parse
_html
5_media
_entries
(
233 'https://127.0.0.1/video.html',
234 r
'<html><video src="/vid.mp4" /></html>', None)[0],
237 'url': 'https://127.0.0.1/vid.mp4',
241 # from https://www.r18.com/
245 self
.ie
._parse
_html
5_media
_entries
(
246 'https://www.r18.com/',
248 <video id="samplevideo_amateur" class="js-samplevideo video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" width="400" height="225" poster="//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg">
249 <source id="video_source" src="https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4" type="video/mp4" res="240" label="300kbps">
250 <source id="video_source" src="https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4" type="video/mp4" res="480" label="1000kbps">
251 <source id="video_source" src="https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4" type="video/mp4" res="740" label="1500kbps">
252 <p>Your browser does not support the video tag.</p>
257 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4',
259 'format_id': '300kbps',
263 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4',
265 'format_id': '1000kbps',
269 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4',
271 'format_id': '1500kbps',
275 'thumbnail': '//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg'
278 # from https://www.csfd.cz/
279 # with width and height
282 self
.ie
._parse
_html
5_media
_entries
(
283 'https://www.csfd.cz/',
285 <video width="770" height="328" preload="none" controls poster="https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360" >
286 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4" type="video/mp4" width="640" height="360">
287 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4" type="video/mp4" width="1280" height="720">
288 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4" type="video/mp4" width="1920" height="1080">
289 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm" type="video/webm" width="640" height="360">
290 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm" type="video/webm" width="1280" height="720">
291 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm" type="video/webm" width="1920" height="1080">
292 <track src="https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt" type="text/x-srt" kind="subtitles" srclang="cs" label="cs">
297 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4',
302 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4',
307 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4',
312 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm',
317 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm',
322 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm',
328 'cs': [{'url': 'https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt'}
]
330 'thumbnail': 'https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360'
333 # from https://tamasha.com/v/Kkdjw
334 # with height in label
337 self
.ie
._parse
_html
5_media
_entries
(
338 'https://tamasha.com/v/Kkdjw',
340 <video crossorigin="anonymous">
341 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4" label="AUTO" res="0"/>
342 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4"
343 label="240p" res="240"/>
344 <source src="https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4" type="video/mp4"
345 label="144p" res="144"/>
350 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
352 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
357 'url': 'https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4',
364 # from https://www.directvnow.com
368 self
.ie
._parse
_html
5_media
_entries
(
369 'https://www.directvnow.com',
371 <video id="vid1" class="header--video-masked active" muted playsinline>
372 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
378 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
382 # from https://www.directvnow.com
386 self
.ie
._parse
_html
5_media
_entries
(
387 'https://www.directvnow.com',
389 <video id="vid1" class="header--video-masked active" muted playsinline>
390 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
395 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
400 # from https://www.klarna.com/uk/
401 # with data-video-src
404 self
.ie
._parse
_html
5_media
_entries
(
405 'https://www.directvnow.com',
407 <video loop autoplay muted class="responsive-video block-kl__video video-on-medium">
408 <source src="" data-video-desktop data-video-src="https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4" type="video/mp4" />
413 'url': 'https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4',
418 def test_extract_jwplayer_data_realworld(self
):
419 # from http://www.suffolk.edu/sjc/
422 self
.ie
._extract
_jwplayer
_data
(r
'''
423 <script type='text/javascript'>
424 jwplayer('my-video').setup({
425 file: 'rtmp://192.138.214.154/live/sjclive',
433 ''', None, require_title
=False),
437 'url': 'rtmp://192.138.214.154/live/sjclive',
442 # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/
445 self
.ie
._extract
_jwplayer
_data
(r
'''
446 <script type="text/javascript">
447 jwplayer("mediaplayer").setup({
450 'aspectratio': "16:9",
451 'stretching': "exactfit",
452 'autostart': 'false',
453 'flashplayer': "https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf",
454 'file': "https://cdn.pornoxo.com/key=MF+oEbaxqTKb50P-w9G3nA,end=1489689259,ip=104.199.146.27/ip=104.199.146.27/speed=6573765/buffer=3.0/2009-12/4b2157147afe5efa93ce1978e0265289c193874e02597.flv",
455 'image': "https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg",
456 'filefallback': "https://cdn.pornoxo.com/key=9ZPsTR5EvPLQrBaak2MUGA,end=1489689259,ip=104.199.146.27/ip=104.199.146.27/speed=6573765/buffer=3.0/2009-12/m_4b2157147afe5efa93ce1978e0265289c193874e02597.mp4",
458 'skin': "https://t04.vipstreamservice.com/jwplayer/skin/modieus-blk.zip",
459 'plugins': "https://t04.vipstreamservice.com/jwplayer/dock/dockableskinnableplugin.swf",
460 'dockableskinnableplugin.piclink': "/index.php?key=ajax-videothumbsn&vid=7564&data=2009-12--14--4b2157147afe5efa93ce1978e0265289c193874e02597.flv--17370",
461 'controlbar': 'bottom',
463 {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'}
467 //noinspection JSAnnotator
469 adsUrl: "/banner-iframe/?zoneId=32",
474 ''', 'dummy', require_title
=False),
476 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg',
478 'url': 'https://cdn.pornoxo.com/key=MF+oEbaxqTKb50P-w9G3nA,end=1489689259,ip=104.199.146.27/ip=104.199.146.27/speed=6573765/buffer=3.0/2009-12/4b2157147afe5efa93ce1978e0265289c193874e02597.flv',
483 # from http://www.indiedb.com/games/king-machine/videos
486 self
.ie
._extract
_jwplayer
_data
(r
'''
488 jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/\/www.indiedb.com\/","displaytitle":false,"autostart":false,"repeat":false,"title":"king machine trailer 1","sharing":{"link":"http:\/\/www.indiedb.com\/games\/king-machine\/videos\/king-machine-trailer-1","code":"<iframe width=\"560\" height=\"315\" src=\"http:\/\/www.indiedb.com\/media\/iframe\/1522983\" frameborder=\"0\" allowfullscreen><\/iframe><br><a href=\"http:\/\/www.indiedb.com\/games\/king-machine\/videos\/king-machine-trailer-1\">king machine trailer 1 - Indie DB<\/a>"},"related":{"file":"http:\/\/rss.indiedb.com\/media\/recommended\/1522983\/feed\/rss.xml","dimensions":"160x120","onclick":"link"},"sources":[{"file":"http:\/\/cdn.dbolical.com\/cache\/videos\/games\/1\/50\/49678\/encode_mp4\/king-machine-trailer.mp4","label":"360p SD","default":"true"},{"file":"http:\/\/cdn.dbolical.com\/cache\/videos\/games\/1\/50\/49678\/encode720p_mp4\/king-machine-trailer.mp4","label":"720p HD"}],"image":"http:\/\/media.indiedb.com\/cache\/images\/games\/1\/50\/49678\/thumb_620x2000\/king-machine-trailer.mp4.jpg","advertising":{"client":"vast","tag":"http:\/\/ads.intergi.com\/adrawdata\/3.0\/5205\/4251742\/0\/1013\/ADTECH;cors=yes;width=560;height=315;referring_url=http:\/\/www.indiedb.com\/games\/king-machine\/videos\/king-machine-trailer-1;content_url=http:\/\/www.indiedb.com\/games\/king-machine\/videos\/king-machine-trailer-1;media_id=1522983;title=king+machine+trailer+1;device=__DEVICE__;model=__MODEL__;os=Windows+OS;osversion=__OSVERSION__;ua=__UA__;ip=109.171.17.81;uniqueid=1522983;tags=__TAGS__;number=58cac25928151;time=1489683033"},"width":620,"height":349}).once("play", function(event) {
489 videoAnalytics("play");
490 }).once("complete", function(event) {
491 videoAnalytics("completed");
496 'title': 'king machine trailer 1',
497 'thumbnail': 'http://media.indiedb.com/cache/images/games/1/50/49678/thumb_620x2000/king-machine-trailer.mp4.jpg',
499 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4',
503 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4',
509 def test_parse_m3u8_formats(self
):
512 # https://github.com/ytdl-org/youtube-dl/issues/11995
513 # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor
514 'img_bipbop_adv_example_fmp4',
515 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
517 'format_id': 'aud1-English',
518 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a1/prog_index.m3u8',
519 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
522 'protocol': 'm3u8_native',
525 'format_id': 'aud2-English',
526 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a2/prog_index.m3u8',
527 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
530 'protocol': 'm3u8_native',
533 'format_id': 'aud3-English',
534 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a3/prog_index.m3u8',
535 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
538 'protocol': 'm3u8_native',
542 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
543 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
545 'protocol': 'm3u8_native',
548 'vcodec': 'avc1.640015',
551 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
552 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
554 'protocol': 'm3u8_native',
557 'vcodec': 'avc1.640015',
560 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
561 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
563 'protocol': 'm3u8_native',
566 'vcodec': 'avc1.640015',
569 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
570 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
572 'protocol': 'm3u8_native',
575 'vcodec': 'avc1.64001e',
578 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
579 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
581 'protocol': 'm3u8_native',
584 'vcodec': 'avc1.64001e',
587 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
588 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
590 'protocol': 'm3u8_native',
593 'vcodec': 'avc1.64001e',
596 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
597 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
599 'protocol': 'm3u8_native',
602 'vcodec': 'avc1.64001e',
605 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
606 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
608 'protocol': 'm3u8_native',
611 'vcodec': 'avc1.64001e',
614 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
615 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
617 'protocol': 'm3u8_native',
620 'vcodec': 'avc1.64001e',
623 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
624 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
626 'protocol': 'm3u8_native',
629 'vcodec': 'avc1.640020',
632 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
633 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
635 'protocol': 'm3u8_native',
638 'vcodec': 'avc1.640020',
641 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
642 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
644 'protocol': 'm3u8_native',
647 'vcodec': 'avc1.640020',
650 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
651 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
653 'protocol': 'm3u8_native',
656 'vcodec': 'avc1.640020',
659 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
660 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
662 'protocol': 'm3u8_native',
665 'vcodec': 'avc1.640020',
668 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
669 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
671 'protocol': 'm3u8_native',
674 'vcodec': 'avc1.640020',
677 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
678 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
680 'protocol': 'm3u8_native',
683 'vcodec': 'avc1.64002a',
686 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
687 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
689 'protocol': 'm3u8_native',
692 'vcodec': 'avc1.64002a',
695 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
696 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
698 'protocol': 'm3u8_native',
701 'vcodec': 'avc1.64002a',
704 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
705 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
707 'protocol': 'm3u8_native',
710 'vcodec': 'avc1.64002a',
713 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
714 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
716 'protocol': 'm3u8_native',
719 'vcodec': 'avc1.64002a',
722 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
723 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
725 'protocol': 'm3u8_native',
728 'vcodec': 'avc1.64002a',
731 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
732 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
734 'protocol': 'm3u8_native',
737 'vcodec': 'avc1.64002a',
740 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
741 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
743 'protocol': 'm3u8_native',
746 'vcodec': 'avc1.64002a',
749 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
750 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
752 'protocol': 'm3u8_native',
755 'vcodec': 'avc1.64002a',
761 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
763 'format_id': 'bipbop_audio-BipBop Audio 2',
764 'format_index': None,
765 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/alternate_audio_aac/prog_index.m3u8',
766 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
769 'protocol': 'm3u8_native',
777 'format_index': None,
778 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8',
779 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
783 'protocol': 'm3u8_native',
787 'acodec': 'mp4a.40.2',
793 'format_index': None,
794 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8',
795 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
799 'protocol': 'm3u8_native',
804 'vcodec': 'avc1.4d400d',
805 'acodec': 'mp4a.40.2',
812 'format_index': None,
813 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8',
814 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
818 'protocol': 'm3u8_native',
823 'vcodec': 'avc1.4d401e',
824 'acodec': 'mp4a.40.2',
831 'format_index': None,
832 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8',
833 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
837 'protocol': 'm3u8_native',
842 'vcodec': 'avc1.4d401f',
843 'acodec': 'mp4a.40.2',
850 'format_index': None,
851 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8',
852 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
856 'protocol': 'm3u8_native',
861 'vcodec': 'avc1.4d401f',
862 'acodec': 'mp4a.40.2',
869 'format_index': None,
870 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8',
871 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
875 'protocol': 'm3u8_native',
880 'vcodec': 'avc1.4d401f',
881 'acodec': 'mp4a.40.2',
889 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng/prog_index.m3u8',
891 'protocol': 'm3u8_native'
893 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng_forced/prog_index.m3u8',
895 'protocol': 'm3u8_native'
898 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra/prog_index.m3u8',
900 'protocol': 'm3u8_native'
902 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra_forced/prog_index.m3u8',
904 'protocol': 'm3u8_native'
907 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa/prog_index.m3u8',
909 'protocol': 'm3u8_native'
911 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa_forced/prog_index.m3u8',
913 'protocol': 'm3u8_native'
916 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn/prog_index.m3u8',
918 'protocol': 'm3u8_native'
920 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn_forced/prog_index.m3u8',
922 'protocol': 'm3u8_native'
928 for m3u8_file
, m3u8_url
, expected_formats
, expected_subs
in _TEST_CASES
:
929 with io
.open('./test/testdata/m3u8/%s.m3u8' % m3u8_file
,
930 mode
='r', encoding
='utf-8') as f
:
931 formats
, subs
= self
.ie
._parse
_m
3u8_formats
_and
_subtitles
(
932 f
.read(), m3u8_url
, ext
='mp4')
933 self
.ie
._sort
_formats
(formats
)
934 expect_value(self
, formats
, expected_formats
, None)
935 expect_value(self
, subs
, expected_subs
, None)
937 def test_parse_mpd_formats(self
):
940 # https://github.com/ytdl-org/youtube-dl/issues/13919
941 # Also tests duplicate representation ids, see
942 # https://github.com/ytdl-org/youtube-dl/issues/15111
944 'http://unknown/manifest.mpd', # mpd_url
947 'manifest_url': 'http://unknown/manifest.mpd',
949 'format_id': '318597',
950 'format_note': 'DASH audio',
951 'protocol': 'http_dash_segments',
952 'acodec': 'mp4a.40.2',
956 'manifest_url': 'http://unknown/manifest.mpd',
958 'format_id': '318597',
959 'format_note': 'DASH video',
960 'protocol': 'http_dash_segments',
962 'vcodec': 'avc1.42001f',
967 'manifest_url': 'http://unknown/manifest.mpd',
969 'format_id': '638590',
970 'format_note': 'DASH video',
971 'protocol': 'http_dash_segments',
973 'vcodec': 'avc1.42001f',
978 'manifest_url': 'http://unknown/manifest.mpd',
980 'format_id': '1022565',
981 'format_note': 'DASH video',
982 'protocol': 'http_dash_segments',
984 'vcodec': 'avc1.4d001f',
989 'manifest_url': 'http://unknown/manifest.mpd',
991 'format_id': '2046506',
992 'format_note': 'DASH video',
993 'protocol': 'http_dash_segments',
995 'vcodec': 'avc1.4d001f',
1000 'manifest_url': 'http://unknown/manifest.mpd',
1002 'format_id': '3998017',
1003 'format_note': 'DASH video',
1004 'protocol': 'http_dash_segments',
1006 'vcodec': 'avc1.640029',
1011 'manifest_url': 'http://unknown/manifest.mpd',
1013 'format_id': '5997485',
1014 'format_note': 'DASH video',
1015 'protocol': 'http_dash_segments',
1017 'vcodec': 'avc1.640032',
1024 # https://github.com/ytdl-org/youtube-dl/pull/14844
1026 'http://unknown/manifest.mpd', # mpd_url
1027 None, # mpd_base_url
1029 'manifest_url': 'http://unknown/manifest.mpd',
1031 'format_id': 'h264_aac_144p_m4s',
1032 'format_note': 'DASH video',
1033 'protocol': 'http_dash_segments',
1034 'acodec': 'mp4a.40.2',
1035 'vcodec': 'avc3.42c01e',
1040 'manifest_url': 'http://unknown/manifest.mpd',
1042 'format_id': 'h264_aac_240p_m4s',
1043 'format_note': 'DASH video',
1044 'protocol': 'http_dash_segments',
1045 'acodec': 'mp4a.40.2',
1046 'vcodec': 'avc3.42c01e',
1051 'manifest_url': 'http://unknown/manifest.mpd',
1053 'format_id': 'h264_aac_360p_m4s',
1054 'format_note': 'DASH video',
1055 'protocol': 'http_dash_segments',
1056 'acodec': 'mp4a.40.2',
1057 'vcodec': 'avc3.42c01e',
1062 'manifest_url': 'http://unknown/manifest.mpd',
1064 'format_id': 'h264_aac_480p_m4s',
1065 'format_note': 'DASH video',
1066 'protocol': 'http_dash_segments',
1067 'acodec': 'mp4a.40.2',
1068 'vcodec': 'avc3.42c01e',
1073 'manifest_url': 'http://unknown/manifest.mpd',
1075 'format_id': 'h264_aac_576p_m4s',
1076 'format_note': 'DASH video',
1077 'protocol': 'http_dash_segments',
1078 'acodec': 'mp4a.40.2',
1079 'vcodec': 'avc3.42c01e',
1084 'manifest_url': 'http://unknown/manifest.mpd',
1086 'format_id': 'h264_aac_720p_m4s',
1087 'format_note': 'DASH video',
1088 'protocol': 'http_dash_segments',
1089 'acodec': 'mp4a.40.2',
1090 'vcodec': 'avc3.42c01e',
1095 'manifest_url': 'http://unknown/manifest.mpd',
1097 'format_id': 'h264_aac_1080p_m4s',
1098 'format_note': 'DASH video',
1099 'protocol': 'http_dash_segments',
1100 'acodec': 'mp4a.40.2',
1101 'vcodec': 'avc3.42c01e',
1108 # https://github.com/ytdl-org/youtube-dl/issues/20346
1109 # Media considered unfragmented even though it contains
1110 # Initialization tag
1112 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', # mpd_url
1113 'https://v.redd.it/hw1x7rcg7zl21', # mpd_base_url
1115 'url': 'https://v.redd.it/hw1x7rcg7zl21/audio',
1116 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1118 'format_id': 'AUDIO-1',
1119 'format_note': 'DASH audio',
1120 'container': 'm4a_dash',
1121 'acodec': 'mp4a.40.2',
1127 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240',
1128 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1130 'format_id': 'VIDEO-2',
1131 'format_note': 'DASH video',
1132 'container': 'mp4_dash',
1134 'vcodec': 'avc1.4d401e',
1140 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_360',
1141 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1143 'format_id': 'VIDEO-1',
1144 'format_note': 'DASH video',
1145 'container': 'mp4_dash',
1147 'vcodec': 'avc1.4d401e',
1156 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1157 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/',
1159 'format_id': 'audio=128001',
1160 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1164 'format_note': 'DASH audio',
1165 'container': 'm4a_dash',
1167 'acodec': 'mp4a.40.2',
1168 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1169 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1170 'protocol': 'http_dash_segments',
1172 'video_ext': 'none',
1175 'format_id': 'video=100000',
1176 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1181 'format_note': 'DASH video',
1182 'container': 'mp4_dash',
1183 'vcodec': 'avc1.4D401F',
1185 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1186 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1187 'protocol': 'http_dash_segments',
1189 'audio_ext': 'none',
1192 'format_id': 'video=326000',
1193 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1198 'format_note': 'DASH video',
1199 'container': 'mp4_dash',
1200 'vcodec': 'avc1.4D401F',
1202 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1203 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1204 'protocol': 'http_dash_segments',
1206 'audio_ext': 'none',
1209 'format_id': 'video=698000',
1210 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1215 'format_note': 'DASH video',
1216 'container': 'mp4_dash',
1217 'vcodec': 'avc1.4D401F',
1219 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1220 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1221 'protocol': 'http_dash_segments',
1223 'audio_ext': 'none',
1226 'format_id': 'video=1493000',
1227 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1232 'format_note': 'DASH video',
1233 'container': 'mp4_dash',
1234 'vcodec': 'avc1.4D401F',
1236 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1237 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1238 'protocol': 'http_dash_segments',
1240 'audio_ext': 'none',
1243 'format_id': 'video=4482000',
1244 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1249 'format_note': 'DASH video',
1250 'container': 'mp4_dash',
1251 'vcodec': 'avc1.4D401F',
1253 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1254 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1255 'protocol': 'http_dash_segments',
1257 'audio_ext': 'none',
1264 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1265 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1266 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1267 'protocol': 'http_dash_segments',
1274 for mpd_file
, mpd_url
, mpd_base_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1275 with io
.open('./test/testdata/mpd/%s.mpd' % mpd_file
,
1276 mode
='r', encoding
='utf-8') as f
:
1277 formats
, subtitles
= self
.ie
._parse
_mpd
_formats
_and
_subtitles
(
1278 compat_etree_fromstring(f
.read().encode('utf-8')),
1279 mpd_base_url
=mpd_base_url
, mpd_url
=mpd_url
)
1280 self
.ie
._sort
_formats
(formats
)
1281 expect_value(self
, formats
, expected_formats
, None)
1282 expect_value(self
, subtitles
, expected_subtitles
, None)
1284 def test_parse_ism_formats(self
):
1288 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1290 'format_id': 'audio-128',
1291 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1292 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1299 '_download_params': {
1300 'stream_type': 'audio',
1301 'duration': 8880746666,
1302 'timescale': 10000000,
1306 'codec_private_data': '1190',
1307 'sampling_rate': 48000,
1309 'bits_per_sample': 16,
1310 'nal_unit_length_field': 4
1312 'audio_ext': 'isma',
1313 'video_ext': 'none',
1316 'format_id': 'video-100',
1317 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1318 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1326 '_download_params': {
1327 'stream_type': 'video',
1328 'duration': 8880746666,
1329 'timescale': 10000000,
1333 'codec_private_data': '00000001674D401FDA0544EFFC2D002CBC40000003004000000C03C60CA80000000168EF32C8',
1335 'bits_per_sample': 16,
1336 'nal_unit_length_field': 4
1338 'video_ext': 'ismv',
1339 'audio_ext': 'none',
1342 'format_id': 'video-326',
1343 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1344 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1352 '_download_params': {
1353 'stream_type': 'video',
1354 'duration': 8880746666,
1355 'timescale': 10000000,
1359 'codec_private_data': '00000001674D401FDA0241FE23FFC3BC83BA44000003000400000300C03C60CA800000000168EF32C8',
1361 'bits_per_sample': 16,
1362 'nal_unit_length_field': 4
1364 'video_ext': 'ismv',
1365 'audio_ext': 'none',
1368 'format_id': 'video-698',
1369 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1370 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1378 '_download_params': {
1379 'stream_type': 'video',
1380 'duration': 8880746666,
1381 'timescale': 10000000,
1385 'codec_private_data': '00000001674D401FDA0350BFB97FF06AF06AD1000003000100000300300F1832A00000000168EF32C8',
1387 'bits_per_sample': 16,
1388 'nal_unit_length_field': 4
1390 'video_ext': 'ismv',
1391 'audio_ext': 'none',
1394 'format_id': 'video-1493',
1395 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1396 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1404 '_download_params': {
1405 'stream_type': 'video',
1406 'duration': 8880746666,
1407 'timescale': 10000000,
1411 'codec_private_data': '00000001674D401FDA011C3DE6FFF0D890D871000003000100000300300F1832A00000000168EF32C8',
1413 'bits_per_sample': 16,
1414 'nal_unit_length_field': 4
1416 'video_ext': 'ismv',
1417 'audio_ext': 'none',
1420 'format_id': 'video-4482',
1421 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1422 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1430 '_download_params': {
1431 'stream_type': 'video',
1432 'duration': 8880746666,
1433 'timescale': 10000000,
1437 'codec_private_data': '00000001674D401FDA01A816F97FFC1ABC1AB440000003004000000C03C60CA80000000168EF32C8',
1439 'bits_per_sample': 16,
1440 'nal_unit_length_field': 4
1442 'video_ext': 'ismv',
1443 'audio_ext': 'none',
1451 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1452 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1453 '_download_params': {
1454 'stream_type': 'text',
1455 'duration': 8880746666,
1456 'timescale': 10000000,
1458 'codec_private_data': ''
1466 for ism_file
, ism_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1467 with io
.open('./test/testdata/ism/%s.Manifest' % ism_file
,
1468 mode
='r', encoding
='utf-8') as f
:
1469 formats
, subtitles
= self
.ie
._parse
_ism
_formats
_and
_subtitles
(
1470 compat_etree_fromstring(f
.read().encode('utf-8')), ism_url
=ism_url
)
1471 self
.ie
._sort
_formats
(formats
)
1472 expect_value(self
, formats
, expected_formats
, None)
1473 expect_value(self
, subtitles
, expected_subtitles
, None)
1475 def test_parse_f4m_formats(self
):
1478 # https://github.com/ytdl-org/youtube-dl/issues/14660
1480 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1482 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1484 'format_id': '2148',
1493 for f4m_file
, f4m_url
, expected_formats
in _TEST_CASES
:
1494 with io
.open('./test/testdata/f4m/%s.f4m' % f4m_file
,
1495 mode
='r', encoding
='utf-8') as f
:
1496 formats
= self
.ie
._parse
_f
4m
_formats
(
1497 compat_etree_fromstring(f
.read().encode('utf-8')),
1499 self
.ie
._sort
_formats
(formats
)
1500 expect_value(self
, formats
, expected_formats
, None)
1502 def test_parse_xspf(self
):
1506 'https://example.org/src/foo_xspf.xspf',
1509 'title': 'Pandemonium',
1510 'description': 'Visit http://bigbrother404.bandcamp.com',
1511 'duration': 202.416,
1513 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1514 'url': 'https://example.org/src/cd1/track%201.mp3',
1518 'title': 'Final Cartridge (Nichico Twelve Remix)',
1519 'description': 'Visit http://bigbrother404.bandcamp.com',
1520 'duration': 255.857,
1522 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1523 'url': 'https://example.org/%E3%83%88%E3%83%A9%E3%83%83%E3%82%AF%E3%80%80%EF%BC%92.mp3',
1527 'title': 'Rebuilding Nightingale',
1528 'description': 'Visit http://bigbrother404.bandcamp.com',
1529 'duration': 287.915,
1531 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1532 'url': 'https://example.org/src/track3.mp3',
1534 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1535 'url': 'https://example.com/track3.mp3',
1541 for xspf_file
, xspf_url
, expected_entries
in _TEST_CASES
:
1542 with io
.open('./test/testdata/xspf/%s.xspf' % xspf_file
,
1543 mode
='r', encoding
='utf-8') as f
:
1544 entries
= self
.ie
._parse
_xspf
(
1545 compat_etree_fromstring(f
.read().encode('utf-8')),
1546 xspf_file
, xspf_url
=xspf_url
, xspf_base_url
=xspf_url
)
1547 expect_value(self
, entries
, expected_entries
, None)
1548 for i
in range(len(entries
)):
1549 expect_dict(self
, entries
[i
], expected_entries
[i
])
1551 def test_response_with_expected_status_returns_content(self
):
1552 # Checks for mitigations against the effects of
1553 # <https://bugs.python.org/issue15002> that affect Python 3.4.1+, which
1554 # manifest as `_download_webpage`, `_download_xml`, `_download_json`,
1555 # or the underlying `_download_webpage_handle` returning no content
1556 # when a response matches `expected_status`.
1558 httpd
= compat_http_server
.HTTPServer(
1559 ('127.0.0.1', 0), InfoExtractorTestRequestHandler
)
1560 port
= http_server_port(httpd
)
1561 server_thread
= threading
.Thread(target
=httpd
.serve_forever
)
1562 server_thread
.daemon
= True
1563 server_thread
.start()
1565 (content
, urlh
) = self
.ie
._download
_webpage
_handle
(
1566 'http://127.0.0.1:%d/teapot' % port
, None,
1567 expected_status
=TEAPOT_RESPONSE_STATUS
)
1568 self
.assertEqual(content
, TEAPOT_RESPONSE_BODY
)
1571 if __name__
== '__main__':