]> jfr.im git - yt-dlp.git/blame - test/test_InfoExtractor.py
Update to ytdl-2021.01.03
[yt-dlp.git] / test / test_InfoExtractor.py
CommitLineData
14719565
JMF
1#!/usr/bin/env python
2
3from __future__ import unicode_literals
4
5# Allow direct execution
cb252080 6import io
14719565
JMF
7import os
8import sys
9import unittest
10sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11
95e42d73 12from test.helper import FakeYDL, expect_dict, expect_value, http_server_port
cefecac1
U
13from youtube_dlc.compat import compat_etree_fromstring, compat_http_server
14from youtube_dlc.extractor.common import InfoExtractor
15from youtube_dlc.extractor import YoutubeIE, get_info_extractor
16from youtube_dlc.utils import encode_data_uri, strip_jsonp, ExtractorError, RegexNotFoundError
95e42d73
XDG
17import threading
18
19
20TEAPOT_RESPONSE_STATUS = 418
21TEAPOT_RESPONSE_BODY = "<h1>418 I'm a teapot</h1>"
22
23
24class InfoExtractorTestRequestHandler(compat_http_server.BaseHTTPRequestHandler):
25 def log_message(self, format, *args):
26 pass
27
28 def do_GET(self):
29 if self.path == '/teapot':
30 self.send_response(TEAPOT_RESPONSE_STATUS)
31 self.send_header('Content-Type', 'text/html; charset=utf-8')
32 self.end_headers()
33 self.wfile.write(TEAPOT_RESPONSE_BODY.encode())
34 else:
35 assert False
14719565
JMF
36
37
38class TestIE(InfoExtractor):
39 pass
40
41
42class TestInfoExtractor(unittest.TestCase):
43 def setUp(self):
44 self.ie = TestIE(FakeYDL())
45
46 def test_ie_key(self):
47 self.assertEqual(get_info_extractor(YoutubeIE.ie_key()), YoutubeIE)
48
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')
53
54 def test_opengraph(self):
55 ie = self.ie
56 html = '''
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&amp;key2=val2'/>
1c29e81e 60 <meta content='application/x-shockwave-flash' property='og:video:type'>
db0a8ad9 61 <meta content='Foo' property=og:foobar>
448ef1f3
S
62 <meta name="og:test1" content='foo > < bar'/>
63 <meta name="og:test2" content="foo >//< bar"/>
22f5f5c6 64 <meta property=og-test3 content='Ill-formatted opengraph'/>
14719565
JMF
65 '''
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')
1c29e81e 69 self.assertEqual(ie._og_search_video_url(html, default=None), None)
db0a8ad9 70 self.assertEqual(ie._og_search_property('foobar', html), 'Foo')
448ef1f3
S
71 self.assertEqual(ie._og_search_property('test1', html), 'foo > < bar')
72 self.assertEqual(ie._og_search_property('test2', html), 'foo >//< bar')
22f5f5c6 73 self.assertEqual(ie._og_search_property('test3', html), 'Ill-formatted opengraph')
b070564e
S
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)
14719565 77
bec22481
PH
78 def test_html_search_meta(self):
79 ie = self.ie
80 html = '''
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">
87 '''
88
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')
88d9f6c0
S
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)
bec22481 100
29f7c58a 101 def test_search_json_ld_realworld(self):
102 # https://github.com/ytdl-org/youtube-dl/issues/23306
103 expect_dict(
104 self,
105 self.ie._search_json_ld(r'''<script type="application/ld+json">
106{
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",
116"width": "1920",
117"height": "1080",
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",
129"ratingValue": "88",
130"ratingCount": "630",
131"bestRating": "100",
132"worstRating": "0"
133}, "actor": [{
134"@type": "Person",
135"name": "Kleio Valentien",
136"url": "https://www.eporner.com/pornstar/kleio-valentien/"
137}]}
138</script>''', None),
139 {
140 'title': '1 On 1 With Kleio',
141 'description': 'Kleio Valentien',
142 'url': 'https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4',
143 'timestamp': 1449347075,
144 'duration': 743.0,
145 'view_count': 1120958,
146 'width': 1920,
147 'height': 1080,
148 })
149
6a801f44
JMF
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)
158
d493f15c 159 def test_parse_html5_media_entries(self):
29f7c58a 160 # inline video tag
161 expect_dict(
162 self,
163 self.ie._parse_html5_media_entries(
164 'https://127.0.0.1/video.html',
165 r'<html><video src="/vid.mp4" /></html>', None)[0],
166 {
167 'formats': [{
168 'url': 'https://127.0.0.1/vid.mp4',
169 }],
170 })
171
d493f15c
S
172 # from https://www.r18.com/
173 # with kpbs in label
174 expect_dict(
175 self,
176 self.ie._parse_html5_media_entries(
177 'https://www.r18.com/',
178 r'''
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>
184 </video>
185 ''', None)[0],
186 {
187 'formats': [{
188 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4',
189 'ext': 'mp4',
190 'format_id': '300kbps',
191 'height': 240,
192 'tbr': 300,
193 }, {
194 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4',
195 'ext': 'mp4',
196 'format_id': '1000kbps',
197 'height': 480,
198 'tbr': 1000,
199 }, {
200 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4',
201 'ext': 'mp4',
202 'format_id': '1500kbps',
203 'height': 740,
204 'tbr': 1500,
205 }],
206 'thumbnail': '//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg'
207 })
208
209 # from https://www.csfd.cz/
210 # with width and height
211 expect_dict(
212 self,
213 self.ie._parse_html5_media_entries(
214 'https://www.csfd.cz/',
215 r'''
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">
224 </video>
225 ''', None)[0],
226 {
227 'formats': [{
228 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4',
229 'ext': 'mp4',
230 'width': 640,
231 'height': 360,
232 }, {
233 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4',
234 'ext': 'mp4',
235 'width': 1280,
236 'height': 720,
237 }, {
238 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4',
239 'ext': 'mp4',
240 'width': 1920,
241 'height': 1080,
242 }, {
243 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm',
244 'ext': 'webm',
245 'width': 640,
246 'height': 360,
247 }, {
248 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm',
249 'ext': 'webm',
250 'width': 1280,
251 'height': 720,
252 }, {
253 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm',
254 'ext': 'webm',
255 'width': 1920,
256 'height': 1080,
257 }],
258 'subtitles': {
259 'cs': [{'url': 'https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt'}]
260 },
261 'thumbnail': 'https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360'
262 })
263
264 # from https://tamasha.com/v/Kkdjw
265 # with height in label
266 expect_dict(
267 self,
268 self.ie._parse_html5_media_entries(
269 'https://tamasha.com/v/Kkdjw',
270 r'''
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"/>
277 </video>
278 ''', None)[0],
279 {
280 'formats': [{
281 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
282 }, {
283 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
284 'ext': 'mp4',
285 'format_id': '240p',
286 'height': 240,
287 }, {
288 'url': 'https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4',
289 'ext': 'mp4',
290 'format_id': '144p',
291 'height': 144,
292 }]
293 })
294
295 # from https://www.directvnow.com
296 # with data-src
297 expect_dict(
298 self,
299 self.ie._parse_html5_media_entries(
300 'https://www.directvnow.com',
301 r'''
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" />
304 </video>
305 ''', None)[0],
306 {
307 'formats': [{
308 'ext': 'mp4',
309 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
310 }]
311 })
312
313 # from https://www.directvnow.com
314 # with data-src
315 expect_dict(
316 self,
317 self.ie._parse_html5_media_entries(
318 'https://www.directvnow.com',
319 r'''
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" />
322 </video>
323 ''', None)[0],
324 {
325 'formats': [{
326 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
327 'ext': 'mp4',
328 }]
329 })
330
331 # from https://www.klarna.com/uk/
332 # with data-video-src
333 expect_dict(
334 self,
335 self.ie._parse_html5_media_entries(
336 'https://www.directvnow.com',
337 r'''
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" />
340 </video>
341 ''', None)[0],
342 {
343 'formats': [{
344 'url': 'https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4',
345 'ext': 'mp4',
346 }],
347 })
348
7f3590c4
S
349 def test_extract_jwplayer_data_realworld(self):
350 # from http://www.suffolk.edu/sjc/
351 expect_dict(
352 self,
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',
357 fallback: 'true',
358 width: '95%',
359 aspectratio: '16:9',
360 primary: 'flash',
361 mediaid:'XEgvuql4'
362 });
363 </script>
364 ''', None, require_title=False),
365 {
366 'id': 'XEgvuql4',
367 'formats': [{
368 'url': 'rtmp://192.138.214.154/live/sjclive',
369 'ext': 'flv'
370 }]
371 })
372
373 # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/
374 expect_dict(
375 self,
376 self.ie._extract_jwplayer_data(r'''
377<script type="text/javascript">
378 jwplayer("mediaplayer").setup({
379 'videoid': "7564",
380 'width': "100%",
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",
388 'logo.hide': true,
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',
393 'modes': [
394 {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'}
395 ],
396 'provider': 'http'
397 });
398 //noinspection JSAnnotator
399 invideo.setup({
400 adsUrl: "/banner-iframe/?zoneId=32",
401 adsUrl2: "",
402 autostart: false
403 });
404</script>
405 ''', 'dummy', require_title=False),
406 {
407 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg',
408 'formats': [{
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',
410 'ext': 'flv'
411 }]
412 })
413
414 # from http://www.indiedb.com/games/king-machine/videos
415 expect_dict(
416 self,
417 self.ie._extract_jwplayer_data(r'''
418<script>
419jwplayer("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");
423});
424</script>
425 ''', 'dummy'),
426 {
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',
429 'formats': [{
430 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4',
431 'height': 360,
432 'ext': 'mp4'
433 }, {
434 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4',
435 'height': 720,
436 'ext': 'mp4'
437 }]
438 })
439
cb252080
S
440 def test_parse_m3u8_formats(self):
441 _TEST_CASES = [
442 (
067aa17e 443 # https://github.com/ytdl-org/youtube-dl/issues/11507
cb252080
S
444 # http://pluzz.francetv.fr/videos/le_ministere.html
445 'pluzz_francetv_11507',
446 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
447 [{
cb252080 448 'url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/index_0_av.m3u8?null=0',
30bb6ce1 449 'manifest_url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
cb252080
S
450 'ext': 'mp4',
451 'format_id': '180',
452 'protocol': 'm3u8',
453 'acodec': 'mp4a.40.2',
454 'vcodec': 'avc1.66.30',
455 'tbr': 180,
456 'width': 256,
457 'height': 144,
458 }, {
459 'url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/index_1_av.m3u8?null=0',
30bb6ce1 460 'manifest_url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
cb252080
S
461 'ext': 'mp4',
462 'format_id': '303',
463 'protocol': 'm3u8',
464 'acodec': 'mp4a.40.2',
465 'vcodec': 'avc1.66.30',
466 'tbr': 303,
467 'width': 320,
468 'height': 180,
469 }, {
470 'url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/index_2_av.m3u8?null=0',
30bb6ce1 471 'manifest_url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
cb252080
S
472 'ext': 'mp4',
473 'format_id': '575',
474 'protocol': 'm3u8',
475 'acodec': 'mp4a.40.2',
476 'vcodec': 'avc1.66.30',
477 'tbr': 575,
478 'width': 512,
479 'height': 288,
480 }, {
481 'url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/index_3_av.m3u8?null=0',
30bb6ce1 482 'manifest_url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
cb252080
S
483 'ext': 'mp4',
484 'format_id': '831',
485 'protocol': 'm3u8',
486 'acodec': 'mp4a.40.2',
487 'vcodec': 'avc1.77.30',
488 'tbr': 831,
489 'width': 704,
490 'height': 396,
491 }, {
492 'url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/index_4_av.m3u8?null=0',
30bb6ce1 493 'manifest_url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
cb252080
S
494 'ext': 'mp4',
495 'protocol': 'm3u8',
496 'format_id': '1467',
497 'acodec': 'mp4a.40.2',
498 'vcodec': 'avc1.77.30',
499 'tbr': 1467,
500 'width': 1024,
501 'height': 576,
502 }]
503 ),
504 (
067aa17e 505 # https://github.com/ytdl-org/youtube-dl/issues/11995
cb252080
S
506 # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor
507 'teamcoco_11995',
508 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
509 [{
cb252080 510 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-audio-160k_v4.m3u8',
30bb6ce1 511 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
cb252080
S
512 'ext': 'mp4',
513 'format_id': 'audio-0-Default',
514 'protocol': 'm3u8',
515 'vcodec': 'none',
516 }, {
517 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-audio-64k_v4.m3u8',
30bb6ce1 518 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
cb252080
S
519 'ext': 'mp4',
520 'format_id': 'audio-1-Default',
521 'protocol': 'm3u8',
522 'vcodec': 'none',
523 }, {
524 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-audio-64k_v4.m3u8',
30bb6ce1 525 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
cb252080
S
526 'ext': 'mp4',
527 'format_id': '71',
528 'protocol': 'm3u8',
529 'acodec': 'mp4a.40.5',
530 'vcodec': 'none',
531 'tbr': 71,
532 }, {
533 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-400k_v4.m3u8',
30bb6ce1 534 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
cb252080
S
535 'ext': 'mp4',
536 'format_id': '413',
537 'protocol': 'm3u8',
538 'acodec': 'none',
539 'vcodec': 'avc1.42001e',
540 'tbr': 413,
541 'width': 400,
542 'height': 224,
543 }, {
544 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-400k_v4.m3u8',
30bb6ce1 545 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
cb252080
S
546 'ext': 'mp4',
547 'format_id': '522',
548 'protocol': 'm3u8',
549 'acodec': 'none',
550 'vcodec': 'avc1.42001e',
551 'tbr': 522,
552 'width': 400,
553 'height': 224,
554 }, {
555 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-1m_v4.m3u8',
30bb6ce1 556 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
cb252080
S
557 'ext': 'mp4',
558 'format_id': '1205',
559 'protocol': 'm3u8',
560 'acodec': 'none',
561 'vcodec': 'avc1.4d001e',
562 'tbr': 1205,
563 'width': 640,
564 'height': 360,
565 }, {
566 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-2m_v4.m3u8',
30bb6ce1 567 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
cb252080
S
568 'ext': 'mp4',
569 'format_id': '2374',
570 'protocol': 'm3u8',
571 'acodec': 'none',
572 'vcodec': 'avc1.4d001f',
573 'tbr': 2374,
574 'width': 1024,
575 'height': 576,
576 }]
577 ),
578 (
067aa17e 579 # https://github.com/ytdl-org/youtube-dl/issues/12211
cb252080
S
580 # http://video.toggle.sg/en/series/whoopie-s-world/ep3/478601
581 'toggle_mobile_12211',
582 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
583 [{
cb252080 584 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/2/pv/1/flavorId/0_sa2ntrdg/name/a.mp4/index.m3u8',
30bb6ce1 585 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
cb252080
S
586 'ext': 'mp4',
587 'format_id': 'audio-English',
588 'protocol': 'm3u8',
589 'language': 'eng',
590 'vcodec': 'none',
591 }, {
592 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/2/pv/1/flavorId/0_r7y0nitg/name/a.mp4/index.m3u8',
30bb6ce1 593 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
cb252080
S
594 'ext': 'mp4',
595 'format_id': 'audio-Undefined',
596 'protocol': 'm3u8',
597 'language': 'und',
598 'vcodec': 'none',
599 }, {
600 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/2/pv/1/flavorId/0_qlk9hlzr/name/a.mp4/index.m3u8',
30bb6ce1 601 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
cb252080
S
602 'ext': 'mp4',
603 'format_id': '155',
604 'protocol': 'm3u8',
ddd258f9 605 'tbr': 155.648,
cb252080
S
606 'width': 320,
607 'height': 180,
608 }, {
609 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/2/pv/1/flavorId/0_oefackmi/name/a.mp4/index.m3u8',
30bb6ce1 610 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
cb252080
S
611 'ext': 'mp4',
612 'format_id': '502',
613 'protocol': 'm3u8',
ddd258f9 614 'tbr': 502.784,
cb252080
S
615 'width': 480,
616 'height': 270,
617 }, {
618 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/12/pv/1/flavorId/0_vyg9pj7k/name/a.mp4/index.m3u8',
30bb6ce1 619 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
cb252080
S
620 'ext': 'mp4',
621 'format_id': '827',
622 'protocol': 'm3u8',
ddd258f9 623 'tbr': 827.392,
cb252080
S
624 'width': 640,
625 'height': 360,
626 }, {
627 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/12/pv/1/flavorId/0_50n4psvx/name/a.mp4/index.m3u8',
30bb6ce1 628 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
cb252080
S
629 'ext': 'mp4',
630 'format_id': '1396',
631 'protocol': 'm3u8',
ddd258f9 632 'tbr': 1396.736,
cb252080
S
633 'width': 854,
634 'height': 480,
635 }]
636 ),
637 (
638 # http://www.twitch.tv/riotgames/v/6528877
639 'twitch_vod',
640 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
641 [{
cb252080 642 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/audio_only/index-muted-HM49I092CC.m3u8',
30bb6ce1 643 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
cb252080
S
644 'ext': 'mp4',
645 'format_id': 'Audio Only',
646 'protocol': 'm3u8',
647 'acodec': 'mp4a.40.2',
648 'vcodec': 'none',
ddd258f9 649 'tbr': 182.725,
cb252080
S
650 }, {
651 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/mobile/index-muted-HM49I092CC.m3u8',
30bb6ce1 652 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
cb252080
S
653 'ext': 'mp4',
654 'format_id': 'Mobile',
655 'protocol': 'm3u8',
656 'acodec': 'mp4a.40.2',
657 'vcodec': 'avc1.42C00D',
ddd258f9 658 'tbr': 280.474,
cb252080
S
659 'width': 400,
660 'height': 226,
661 }, {
662 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/low/index-muted-HM49I092CC.m3u8',
30bb6ce1 663 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
cb252080
S
664 'ext': 'mp4',
665 'format_id': 'Low',
666 'protocol': 'm3u8',
667 'acodec': 'mp4a.40.2',
668 'vcodec': 'avc1.42C01E',
ddd258f9 669 'tbr': 628.347,
cb252080
S
670 'width': 640,
671 'height': 360,
672 }, {
673 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/medium/index-muted-HM49I092CC.m3u8',
30bb6ce1 674 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
cb252080
S
675 'ext': 'mp4',
676 'format_id': 'Medium',
677 'protocol': 'm3u8',
678 'acodec': 'mp4a.40.2',
679 'vcodec': 'avc1.42C01E',
ddd258f9 680 'tbr': 893.387,
cb252080
S
681 'width': 852,
682 'height': 480,
683 }, {
684 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/high/index-muted-HM49I092CC.m3u8',
30bb6ce1 685 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
cb252080
S
686 'ext': 'mp4',
687 'format_id': 'High',
688 'protocol': 'm3u8',
689 'acodec': 'mp4a.40.2',
690 'vcodec': 'avc1.42C01F',
ddd258f9 691 'tbr': 1603.789,
cb252080
S
692 'width': 1280,
693 'height': 720,
694 }, {
695 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/chunked/index-muted-HM49I092CC.m3u8',
30bb6ce1 696 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
cb252080
S
697 'ext': 'mp4',
698 'format_id': 'Source',
699 'protocol': 'm3u8',
700 'acodec': 'mp4a.40.2',
701 'vcodec': 'avc1.100.31',
ddd258f9
S
702 'tbr': 3214.134,
703 'width': 1280,
704 'height': 720,
705 }]
706 ),
707 (
708 # http://www.vidio.com/watch/165683-dj_ambred-booyah-live-2015
709 # EXT-X-STREAM-INF tag with NAME attribute that is not defined
710 # in HLS specification
711 'vidio',
712 'https://www.vidio.com/videos/165683/playlist.m3u8',
713 [{
ddd258f9 714 'url': 'https://cdn1-a.production.vidio.static6.com/uploads/165683/dj_ambred-4383-b300.mp4.m3u8',
30bb6ce1 715 'manifest_url': 'https://www.vidio.com/videos/165683/playlist.m3u8',
ddd258f9
S
716 'ext': 'mp4',
717 'format_id': '270p 3G',
718 'protocol': 'm3u8',
719 'tbr': 300,
720 'width': 480,
721 'height': 270,
722 }, {
723 'url': 'https://cdn1-a.production.vidio.static6.com/uploads/165683/dj_ambred-4383-b600.mp4.m3u8',
30bb6ce1 724 'manifest_url': 'https://www.vidio.com/videos/165683/playlist.m3u8',
ddd258f9
S
725 'ext': 'mp4',
726 'format_id': '360p SD',
727 'protocol': 'm3u8',
728 'tbr': 600,
729 'width': 640,
730 'height': 360,
731 }, {
732 'url': 'https://cdn1-a.production.vidio.static6.com/uploads/165683/dj_ambred-4383-b1200.mp4.m3u8',
30bb6ce1 733 'manifest_url': 'https://www.vidio.com/videos/165683/playlist.m3u8',
ddd258f9
S
734 'ext': 'mp4',
735 'format_id': '720p HD',
736 'protocol': 'm3u8',
737 'tbr': 1200,
cb252080
S
738 'width': 1280,
739 'height': 720,
740 }]
fc746c3f
RA
741 ),
742 (
067aa17e 743 # https://github.com/ytdl-org/youtube-dl/issues/18923
fc746c3f
RA
744 # https://www.ted.com/talks/boris_hesser_a_grassroots_healthcare_revolution_in_africa
745 'ted_18923',
746 'http://hls.ted.com/talks/31241.m3u8',
747 [{
748 'url': 'http://hls.ted.com/videos/BorisHesser_2018S/audio/600k.m3u8?nobumpers=true&uniqueId=76011e2b',
749 'format_id': '600k-Audio',
750 'vcodec': 'none',
751 }, {
752 'url': 'http://hls.ted.com/videos/BorisHesser_2018S/audio/600k.m3u8?nobumpers=true&uniqueId=76011e2b',
753 'format_id': '68',
754 'vcodec': 'none',
755 }, {
756 'url': 'http://hls.ted.com/videos/BorisHesser_2018S/video/64k.m3u8?nobumpers=true&uniqueId=76011e2b',
757 'format_id': '163',
758 'acodec': 'none',
759 'width': 320,
760 'height': 180,
761 }, {
762 'url': 'http://hls.ted.com/videos/BorisHesser_2018S/video/180k.m3u8?nobumpers=true&uniqueId=76011e2b',
763 'format_id': '481',
764 'acodec': 'none',
765 'width': 512,
766 'height': 288,
767 }, {
768 'url': 'http://hls.ted.com/videos/BorisHesser_2018S/video/320k.m3u8?nobumpers=true&uniqueId=76011e2b',
769 'format_id': '769',
770 'acodec': 'none',
771 'width': 512,
772 'height': 288,
773 }, {
774 'url': 'http://hls.ted.com/videos/BorisHesser_2018S/video/450k.m3u8?nobumpers=true&uniqueId=76011e2b',
775 'format_id': '984',
776 'acodec': 'none',
777 'width': 512,
778 'height': 288,
779 }, {
780 'url': 'http://hls.ted.com/videos/BorisHesser_2018S/video/600k.m3u8?nobumpers=true&uniqueId=76011e2b',
781 'format_id': '1255',
782 'acodec': 'none',
783 'width': 640,
784 'height': 360,
785 }, {
786 'url': 'http://hls.ted.com/videos/BorisHesser_2018S/video/950k.m3u8?nobumpers=true&uniqueId=76011e2b',
787 'format_id': '1693',
788 'acodec': 'none',
789 'width': 853,
790 'height': 480,
791 }, {
792 'url': 'http://hls.ted.com/videos/BorisHesser_2018S/video/1500k.m3u8?nobumpers=true&uniqueId=76011e2b',
793 'format_id': '2462',
794 'acodec': 'none',
795 'width': 1280,
796 'height': 720,
797 }]
798 ),
cb252080
S
799 ]
800
801 for m3u8_file, m3u8_url, expected_formats in _TEST_CASES:
802 with io.open('./test/testdata/m3u8/%s.m3u8' % m3u8_file,
803 mode='r', encoding='utf-8') as f:
804 formats = self.ie._parse_m3u8_formats(
805 f.read(), m3u8_url, ext='mp4')
806 self.ie._sort_formats(formats)
807 expect_value(self, formats, expected_formats, None)
808
48504785
S
809 def test_parse_mpd_formats(self):
810 _TEST_CASES = [
811 (
067aa17e 812 # https://github.com/ytdl-org/youtube-dl/issues/13919
9d6ac71c 813 # Also tests duplicate representation ids, see
067aa17e 814 # https://github.com/ytdl-org/youtube-dl/issues/15111
48504785 815 'float_duration',
2e27421c
S
816 'http://unknown/manifest.mpd', # mpd_url
817 None, # mpd_base_url
48504785 818 [{
9d6ac71c
S
819 'manifest_url': 'http://unknown/manifest.mpd',
820 'ext': 'm4a',
821 'format_id': '318597',
822 'format_note': 'DASH audio',
823 'protocol': 'http_dash_segments',
824 'acodec': 'mp4a.40.2',
825 'vcodec': 'none',
826 'tbr': 61.587,
827 }, {
48504785
S
828 'manifest_url': 'http://unknown/manifest.mpd',
829 'ext': 'mp4',
830 'format_id': '318597',
831 'format_note': 'DASH video',
832 'protocol': 'http_dash_segments',
833 'acodec': 'none',
834 'vcodec': 'avc1.42001f',
835 'tbr': 318.597,
836 'width': 340,
837 'height': 192,
838 }, {
839 'manifest_url': 'http://unknown/manifest.mpd',
840 'ext': 'mp4',
841 'format_id': '638590',
842 'format_note': 'DASH video',
843 'protocol': 'http_dash_segments',
844 'acodec': 'none',
845 'vcodec': 'avc1.42001f',
846 'tbr': 638.59,
847 'width': 512,
848 'height': 288,
849 }, {
850 'manifest_url': 'http://unknown/manifest.mpd',
851 'ext': 'mp4',
852 'format_id': '1022565',
853 'format_note': 'DASH video',
854 'protocol': 'http_dash_segments',
855 'acodec': 'none',
856 'vcodec': 'avc1.4d001f',
857 'tbr': 1022.565,
858 'width': 688,
859 'height': 384,
860 }, {
861 'manifest_url': 'http://unknown/manifest.mpd',
862 'ext': 'mp4',
863 'format_id': '2046506',
864 'format_note': 'DASH video',
865 'protocol': 'http_dash_segments',
866 'acodec': 'none',
867 'vcodec': 'avc1.4d001f',
868 'tbr': 2046.506,
869 'width': 1024,
870 'height': 576,
871 }, {
872 'manifest_url': 'http://unknown/manifest.mpd',
873 'ext': 'mp4',
874 'format_id': '3998017',
875 'format_note': 'DASH video',
876 'protocol': 'http_dash_segments',
877 'acodec': 'none',
878 'vcodec': 'avc1.640029',
879 'tbr': 3998.017,
880 'width': 1280,
881 'height': 720,
882 }, {
883 'manifest_url': 'http://unknown/manifest.mpd',
884 'ext': 'mp4',
885 'format_id': '5997485',
886 'format_note': 'DASH video',
887 'protocol': 'http_dash_segments',
888 'acodec': 'none',
889 'vcodec': 'avc1.640032',
890 'tbr': 5997.485,
891 'width': 1920,
892 'height': 1080,
893 }]
41bf647e 894 ), (
067aa17e 895 # https://github.com/ytdl-org/youtube-dl/pull/14844
41bf647e 896 'urls_only',
2e27421c
S
897 'http://unknown/manifest.mpd', # mpd_url
898 None, # mpd_base_url
41bf647e
PN
899 [{
900 'manifest_url': 'http://unknown/manifest.mpd',
901 'ext': 'mp4',
902 'format_id': 'h264_aac_144p_m4s',
903 'format_note': 'DASH video',
904 'protocol': 'http_dash_segments',
905 'acodec': 'mp4a.40.2',
906 'vcodec': 'avc3.42c01e',
907 'tbr': 200,
908 'width': 256,
909 'height': 144,
910 }, {
911 'manifest_url': 'http://unknown/manifest.mpd',
912 'ext': 'mp4',
913 'format_id': 'h264_aac_240p_m4s',
914 'format_note': 'DASH video',
915 'protocol': 'http_dash_segments',
916 'acodec': 'mp4a.40.2',
917 'vcodec': 'avc3.42c01e',
918 'tbr': 400,
919 'width': 424,
920 'height': 240,
921 }, {
922 'manifest_url': 'http://unknown/manifest.mpd',
923 'ext': 'mp4',
924 'format_id': 'h264_aac_360p_m4s',
925 'format_note': 'DASH video',
926 'protocol': 'http_dash_segments',
927 'acodec': 'mp4a.40.2',
928 'vcodec': 'avc3.42c01e',
929 'tbr': 800,
930 'width': 640,
931 'height': 360,
932 }, {
933 'manifest_url': 'http://unknown/manifest.mpd',
934 'ext': 'mp4',
935 'format_id': 'h264_aac_480p_m4s',
936 'format_note': 'DASH video',
937 'protocol': 'http_dash_segments',
938 'acodec': 'mp4a.40.2',
939 'vcodec': 'avc3.42c01e',
940 'tbr': 1200,
941 'width': 856,
942 'height': 480,
943 }, {
944 'manifest_url': 'http://unknown/manifest.mpd',
945 'ext': 'mp4',
946 'format_id': 'h264_aac_576p_m4s',
947 'format_note': 'DASH video',
948 'protocol': 'http_dash_segments',
949 'acodec': 'mp4a.40.2',
950 'vcodec': 'avc3.42c01e',
951 'tbr': 1600,
952 'width': 1024,
953 'height': 576,
954 }, {
955 'manifest_url': 'http://unknown/manifest.mpd',
956 'ext': 'mp4',
957 'format_id': 'h264_aac_720p_m4s',
958 'format_note': 'DASH video',
959 'protocol': 'http_dash_segments',
960 'acodec': 'mp4a.40.2',
961 'vcodec': 'avc3.42c01e',
962 'tbr': 2400,
963 'width': 1280,
964 'height': 720,
965 }, {
966 'manifest_url': 'http://unknown/manifest.mpd',
967 'ext': 'mp4',
968 'format_id': 'h264_aac_1080p_m4s',
969 'format_note': 'DASH video',
970 'protocol': 'http_dash_segments',
971 'acodec': 'mp4a.40.2',
972 'vcodec': 'avc3.42c01e',
973 'tbr': 4400,
974 'width': 1920,
975 'height': 1080,
976 }]
2e27421c
S
977 ), (
978 # https://github.com/ytdl-org/youtube-dl/issues/20346
979 # Media considered unfragmented even though it contains
980 # Initialization tag
981 'unfragmented',
982 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', # mpd_url
983 'https://v.redd.it/hw1x7rcg7zl21', # mpd_base_url
984 [{
985 'url': 'https://v.redd.it/hw1x7rcg7zl21/audio',
986 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
987 'ext': 'm4a',
988 'format_id': 'AUDIO-1',
989 'format_note': 'DASH audio',
990 'container': 'm4a_dash',
991 'acodec': 'mp4a.40.2',
992 'vcodec': 'none',
993 'tbr': 129.87,
994 'asr': 48000,
995
996 }, {
997 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240',
998 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
999 'ext': 'mp4',
1000 'format_id': 'VIDEO-2',
1001 'format_note': 'DASH video',
1002 'container': 'mp4_dash',
1003 'acodec': 'none',
1004 'vcodec': 'avc1.4d401e',
1005 'tbr': 608.0,
1006 'width': 240,
1007 'height': 240,
1008 'fps': 30,
1009 }, {
1010 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_360',
1011 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1012 'ext': 'mp4',
1013 'format_id': 'VIDEO-1',
1014 'format_note': 'DASH video',
1015 'container': 'mp4_dash',
1016 'acodec': 'none',
1017 'vcodec': 'avc1.4d401e',
1018 'tbr': 804.261,
1019 'width': 360,
1020 'height': 360,
1021 'fps': 30,
1022 }]
41bf647e 1023 )
48504785
S
1024 ]
1025
2e27421c 1026 for mpd_file, mpd_url, mpd_base_url, expected_formats in _TEST_CASES:
48504785
S
1027 with io.open('./test/testdata/mpd/%s.mpd' % mpd_file,
1028 mode='r', encoding='utf-8') as f:
1029 formats = self.ie._parse_mpd_formats(
1030 compat_etree_fromstring(f.read().encode('utf-8')),
2e27421c 1031 mpd_base_url=mpd_base_url, mpd_url=mpd_url)
48504785
S
1032 self.ie._sort_formats(formats)
1033 expect_value(self, formats, expected_formats, None)
1034
181e381f
S
1035 def test_parse_f4m_formats(self):
1036 _TEST_CASES = [
1037 (
067aa17e 1038 # https://github.com/ytdl-org/youtube-dl/issues/14660
181e381f
S
1039 'custom_base_url',
1040 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1041 [{
1042 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1043 'ext': 'flv',
1044 'format_id': '2148',
1045 'protocol': 'f4m',
1046 'tbr': 2148,
1047 'width': 1280,
1048 'height': 720,
1049 }]
1050 ),
1051 ]
1052
1053 for f4m_file, f4m_url, expected_formats in _TEST_CASES:
1054 with io.open('./test/testdata/f4m/%s.f4m' % f4m_file,
1055 mode='r', encoding='utf-8') as f:
1056 formats = self.ie._parse_f4m_formats(
1057 compat_etree_fromstring(f.read().encode('utf-8')),
1058 f4m_url, None)
1059 self.ie._sort_formats(formats)
1060 expect_value(self, formats, expected_formats, None)
582be358 1061
96b8b9ab
RC
1062 def test_parse_xspf(self):
1063 _TEST_CASES = [
1064 (
1065 'foo_xspf',
47a5cb77 1066 'https://example.org/src/foo_xspf.xspf',
96b8b9ab 1067 [{
47a5cb77
S
1068 'id': 'foo_xspf',
1069 'title': 'Pandemonium',
96b8b9ab
RC
1070 'description': 'Visit http://bigbrother404.bandcamp.com',
1071 'duration': 202.416,
47a5cb77
S
1072 'formats': [{
1073 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1074 'url': 'https://example.org/src/cd1/track%201.mp3',
1075 }],
1076 }, {
96b8b9ab 1077 'id': 'foo_xspf',
47a5cb77 1078 'title': 'Final Cartridge (Nichico Twelve Remix)',
96b8b9ab
RC
1079 'description': 'Visit http://bigbrother404.bandcamp.com',
1080 'duration': 255.857,
47a5cb77
S
1081 'formats': [{
1082 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1083 'url': 'https://example.org/%E3%83%88%E3%83%A9%E3%83%83%E3%82%AF%E3%80%80%EF%BC%92.mp3',
1084 }],
1085 }, {
96b8b9ab 1086 'id': 'foo_xspf',
47a5cb77 1087 'title': 'Rebuilding Nightingale',
96b8b9ab
RC
1088 'description': 'Visit http://bigbrother404.bandcamp.com',
1089 'duration': 287.915,
47a5cb77
S
1090 'formats': [{
1091 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1092 'url': 'https://example.org/src/track3.mp3',
1093 }, {
1094 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1095 'url': 'https://example.com/track3.mp3',
1096 }]
96b8b9ab
RC
1097 }]
1098 ),
1099 ]
1100
47a5cb77 1101 for xspf_file, xspf_url, expected_entries in _TEST_CASES:
96b8b9ab
RC
1102 with io.open('./test/testdata/xspf/%s.xspf' % xspf_file,
1103 mode='r', encoding='utf-8') as f:
1104 entries = self.ie._parse_xspf(
1105 compat_etree_fromstring(f.read().encode('utf-8')),
47a5cb77 1106 xspf_file, xspf_url=xspf_url, xspf_base_url=xspf_url)
96b8b9ab
RC
1107 expect_value(self, entries, expected_entries, None)
1108 for i in range(len(entries)):
1109 expect_dict(self, entries[i], expected_entries[i])
1110
95e42d73
XDG
1111 def test_response_with_expected_status_returns_content(self):
1112 # Checks for mitigations against the effects of
1113 # <https://bugs.python.org/issue15002> that affect Python 3.4.1+, which
1114 # manifest as `_download_webpage`, `_download_xml`, `_download_json`,
1115 # or the underlying `_download_webpage_handle` returning no content
1116 # when a response matches `expected_status`.
1117
1118 httpd = compat_http_server.HTTPServer(
1119 ('127.0.0.1', 0), InfoExtractorTestRequestHandler)
1120 port = http_server_port(httpd)
1121 server_thread = threading.Thread(target=httpd.serve_forever)
1122 server_thread.daemon = True
1123 server_thread.start()
1124
1125 (content, urlh) = self.ie._download_webpage_handle(
1126 'http://127.0.0.1:%d/teapot' % port, None,
1127 expected_status=TEAPOT_RESPONSE_STATUS)
1128 self.assertEqual(content, TEAPOT_RESPONSE_BODY)
1129
f58a5060 1130
14719565
JMF
1131if __name__ == '__main__':
1132 unittest.main()