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 TestIE(InfoExtractor
):
42 class TestInfoExtractor(unittest
.TestCase
):
44 self
.ie
= TestIE(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
):
102 # https://github.com/ytdl-org/youtube-dl/issues/23306
105 self
.ie
._search
_json
_ld
(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,
150 def test_download_json(self
):
151 uri
= encode_data_uri(b
'{"foo": "blah"}', 'application/json')
152 self
.assertEqual(self
.ie
._download
_json
(uri
, None), {'foo': 'blah'}
)
153 uri
= encode_data_uri(b
'callback({"foo": "blah"})', 'application/javascript')
154 self
.assertEqual(self
.ie
._download
_json
(uri
, None, transform_source
=strip_jsonp
), {'foo': 'blah'}
)
155 uri
= encode_data_uri(b
'{"foo": invalid}', 'application/json')
156 self
.assertRaises(ExtractorError
, self
.ie
._download
_json
, uri
, None)
157 self
.assertEqual(self
.ie
._download
_json
(uri
, None, fatal
=False), None)
159 def test_parse_html5_media_entries(self
):
163 self
.ie
._parse
_html
5_media
_entries
(
164 'https://127.0.0.1/video.html',
165 r
'<html><video src="/vid.mp4" /></html>', None)[0],
168 'url': 'https://127.0.0.1/vid.mp4',
172 # from https://www.r18.com/
176 self
.ie
._parse
_html
5_media
_entries
(
177 'https://www.r18.com/',
179 <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">
180 <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">
181 <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">
182 <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">
183 <p>Your browser does not support the video tag.</p>
188 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4',
190 'format_id': '300kbps',
194 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4',
196 'format_id': '1000kbps',
200 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4',
202 'format_id': '1500kbps',
206 'thumbnail': '//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg'
209 # from https://www.csfd.cz/
210 # with width and height
213 self
.ie
._parse
_html
5_media
_entries
(
214 'https://www.csfd.cz/',
216 <video width="770" height="328" preload="none" controls poster="https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360" >
217 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4" type="video/mp4" width="640" height="360">
218 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4" type="video/mp4" width="1280" height="720">
219 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4" type="video/mp4" width="1920" height="1080">
220 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm" type="video/webm" width="640" height="360">
221 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm" type="video/webm" width="1280" height="720">
222 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm" type="video/webm" width="1920" height="1080">
223 <track src="https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt" type="text/x-srt" kind="subtitles" srclang="cs" label="cs">
228 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4',
233 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4',
238 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4',
243 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm',
248 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm',
253 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm',
259 'cs': [{'url': 'https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt'}
]
261 'thumbnail': 'https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360'
264 # from https://tamasha.com/v/Kkdjw
265 # with height in label
268 self
.ie
._parse
_html
5_media
_entries
(
269 'https://tamasha.com/v/Kkdjw',
271 <video crossorigin="anonymous">
272 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4" label="AUTO" res="0"/>
273 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4"
274 label="240p" res="240"/>
275 <source src="https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4" type="video/mp4"
276 label="144p" res="144"/>
281 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
283 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
288 'url': 'https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4',
295 # from https://www.directvnow.com
299 self
.ie
._parse
_html
5_media
_entries
(
300 'https://www.directvnow.com',
302 <video id="vid1" class="header--video-masked active" muted playsinline>
303 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
309 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
313 # from https://www.directvnow.com
317 self
.ie
._parse
_html
5_media
_entries
(
318 'https://www.directvnow.com',
320 <video id="vid1" class="header--video-masked active" muted playsinline>
321 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
326 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
331 # from https://www.klarna.com/uk/
332 # with data-video-src
335 self
.ie
._parse
_html
5_media
_entries
(
336 'https://www.directvnow.com',
338 <video loop autoplay muted class="responsive-video block-kl__video video-on-medium">
339 <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" />
344 'url': 'https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4',
349 def test_extract_jwplayer_data_realworld(self
):
350 # from http://www.suffolk.edu/sjc/
353 self
.ie
._extract
_jwplayer
_data
(r
'''
354 <script type='text/javascript'>
355 jwplayer('my-video').setup({
356 file: 'rtmp://192.138.214.154/live/sjclive',
364 ''', None, require_title
=False),
368 'url': 'rtmp://192.138.214.154/live/sjclive',
373 # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/
376 self
.ie
._extract
_jwplayer
_data
(r
'''
377 <script type="text/javascript">
378 jwplayer("mediaplayer").setup({
381 'aspectratio': "16:9",
382 'stretching': "exactfit",
383 'autostart': 'false',
384 'flashplayer': "https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf",
385 '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",
386 'image': "https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg",
387 '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",
389 'skin': "https://t04.vipstreamservice.com/jwplayer/skin/modieus-blk.zip",
390 'plugins': "https://t04.vipstreamservice.com/jwplayer/dock/dockableskinnableplugin.swf",
391 'dockableskinnableplugin.piclink': "/index.php?key=ajax-videothumbsn&vid=7564&data=2009-12--14--4b2157147afe5efa93ce1978e0265289c193874e02597.flv--17370",
392 'controlbar': 'bottom',
394 {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'}
398 //noinspection JSAnnotator
400 adsUrl: "/banner-iframe/?zoneId=32",
405 ''', 'dummy', require_title
=False),
407 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg',
409 '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',
414 # from http://www.indiedb.com/games/king-machine/videos
417 self
.ie
._extract
_jwplayer
_data
(r
'''
419 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) {
420 videoAnalytics("play");
421 }).once("complete", function(event) {
422 videoAnalytics("completed");
427 'title': 'king machine trailer 1',
428 'thumbnail': 'http://media.indiedb.com/cache/images/games/1/50/49678/thumb_620x2000/king-machine-trailer.mp4.jpg',
430 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4',
434 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4',
440 def test_parse_m3u8_formats(self
):
443 # https://github.com/ytdl-org/youtube-dl/issues/11995
444 # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor
445 'img_bipbop_adv_example_fmp4',
446 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
448 'format_id': 'aud1-English',
449 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a1/prog_index.m3u8',
450 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
456 'format_id': 'aud2-English',
457 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a2/prog_index.m3u8',
458 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
464 'format_id': 'aud3-English',
465 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a3/prog_index.m3u8',
466 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
473 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
474 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
479 'vcodec': 'avc1.640015',
482 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
483 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
488 'vcodec': 'avc1.640015',
491 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
492 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
497 'vcodec': 'avc1.640015',
500 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
501 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
506 'vcodec': 'avc1.64001e',
509 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
510 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
515 'vcodec': 'avc1.64001e',
518 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
519 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
524 'vcodec': 'avc1.64001e',
527 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
528 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
533 'vcodec': 'avc1.64001e',
536 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
537 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
542 'vcodec': 'avc1.64001e',
545 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
546 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
551 'vcodec': 'avc1.64001e',
554 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
555 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
560 'vcodec': 'avc1.640020',
563 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
564 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
569 'vcodec': 'avc1.640020',
572 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
573 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
578 'vcodec': 'avc1.640020',
581 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
582 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
587 'vcodec': 'avc1.640020',
590 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
591 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
596 'vcodec': 'avc1.640020',
599 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
600 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
605 'vcodec': 'avc1.640020',
608 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
609 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
614 'vcodec': 'avc1.64002a',
617 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
618 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
623 'vcodec': 'avc1.64002a',
626 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
627 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
632 'vcodec': 'avc1.64002a',
635 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
636 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
641 'vcodec': 'avc1.64002a',
644 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
645 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
650 'vcodec': 'avc1.64002a',
653 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
654 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
659 'vcodec': 'avc1.64002a',
662 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
663 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
668 'vcodec': 'avc1.64002a',
671 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
672 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
677 'vcodec': 'avc1.64002a',
680 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
681 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
686 'vcodec': 'avc1.64002a',
692 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
694 "format_id": "bipbop_audio-BipBop Audio 2",
695 "format_index": None,
696 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/alternate_audio_aac/prog_index.m3u8",
697 "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8",
708 "format_index": None,
709 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8",
710 "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8",
718 "acodec": "mp4a.40.2",
724 "format_index": None,
725 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8",
726 "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8",
735 "vcodec": "avc1.4d400d",
736 "acodec": "mp4a.40.2",
743 "format_index": None,
744 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8",
745 "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8",
754 "vcodec": "avc1.4d401e",
755 "acodec": "mp4a.40.2",
762 "format_index": None,
763 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8",
764 "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8",
773 "vcodec": "avc1.4d401f",
774 "acodec": "mp4a.40.2",
781 "format_index": None,
782 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8",
783 "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8",
792 "vcodec": "avc1.4d401f",
793 "acodec": "mp4a.40.2",
800 "format_index": None,
801 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8",
802 "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8",
811 "vcodec": "avc1.4d401f",
812 "acodec": "mp4a.40.2",
820 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng/prog_index.m3u8",
822 "protocol": "m3u8_native"
824 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng_forced/prog_index.m3u8",
826 "protocol": "m3u8_native"
829 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra/prog_index.m3u8",
831 "protocol": "m3u8_native"
833 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra_forced/prog_index.m3u8",
835 "protocol": "m3u8_native"
838 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa/prog_index.m3u8",
840 "protocol": "m3u8_native"
842 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa_forced/prog_index.m3u8",
844 "protocol": "m3u8_native"
847 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn/prog_index.m3u8",
849 "protocol": "m3u8_native"
851 "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn_forced/prog_index.m3u8",
853 "protocol": "m3u8_native"
859 for m3u8_file
, m3u8_url
, expected_formats
, expected_subs
in _TEST_CASES
:
860 with io
.open('./test/testdata/m3u8/%s.m3u8' % m3u8_file
,
861 mode
='r', encoding
='utf-8') as f
:
862 formats
, subs
= self
.ie
._parse
_m
3u8_formats
_and
_subtitles
(
863 f
.read(), m3u8_url
, ext
='mp4')
864 self
.ie
._sort
_formats
(formats
)
865 expect_value(self
, formats
, expected_formats
, None)
866 expect_value(self
, subs
, expected_subs
, None)
868 def test_parse_mpd_formats(self
):
871 # https://github.com/ytdl-org/youtube-dl/issues/13919
872 # Also tests duplicate representation ids, see
873 # https://github.com/ytdl-org/youtube-dl/issues/15111
875 'http://unknown/manifest.mpd', # mpd_url
878 'manifest_url': 'http://unknown/manifest.mpd',
880 'format_id': '318597',
881 'format_note': 'DASH audio',
882 'protocol': 'http_dash_segments',
883 'acodec': 'mp4a.40.2',
887 'manifest_url': 'http://unknown/manifest.mpd',
889 'format_id': '318597',
890 'format_note': 'DASH video',
891 'protocol': 'http_dash_segments',
893 'vcodec': 'avc1.42001f',
898 'manifest_url': 'http://unknown/manifest.mpd',
900 'format_id': '638590',
901 'format_note': 'DASH video',
902 'protocol': 'http_dash_segments',
904 'vcodec': 'avc1.42001f',
909 'manifest_url': 'http://unknown/manifest.mpd',
911 'format_id': '1022565',
912 'format_note': 'DASH video',
913 'protocol': 'http_dash_segments',
915 'vcodec': 'avc1.4d001f',
920 'manifest_url': 'http://unknown/manifest.mpd',
922 'format_id': '2046506',
923 'format_note': 'DASH video',
924 'protocol': 'http_dash_segments',
926 'vcodec': 'avc1.4d001f',
931 'manifest_url': 'http://unknown/manifest.mpd',
933 'format_id': '3998017',
934 'format_note': 'DASH video',
935 'protocol': 'http_dash_segments',
937 'vcodec': 'avc1.640029',
942 'manifest_url': 'http://unknown/manifest.mpd',
944 'format_id': '5997485',
945 'format_note': 'DASH video',
946 'protocol': 'http_dash_segments',
948 'vcodec': 'avc1.640032',
955 # https://github.com/ytdl-org/youtube-dl/pull/14844
957 'http://unknown/manifest.mpd', # mpd_url
960 'manifest_url': 'http://unknown/manifest.mpd',
962 'format_id': 'h264_aac_144p_m4s',
963 'format_note': 'DASH video',
964 'protocol': 'http_dash_segments',
965 'acodec': 'mp4a.40.2',
966 'vcodec': 'avc3.42c01e',
971 'manifest_url': 'http://unknown/manifest.mpd',
973 'format_id': 'h264_aac_240p_m4s',
974 'format_note': 'DASH video',
975 'protocol': 'http_dash_segments',
976 'acodec': 'mp4a.40.2',
977 'vcodec': 'avc3.42c01e',
982 'manifest_url': 'http://unknown/manifest.mpd',
984 'format_id': 'h264_aac_360p_m4s',
985 'format_note': 'DASH video',
986 'protocol': 'http_dash_segments',
987 'acodec': 'mp4a.40.2',
988 'vcodec': 'avc3.42c01e',
993 'manifest_url': 'http://unknown/manifest.mpd',
995 'format_id': 'h264_aac_480p_m4s',
996 'format_note': 'DASH video',
997 'protocol': 'http_dash_segments',
998 'acodec': 'mp4a.40.2',
999 'vcodec': 'avc3.42c01e',
1004 'manifest_url': 'http://unknown/manifest.mpd',
1006 'format_id': 'h264_aac_576p_m4s',
1007 'format_note': 'DASH video',
1008 'protocol': 'http_dash_segments',
1009 'acodec': 'mp4a.40.2',
1010 'vcodec': 'avc3.42c01e',
1015 'manifest_url': 'http://unknown/manifest.mpd',
1017 'format_id': 'h264_aac_720p_m4s',
1018 'format_note': 'DASH video',
1019 'protocol': 'http_dash_segments',
1020 'acodec': 'mp4a.40.2',
1021 'vcodec': 'avc3.42c01e',
1026 'manifest_url': 'http://unknown/manifest.mpd',
1028 'format_id': 'h264_aac_1080p_m4s',
1029 'format_note': 'DASH video',
1030 'protocol': 'http_dash_segments',
1031 'acodec': 'mp4a.40.2',
1032 'vcodec': 'avc3.42c01e',
1039 # https://github.com/ytdl-org/youtube-dl/issues/20346
1040 # Media considered unfragmented even though it contains
1041 # Initialization tag
1043 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', # mpd_url
1044 'https://v.redd.it/hw1x7rcg7zl21', # mpd_base_url
1046 'url': 'https://v.redd.it/hw1x7rcg7zl21/audio',
1047 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1049 'format_id': 'AUDIO-1',
1050 'format_note': 'DASH audio',
1051 'container': 'm4a_dash',
1052 'acodec': 'mp4a.40.2',
1058 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240',
1059 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1061 'format_id': 'VIDEO-2',
1062 'format_note': 'DASH video',
1063 'container': 'mp4_dash',
1065 'vcodec': 'avc1.4d401e',
1071 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_360',
1072 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1074 'format_id': 'VIDEO-1',
1075 'format_note': 'DASH video',
1076 'container': 'mp4_dash',
1078 'vcodec': 'avc1.4d401e',
1087 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1088 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/',
1090 "format_id": "audio=128001",
1091 "manifest_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1095 "format_note": "DASH audio",
1096 "container": "m4a_dash",
1098 "acodec": "mp4a.40.2",
1099 "url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1100 "fragment_base_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/",
1101 "protocol": "http_dash_segments",
1103 "video_ext": "none",
1106 "format_id": "video=100000",
1107 "manifest_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1112 "format_note": "DASH video",
1113 "container": "mp4_dash",
1114 "vcodec": "avc1.4D401F",
1116 "url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1117 "fragment_base_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/",
1118 "protocol": "http_dash_segments",
1120 "audio_ext": "none",
1123 "format_id": "video=326000",
1124 "manifest_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1129 "format_note": "DASH video",
1130 "container": "mp4_dash",
1131 "vcodec": "avc1.4D401F",
1133 "url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1134 "fragment_base_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/",
1135 "protocol": "http_dash_segments",
1137 "audio_ext": "none",
1140 "format_id": "video=698000",
1141 "manifest_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1146 "format_note": "DASH video",
1147 "container": "mp4_dash",
1148 "vcodec": "avc1.4D401F",
1150 "url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1151 "fragment_base_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/",
1152 "protocol": "http_dash_segments",
1154 "audio_ext": "none",
1157 "format_id": "video=1493000",
1158 "manifest_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1163 "format_note": "DASH video",
1164 "container": "mp4_dash",
1165 "vcodec": "avc1.4D401F",
1167 "url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1168 "fragment_base_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/",
1169 "protocol": "http_dash_segments",
1171 "audio_ext": "none",
1174 "format_id": "video=4482000",
1175 "manifest_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1180 "format_note": "DASH video",
1181 "container": "mp4_dash",
1182 "vcodec": "avc1.4D401F",
1184 "url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1185 "fragment_base_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/",
1186 "protocol": "http_dash_segments",
1188 "audio_ext": "none",
1195 "manifest_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1196 "url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd",
1197 "fragment_base_url": "https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/",
1198 "protocol": "http_dash_segments",
1205 for mpd_file
, mpd_url
, mpd_base_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1206 with io
.open('./test/testdata/mpd/%s.mpd' % mpd_file
,
1207 mode
='r', encoding
='utf-8') as f
:
1208 formats
, subtitles
= self
.ie
._parse
_mpd
_formats
_and
_subtitles
(
1209 compat_etree_fromstring(f
.read().encode('utf-8')),
1210 mpd_base_url
=mpd_base_url
, mpd_url
=mpd_url
)
1211 self
.ie
._sort
_formats
(formats
)
1212 expect_value(self
, formats
, expected_formats
, None)
1213 expect_value(self
, subtitles
, expected_subtitles
, None)
1215 def test_parse_f4m_formats(self
):
1218 # https://github.com/ytdl-org/youtube-dl/issues/14660
1220 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1222 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1224 'format_id': '2148',
1233 for f4m_file
, f4m_url
, expected_formats
in _TEST_CASES
:
1234 with io
.open('./test/testdata/f4m/%s.f4m' % f4m_file
,
1235 mode
='r', encoding
='utf-8') as f
:
1236 formats
= self
.ie
._parse
_f
4m
_formats
(
1237 compat_etree_fromstring(f
.read().encode('utf-8')),
1239 self
.ie
._sort
_formats
(formats
)
1240 expect_value(self
, formats
, expected_formats
, None)
1242 def test_parse_xspf(self
):
1246 'https://example.org/src/foo_xspf.xspf',
1249 'title': 'Pandemonium',
1250 'description': 'Visit http://bigbrother404.bandcamp.com',
1251 'duration': 202.416,
1253 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1254 'url': 'https://example.org/src/cd1/track%201.mp3',
1258 'title': 'Final Cartridge (Nichico Twelve Remix)',
1259 'description': 'Visit http://bigbrother404.bandcamp.com',
1260 'duration': 255.857,
1262 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1263 'url': 'https://example.org/%E3%83%88%E3%83%A9%E3%83%83%E3%82%AF%E3%80%80%EF%BC%92.mp3',
1267 'title': 'Rebuilding Nightingale',
1268 'description': 'Visit http://bigbrother404.bandcamp.com',
1269 'duration': 287.915,
1271 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1272 'url': 'https://example.org/src/track3.mp3',
1274 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1275 'url': 'https://example.com/track3.mp3',
1281 for xspf_file
, xspf_url
, expected_entries
in _TEST_CASES
:
1282 with io
.open('./test/testdata/xspf/%s.xspf' % xspf_file
,
1283 mode
='r', encoding
='utf-8') as f
:
1284 entries
= self
.ie
._parse
_xspf
(
1285 compat_etree_fromstring(f
.read().encode('utf-8')),
1286 xspf_file
, xspf_url
=xspf_url
, xspf_base_url
=xspf_url
)
1287 expect_value(self
, entries
, expected_entries
, None)
1288 for i
in range(len(entries
)):
1289 expect_dict(self
, entries
[i
], expected_entries
[i
])
1291 def test_response_with_expected_status_returns_content(self
):
1292 # Checks for mitigations against the effects of
1293 # <https://bugs.python.org/issue15002> that affect Python 3.4.1+, which
1294 # manifest as `_download_webpage`, `_download_xml`, `_download_json`,
1295 # or the underlying `_download_webpage_handle` returning no content
1296 # when a response matches `expected_status`.
1298 httpd
= compat_http_server
.HTTPServer(
1299 ('127.0.0.1', 0), InfoExtractorTestRequestHandler
)
1300 port
= http_server_port(httpd
)
1301 server_thread
= threading
.Thread(target
=httpd
.serve_forever
)
1302 server_thread
.daemon
= True
1303 server_thread
.start()
1305 (content
, urlh
) = self
.ie
._download
_webpage
_handle
(
1306 'http://127.0.0.1:%d/teapot' % port
, None,
1307 expected_status
=TEAPOT_RESPONSE_STATUS
)
1308 self
.assertEqual(content
, TEAPOT_RESPONSE_BODY
)
1311 if __name__
== '__main__':