2 # Allow direct execution
7 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
10 from test
.helper
import FakeYDL
, expect_dict
, expect_value
, http_server_port
12 from yt_dlp
.compat
import compat_etree_fromstring
, compat_http_server
13 from yt_dlp
.extractor
import YoutubeIE
, get_info_extractor
14 from yt_dlp
.extractor
.common
import InfoExtractor
15 from yt_dlp
.utils
import (
22 TEAPOT_RESPONSE_STATUS
= 418
23 TEAPOT_RESPONSE_BODY
= "<h1>418 I'm a teapot</h1>"
26 class InfoExtractorTestRequestHandler(compat_http_server
.BaseHTTPRequestHandler
):
27 def log_message(self
, format
, *args
):
31 if self
.path
== '/teapot':
32 self
.send_response(TEAPOT_RESPONSE_STATUS
)
33 self
.send_header('Content-Type', 'text/html; charset=utf-8')
35 self
.wfile
.write(TEAPOT_RESPONSE_BODY
.encode())
40 class DummyIE(InfoExtractor
):
44 class TestInfoExtractor(unittest
.TestCase
):
46 self
.ie
= DummyIE(FakeYDL())
48 def test_ie_key(self
):
49 self
.assertEqual(get_info_extractor(YoutubeIE
.ie_key()), YoutubeIE
)
51 def test_html_search_regex(self
):
52 html
= '<p id="foo">Watch this <a href="http://www.youtube.com/watch?v=BaW_jenozKc">video</a></p>'
53 search
= lambda re
, *args
: self
.ie
._html
_search
_regex
(re
, html
, *args
)
54 self
.assertEqual(search(r
'<p id="foo">(.+?)</p>', 'foo'), 'Watch this video')
56 def test_opengraph(self
):
59 <meta name="og:title" content='Foo'/>
60 <meta content="Some video's description " name="og:description"/>
61 <meta property='og:image' content='http://domain.com/pic.jpg?key1=val1&key2=val2'/>
62 <meta content='application/x-shockwave-flash' property='og:video:type'>
63 <meta content='Foo' property=og:foobar>
64 <meta name="og:test1" content='foo > < bar'/>
65 <meta name="og:test2" content="foo >//< bar"/>
66 <meta property=og-test3 content='Ill-formatted opengraph'/>
68 self
.assertEqual(ie
._og
_search
_title
(html
), 'Foo')
69 self
.assertEqual(ie
._og
_search
_description
(html
), 'Some video\'s description ')
70 self
.assertEqual(ie
._og
_search
_thumbnail
(html
), 'http://domain.com/pic.jpg?key1=val1&key2=val2')
71 self
.assertEqual(ie
._og
_search
_video
_url
(html
, default
=None), None)
72 self
.assertEqual(ie
._og
_search
_property
('foobar', html
), 'Foo')
73 self
.assertEqual(ie
._og
_search
_property
('test1', html
), 'foo > < bar')
74 self
.assertEqual(ie
._og
_search
_property
('test2', html
), 'foo >//< bar')
75 self
.assertEqual(ie
._og
_search
_property
('test3', html
), 'Ill-formatted opengraph')
76 self
.assertEqual(ie
._og
_search
_property
(('test0', 'test1'), html
), 'foo > < bar')
77 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, 'test0', html
, None, fatal
=True)
78 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, ('test0', 'test00'), html
, None, fatal
=True)
80 def test_html_search_meta(self
):
83 <meta name="a" content="1" />
84 <meta name='b' content='2'>
85 <meta name="c" content='3'>
86 <meta name=d content='4'>
87 <meta property="e" content='5' >
88 <meta content="6" name="f">
91 self
.assertEqual(ie
._html
_search
_meta
('a', html
), '1')
92 self
.assertEqual(ie
._html
_search
_meta
('b', html
), '2')
93 self
.assertEqual(ie
._html
_search
_meta
('c', html
), '3')
94 self
.assertEqual(ie
._html
_search
_meta
('d', html
), '4')
95 self
.assertEqual(ie
._html
_search
_meta
('e', html
), '5')
96 self
.assertEqual(ie
._html
_search
_meta
('f', html
), '6')
97 self
.assertEqual(ie
._html
_search
_meta
(('a', 'b', 'c'), html
), '1')
98 self
.assertEqual(ie
._html
_search
_meta
(('c', 'b', 'a'), html
), '3')
99 self
.assertEqual(ie
._html
_search
_meta
(('z', 'x', 'c'), html
), '3')
100 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, 'z', html
, None, fatal
=True)
101 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, ('z', 'x'), html
, None, fatal
=True)
103 def test_search_json_ld_realworld(self
):
105 # https://github.com/ytdl-org/youtube-dl/issues/23306
107 r
'''<script type="application/ld+json">
109 "@context": "http://schema.org/",
110 "@type": "VideoObject",
111 "name": "1 On 1 With Kleio",
112 "url": "https://www.eporner.com/hd-porn/xN49A1cT3eB/1-On-1-With-Kleio/",
113 "duration": "PT0H12M23S",
114 "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"],
115 "contentUrl": "https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4",
116 "embedUrl": "https://www.eporner.com/embed/xN49A1cT3eB/1-On-1-With-Kleio/",
117 "image": "https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg",
120 "encodingFormat": "mp4",
121 "bitrate": "6617kbps",
122 "isFamilyFriendly": "False",
123 "description": "Kleio Valentien",
124 "uploadDate": "2015-12-05T21:24:35+01:00",
125 "interactionStatistic": {
126 "@type": "InteractionCounter",
127 "interactionType": { "@type": "http://schema.org/WatchAction" },
128 "userInteractionCount": 1120958
129 }, "aggregateRating": {
130 "@type": "AggregateRating",
132 "ratingCount": "630",
137 "name": "Kleio Valentien",
138 "url": "https://www.eporner.com/pornstar/kleio-valentien/"
142 'title': '1 On 1 With Kleio',
143 'description': 'Kleio Valentien',
144 'url': 'https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4',
145 'timestamp': 1449347075,
147 'view_count': 1120958,
154 r
'''<script type="application/ld+json">
156 "@context": "https://schema.org",
159 "@type": "NewsArticle",
160 "mainEntityOfPage": {
162 "@id": "https://www.ant1news.gr/Society/article/620286/symmoria-anilikon-dikigoros-thymaton-ithelan-na-toys-apoteleiosoyn"
164 "headline": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
165 "name": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
166 "description": "Τα παιδιά δέχθηκαν την επίθεση επειδή αρνήθηκαν να γίνουν μέλη της συμμορίας, ανέφερε ο Γ. Ζαχαρόπουλος.",
168 "@type": "ImageObject",
169 "url": "https://ant1media.azureedge.net/imgHandler/1100/a635c968-be71-447c-bf9c-80d843ece21e.jpg",
172 "datePublished": "2021-11-10T08:50:00+03:00",
173 "dateModified": "2021-11-10T08:52:53+03:00",
176 "@id": "https://www.ant1news.gr/",
178 "image": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
179 "url": "https://www.ant1news.gr/"
182 "@type": "Organization",
183 "@id": "https://www.ant1news.gr#publisher",
185 "url": "https://www.ant1news.gr",
187 "@type": "ImageObject",
188 "url": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
192 "https://www.facebook.com/Ant1news.gr",
193 "https://twitter.com/antennanews",
194 "https://www.youtube.com/channel/UC0smvAbfczoN75dP0Hw4Pzw",
195 "https://www.instagram.com/ant1news/"
199 "keywords": "μαχαίρωμα,συμμορία ανηλίκων,ΕΙΔΗΣΕΙΣ,ΕΙΔΗΣΕΙΣ ΣΗΜΕΡΑ,ΝΕΑ,Κοινωνία - Ant1news",
202 "articleSection": "Κοινωνία"
208 'timestamp': 1636523400,
209 'title': 'md5:91fe569e952e4d146485740ae927662b',
211 {'expected_type': 'NewsArticle'}
,
214 r
'''<script type="application/ld+json">
215 {"url":"/vrtnu/a-z/het-journaal/2021/het-journaal-het-journaal-19u-20211231/",
216 "name":"Het journaal 19u",
217 "description":"Het journaal 19u van vrijdag 31 december 2021.",
218 "potentialAction":{"url":"https://vrtnu.page.link/pfVy6ihgCAJKgHqe8","@type":"ShareAction"},
219 "mainEntityOfPage":{"@id":"1640092242445","@type":"WebPage"},
221 "startDate":"2021-12-31T19:00:00.000+01:00",
222 "endDate":"2022-01-30T23:55:00.000+01:00",
223 "publishedBy":{"name":"een","@type":"Organization"},
224 "publishedOn":{"url":"https://www.vrt.be/vrtnu/","name":"VRT NU","@type":"BroadcastService"},
225 "@id":"pbs-pub-3a7ec233-da95-4c1e-9b2b-cf5fdfebcbe8",
226 "@type":"BroadcastEvent"
229 "name":"Het journaal - Aflevering 365 (Seizoen 2021)",
230 "description":"Het journaal 19u van vrijdag 31 december 2021. Bekijk aflevering 365 van seizoen 2021 met VRT NU via de site of app.",
231 "thumbnailUrl":"//images.vrt.be/width1280/2021/12/31/80d5ed00-6a64-11ec-b07d-02b7b76bf47f.jpg",
232 "expires":"2022-01-30T23:55:00.000+01:00",
234 {"name":"Explosie Turnhout","startOffset":70,"@type":"Clip"},
235 {"name":"Jaarwisseling","startOffset":440,"@type":"Clip"},
236 {"name":"Natuurbranden Colorado","startOffset":1179,"@type":"Clip"},
237 {"name":"Klimaatverandering","startOffset":1263,"@type":"Clip"},
238 {"name":"Zacht weer","startOffset":1367,"@type":"Clip"},
239 {"name":"Financiële balans","startOffset":1383,"@type":"Clip"},
240 {"name":"Club Brugge","startOffset":1484,"@type":"Clip"},
241 {"name":"Mentale gezondheid bij topsporters","startOffset":1575,"@type":"Clip"},
242 {"name":"Olympische Winterspelen","startOffset":1728,"@type":"Clip"},
243 {"name":"Sober oudjaar in Nederland","startOffset":1873,"@type":"Clip"}
245 "duration":"PT34M39.23S",
246 "uploadDate":"2021-12-31T19:00:00.000+01:00",
247 "@id":"vid-9457d0c6-b8ac-4aba-b5e1-15aa3a3295b5",
248 "@type":"VideoObject"
250 "genre":["Nieuws en actua"],
252 "partOfSeries":{"name":"Het journaal","@id":"222831405527","@type":"TVSeries"},
253 "partOfSeason":{"name":"Seizoen 2021","@id":"961809365527","@type":"TVSeason"},
254 "@context":"https://schema.org","@id":"961685295527","@type":"TVEpisode"}</script>
258 {"title": "Explosie Turnhout", "start_time": 70, "end_time": 440}
,
259 {"title": "Jaarwisseling", "start_time": 440, "end_time": 1179}
,
260 {"title": "Natuurbranden Colorado", "start_time": 1179, "end_time": 1263}
,
261 {"title": "Klimaatverandering", "start_time": 1263, "end_time": 1367}
,
262 {"title": "Zacht weer", "start_time": 1367, "end_time": 1383}
,
263 {"title": "Financiële balans", "start_time": 1383, "end_time": 1484}
,
264 {"title": "Club Brugge", "start_time": 1484, "end_time": 1575}
,
265 {"title": "Mentale gezondheid bij topsporters", "start_time": 1575, "end_time": 1728}
,
266 {"title": "Olympische Winterspelen", "start_time": 1728, "end_time": 1873}
,
267 {"title": "Sober oudjaar in Nederland", "start_time": 1873, "end_time": 2079.23}
269 'title': 'Het journaal - Aflevering 365 (Seizoen 2021)'
273 # test multiple thumbnails in a list
275 <script type="application/ld+json">
276 {"@context":"https://schema.org",
277 "@type":"VideoObject",
278 "thumbnailUrl":["https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"]}
281 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}
],
286 # test single thumbnail
288 <script type="application/ld+json">
289 {"@context":"https://schema.org",
290 "@type":"VideoObject",
291 "thumbnailUrl":"https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"}
294 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}
],
299 for html
, expected_dict
, search_json_ld_kwargs
in _TESTS
:
302 self
.ie
._search
_json
_ld
(html
, None, **search_json_ld_kwargs
),
306 def test_download_json(self
):
307 uri
= encode_data_uri(b
'{"foo": "blah"}', 'application/json')
308 self
.assertEqual(self
.ie
._download
_json
(uri
, None), {'foo': 'blah'}
)
309 uri
= encode_data_uri(b
'callback({"foo": "blah"})', 'application/javascript')
310 self
.assertEqual(self
.ie
._download
_json
(uri
, None, transform_source
=strip_jsonp
), {'foo': 'blah'}
)
311 uri
= encode_data_uri(b
'{"foo": invalid}', 'application/json')
312 self
.assertRaises(ExtractorError
, self
.ie
._download
_json
, uri
, None)
313 self
.assertEqual(self
.ie
._download
_json
(uri
, None, fatal
=False), None)
315 def test_parse_html5_media_entries(self
):
319 self
.ie
._parse
_html
5_media
_entries
(
320 'https://127.0.0.1/video.html',
321 r
'<html><video src="/vid.mp4" /></html>', None)[0],
324 'url': 'https://127.0.0.1/vid.mp4',
328 # from https://www.r18.com/
332 self
.ie
._parse
_html
5_media
_entries
(
333 'https://www.r18.com/',
335 <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">
336 <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">
337 <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">
338 <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">
339 <p>Your browser does not support the video tag.</p>
344 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4',
346 'format_id': '300kbps',
350 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4',
352 'format_id': '1000kbps',
356 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4',
358 'format_id': '1500kbps',
362 'thumbnail': '//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg'
365 # from https://www.csfd.cz/
366 # with width and height
369 self
.ie
._parse
_html
5_media
_entries
(
370 'https://www.csfd.cz/',
372 <video width="770" height="328" preload="none" controls poster="https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360" >
373 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4" type="video/mp4" width="640" height="360">
374 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4" type="video/mp4" width="1280" height="720">
375 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4" type="video/mp4" width="1920" height="1080">
376 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm" type="video/webm" width="640" height="360">
377 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm" type="video/webm" width="1280" height="720">
378 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm" type="video/webm" width="1920" height="1080">
379 <track src="https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt" type="text/x-srt" kind="subtitles" srclang="cs" label="cs">
384 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4',
389 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4',
394 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4',
399 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm',
404 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm',
409 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm',
415 'cs': [{'url': 'https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt'}
]
417 'thumbnail': 'https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360'
420 # from https://tamasha.com/v/Kkdjw
421 # with height in label
424 self
.ie
._parse
_html
5_media
_entries
(
425 'https://tamasha.com/v/Kkdjw',
427 <video crossorigin="anonymous">
428 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4" label="AUTO" res="0"/>
429 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4"
430 label="240p" res="240"/>
431 <source src="https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4" type="video/mp4"
432 label="144p" res="144"/>
437 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
439 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
444 'url': 'https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4',
451 # from https://www.directvnow.com
455 self
.ie
._parse
_html
5_media
_entries
(
456 'https://www.directvnow.com',
458 <video id="vid1" class="header--video-masked active" muted playsinline>
459 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
465 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
469 # from https://www.directvnow.com
473 self
.ie
._parse
_html
5_media
_entries
(
474 'https://www.directvnow.com',
476 <video id="vid1" class="header--video-masked active" muted playsinline>
477 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
482 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
487 # from https://www.klarna.com/uk/
488 # with data-video-src
491 self
.ie
._parse
_html
5_media
_entries
(
492 'https://www.directvnow.com',
494 <video loop autoplay muted class="responsive-video block-kl__video video-on-medium">
495 <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" />
500 'url': 'https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4',
505 def test_extract_jwplayer_data_realworld(self
):
506 # from http://www.suffolk.edu/sjc/
509 self
.ie
._extract
_jwplayer
_data
(r
'''
510 <script type='text/javascript'>
511 jwplayer('my-video').setup({
512 file: 'rtmp://192.138.214.154/live/sjclive',
520 ''', None, require_title
=False),
524 'url': 'rtmp://192.138.214.154/live/sjclive',
529 # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/
532 self
.ie
._extract
_jwplayer
_data
(r
'''
533 <script type="text/javascript">
534 jwplayer("mediaplayer").setup({
537 'aspectratio': "16:9",
538 'stretching': "exactfit",
539 'autostart': 'false',
540 'flashplayer': "https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf",
541 '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",
542 'image': "https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg",
543 '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",
545 'skin': "https://t04.vipstreamservice.com/jwplayer/skin/modieus-blk.zip",
546 'plugins': "https://t04.vipstreamservice.com/jwplayer/dock/dockableskinnableplugin.swf",
547 'dockableskinnableplugin.piclink': "/index.php?key=ajax-videothumbsn&vid=7564&data=2009-12--14--4b2157147afe5efa93ce1978e0265289c193874e02597.flv--17370",
548 'controlbar': 'bottom',
550 {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'}
554 //noinspection JSAnnotator
556 adsUrl: "/banner-iframe/?zoneId=32",
561 ''', 'dummy', require_title
=False),
563 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg',
565 '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',
570 # from http://www.indiedb.com/games/king-machine/videos
573 self
.ie
._extract
_jwplayer
_data
(r
'''
575 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) {
576 videoAnalytics("play");
577 }).once("complete", function(event) {
578 videoAnalytics("completed");
583 'title': 'king machine trailer 1',
584 'thumbnail': 'http://media.indiedb.com/cache/images/games/1/50/49678/thumb_620x2000/king-machine-trailer.mp4.jpg',
586 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4',
590 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4',
596 def test_parse_m3u8_formats(self
):
599 # https://github.com/ytdl-org/youtube-dl/issues/11995
600 # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor
601 'img_bipbop_adv_example_fmp4',
602 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
604 'format_id': 'aud1-English',
605 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a1/prog_index.m3u8',
606 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
609 'protocol': 'm3u8_native',
612 'format_id': 'aud2-English',
613 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a2/prog_index.m3u8',
614 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
617 'protocol': 'm3u8_native',
620 'format_id': 'aud3-English',
621 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a3/prog_index.m3u8',
622 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
625 'protocol': 'm3u8_native',
629 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
630 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
632 'protocol': 'm3u8_native',
635 'vcodec': 'avc1.640015',
638 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
639 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
641 'protocol': 'm3u8_native',
644 'vcodec': 'avc1.640015',
647 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
648 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
650 'protocol': 'm3u8_native',
653 'vcodec': 'avc1.640015',
656 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
657 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
659 'protocol': 'm3u8_native',
662 'vcodec': 'avc1.64001e',
665 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
666 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
668 'protocol': 'm3u8_native',
671 'vcodec': 'avc1.64001e',
674 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
675 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
677 'protocol': 'm3u8_native',
680 'vcodec': 'avc1.64001e',
683 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
684 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
686 'protocol': 'm3u8_native',
689 'vcodec': 'avc1.64001e',
692 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
693 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
695 'protocol': 'm3u8_native',
698 'vcodec': 'avc1.64001e',
701 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
702 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
704 'protocol': 'm3u8_native',
707 'vcodec': 'avc1.64001e',
710 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
711 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
713 'protocol': 'm3u8_native',
716 'vcodec': 'avc1.640020',
719 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
720 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
722 'protocol': 'm3u8_native',
725 'vcodec': 'avc1.640020',
728 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
729 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
731 'protocol': 'm3u8_native',
734 'vcodec': 'avc1.640020',
737 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
738 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
740 'protocol': 'm3u8_native',
743 'vcodec': 'avc1.640020',
746 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
747 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
749 'protocol': 'm3u8_native',
752 'vcodec': 'avc1.640020',
755 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
756 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
758 'protocol': 'm3u8_native',
761 'vcodec': 'avc1.640020',
764 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
765 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
767 'protocol': 'm3u8_native',
770 'vcodec': 'avc1.64002a',
773 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
774 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
776 'protocol': 'm3u8_native',
779 'vcodec': 'avc1.64002a',
782 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
783 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
785 'protocol': 'm3u8_native',
788 'vcodec': 'avc1.64002a',
791 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
792 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
794 'protocol': 'm3u8_native',
797 'vcodec': 'avc1.64002a',
800 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
801 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
803 'protocol': 'm3u8_native',
806 'vcodec': 'avc1.64002a',
809 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
810 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
812 'protocol': 'm3u8_native',
815 'vcodec': 'avc1.64002a',
818 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
819 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
821 'protocol': 'm3u8_native',
824 'vcodec': 'avc1.64002a',
827 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
828 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
830 'protocol': 'm3u8_native',
833 'vcodec': 'avc1.64002a',
836 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
837 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
839 'protocol': 'm3u8_native',
842 'vcodec': 'avc1.64002a',
848 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
850 'format_id': 'bipbop_audio-BipBop Audio 2',
851 'format_index': None,
852 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/alternate_audio_aac/prog_index.m3u8',
853 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
856 'protocol': 'm3u8_native',
864 'format_index': None,
865 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8',
866 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
870 'protocol': 'm3u8_native',
874 'acodec': 'mp4a.40.2',
880 'format_index': None,
881 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8',
882 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
886 'protocol': 'm3u8_native',
891 'vcodec': 'avc1.4d400d',
892 'acodec': 'mp4a.40.2',
899 'format_index': None,
900 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8',
901 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
905 'protocol': 'm3u8_native',
910 'vcodec': 'avc1.4d401e',
911 'acodec': 'mp4a.40.2',
918 'format_index': None,
919 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8',
920 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
924 'protocol': 'm3u8_native',
929 'vcodec': 'avc1.4d401f',
930 'acodec': 'mp4a.40.2',
937 'format_index': None,
938 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8',
939 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
943 'protocol': 'm3u8_native',
948 'vcodec': 'avc1.4d401f',
949 'acodec': 'mp4a.40.2',
956 'format_index': None,
957 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8',
958 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
962 'protocol': 'm3u8_native',
967 'vcodec': 'avc1.4d401f',
968 'acodec': 'mp4a.40.2',
976 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng/prog_index.m3u8',
978 'protocol': 'm3u8_native'
980 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng_forced/prog_index.m3u8',
982 'protocol': 'm3u8_native'
985 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra/prog_index.m3u8',
987 'protocol': 'm3u8_native'
989 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra_forced/prog_index.m3u8',
991 'protocol': 'm3u8_native'
994 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa/prog_index.m3u8',
996 'protocol': 'm3u8_native'
998 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa_forced/prog_index.m3u8',
1000 'protocol': 'm3u8_native'
1003 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn/prog_index.m3u8',
1005 'protocol': 'm3u8_native'
1007 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn_forced/prog_index.m3u8',
1009 'protocol': 'm3u8_native'
1015 for m3u8_file
, m3u8_url
, expected_formats
, expected_subs
in _TEST_CASES
:
1016 with open('./test/testdata/m3u8/%s.m3u8' % m3u8_file
, encoding
='utf-8') as f
:
1017 formats
, subs
= self
.ie
._parse
_m
3u8_formats
_and
_subtitles
(
1018 f
.read(), m3u8_url
, ext
='mp4')
1019 self
.ie
._sort
_formats
(formats
)
1020 expect_value(self
, formats
, expected_formats
, None)
1021 expect_value(self
, subs
, expected_subs
, None)
1023 def test_parse_mpd_formats(self
):
1026 # https://github.com/ytdl-org/youtube-dl/issues/13919
1027 # Also tests duplicate representation ids, see
1028 # https://github.com/ytdl-org/youtube-dl/issues/15111
1030 'http://unknown/manifest.mpd', # mpd_url
1031 None, # mpd_base_url
1033 'manifest_url': 'http://unknown/manifest.mpd',
1035 'format_id': '318597',
1036 'format_note': 'DASH audio',
1037 'protocol': 'http_dash_segments',
1038 'acodec': 'mp4a.40.2',
1042 'manifest_url': 'http://unknown/manifest.mpd',
1044 'format_id': '318597',
1045 'format_note': 'DASH video',
1046 'protocol': 'http_dash_segments',
1048 'vcodec': 'avc1.42001f',
1053 'manifest_url': 'http://unknown/manifest.mpd',
1055 'format_id': '638590',
1056 'format_note': 'DASH video',
1057 'protocol': 'http_dash_segments',
1059 'vcodec': 'avc1.42001f',
1064 'manifest_url': 'http://unknown/manifest.mpd',
1066 'format_id': '1022565',
1067 'format_note': 'DASH video',
1068 'protocol': 'http_dash_segments',
1070 'vcodec': 'avc1.4d001f',
1075 'manifest_url': 'http://unknown/manifest.mpd',
1077 'format_id': '2046506',
1078 'format_note': 'DASH video',
1079 'protocol': 'http_dash_segments',
1081 'vcodec': 'avc1.4d001f',
1086 'manifest_url': 'http://unknown/manifest.mpd',
1088 'format_id': '3998017',
1089 'format_note': 'DASH video',
1090 'protocol': 'http_dash_segments',
1092 'vcodec': 'avc1.640029',
1097 'manifest_url': 'http://unknown/manifest.mpd',
1099 'format_id': '5997485',
1100 'format_note': 'DASH video',
1101 'protocol': 'http_dash_segments',
1103 'vcodec': 'avc1.640032',
1110 # https://github.com/ytdl-org/youtube-dl/pull/14844
1112 'http://unknown/manifest.mpd', # mpd_url
1113 None, # mpd_base_url
1115 'manifest_url': 'http://unknown/manifest.mpd',
1117 'format_id': 'h264_aac_144p_m4s',
1118 'format_note': 'DASH video',
1119 'protocol': 'http_dash_segments',
1120 'acodec': 'mp4a.40.2',
1121 'vcodec': 'avc3.42c01e',
1126 'manifest_url': 'http://unknown/manifest.mpd',
1128 'format_id': 'h264_aac_240p_m4s',
1129 'format_note': 'DASH video',
1130 'protocol': 'http_dash_segments',
1131 'acodec': 'mp4a.40.2',
1132 'vcodec': 'avc3.42c01e',
1137 'manifest_url': 'http://unknown/manifest.mpd',
1139 'format_id': 'h264_aac_360p_m4s',
1140 'format_note': 'DASH video',
1141 'protocol': 'http_dash_segments',
1142 'acodec': 'mp4a.40.2',
1143 'vcodec': 'avc3.42c01e',
1148 'manifest_url': 'http://unknown/manifest.mpd',
1150 'format_id': 'h264_aac_480p_m4s',
1151 'format_note': 'DASH video',
1152 'protocol': 'http_dash_segments',
1153 'acodec': 'mp4a.40.2',
1154 'vcodec': 'avc3.42c01e',
1159 'manifest_url': 'http://unknown/manifest.mpd',
1161 'format_id': 'h264_aac_576p_m4s',
1162 'format_note': 'DASH video',
1163 'protocol': 'http_dash_segments',
1164 'acodec': 'mp4a.40.2',
1165 'vcodec': 'avc3.42c01e',
1170 'manifest_url': 'http://unknown/manifest.mpd',
1172 'format_id': 'h264_aac_720p_m4s',
1173 'format_note': 'DASH video',
1174 'protocol': 'http_dash_segments',
1175 'acodec': 'mp4a.40.2',
1176 'vcodec': 'avc3.42c01e',
1181 'manifest_url': 'http://unknown/manifest.mpd',
1183 'format_id': 'h264_aac_1080p_m4s',
1184 'format_note': 'DASH video',
1185 'protocol': 'http_dash_segments',
1186 'acodec': 'mp4a.40.2',
1187 'vcodec': 'avc3.42c01e',
1194 # https://github.com/ytdl-org/youtube-dl/issues/20346
1195 # Media considered unfragmented even though it contains
1196 # Initialization tag
1198 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', # mpd_url
1199 'https://v.redd.it/hw1x7rcg7zl21', # mpd_base_url
1201 'url': 'https://v.redd.it/hw1x7rcg7zl21/audio',
1202 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1204 'format_id': 'AUDIO-1',
1205 'format_note': 'DASH audio',
1206 'container': 'm4a_dash',
1207 'acodec': 'mp4a.40.2',
1213 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240',
1214 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1216 'format_id': 'VIDEO-2',
1217 'format_note': 'DASH video',
1218 'container': 'mp4_dash',
1220 'vcodec': 'avc1.4d401e',
1226 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_360',
1227 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1229 'format_id': 'VIDEO-1',
1230 'format_note': 'DASH video',
1231 'container': 'mp4_dash',
1233 'vcodec': 'avc1.4d401e',
1242 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1243 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/',
1245 'format_id': 'audio=128001',
1246 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1250 'format_note': 'DASH audio',
1251 'container': 'm4a_dash',
1253 'acodec': 'mp4a.40.2',
1254 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1255 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1256 'protocol': 'http_dash_segments',
1258 'video_ext': 'none',
1261 'format_id': 'video=100000',
1262 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1267 'format_note': 'DASH video',
1268 'container': 'mp4_dash',
1269 'vcodec': 'avc1.4D401F',
1271 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1272 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1273 'protocol': 'http_dash_segments',
1275 'audio_ext': 'none',
1278 'format_id': 'video=326000',
1279 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1284 'format_note': 'DASH video',
1285 'container': 'mp4_dash',
1286 'vcodec': 'avc1.4D401F',
1288 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1289 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1290 'protocol': 'http_dash_segments',
1292 'audio_ext': 'none',
1295 'format_id': 'video=698000',
1296 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1301 'format_note': 'DASH video',
1302 'container': 'mp4_dash',
1303 'vcodec': 'avc1.4D401F',
1305 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1306 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1307 'protocol': 'http_dash_segments',
1309 'audio_ext': 'none',
1312 'format_id': 'video=1493000',
1313 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1318 'format_note': 'DASH video',
1319 'container': 'mp4_dash',
1320 'vcodec': 'avc1.4D401F',
1322 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1323 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1324 'protocol': 'http_dash_segments',
1326 'audio_ext': 'none',
1329 'format_id': 'video=4482000',
1330 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1335 'format_note': 'DASH video',
1336 'container': 'mp4_dash',
1337 'vcodec': 'avc1.4D401F',
1339 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1340 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1341 'protocol': 'http_dash_segments',
1343 'audio_ext': 'none',
1350 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1351 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1352 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1353 'protocol': 'http_dash_segments',
1360 for mpd_file
, mpd_url
, mpd_base_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1361 with open('./test/testdata/mpd/%s.mpd' % mpd_file
, encoding
='utf-8') as f
:
1362 formats
, subtitles
= self
.ie
._parse
_mpd
_formats
_and
_subtitles
(
1363 compat_etree_fromstring(f
.read().encode('utf-8')),
1364 mpd_base_url
=mpd_base_url
, mpd_url
=mpd_url
)
1365 self
.ie
._sort
_formats
(formats
)
1366 expect_value(self
, formats
, expected_formats
, None)
1367 expect_value(self
, subtitles
, expected_subtitles
, None)
1369 def test_parse_ism_formats(self
):
1373 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1375 'format_id': 'audio-128',
1376 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1377 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1384 '_download_params': {
1385 'stream_type': 'audio',
1386 'duration': 8880746666,
1387 'timescale': 10000000,
1391 'codec_private_data': '1190',
1392 'sampling_rate': 48000,
1394 'bits_per_sample': 16,
1395 'nal_unit_length_field': 4
1397 'audio_ext': 'isma',
1398 'video_ext': 'none',
1401 'format_id': 'video-100',
1402 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1403 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1411 '_download_params': {
1412 'stream_type': 'video',
1413 'duration': 8880746666,
1414 'timescale': 10000000,
1418 'codec_private_data': '00000001674D401FDA0544EFFC2D002CBC40000003004000000C03C60CA80000000168EF32C8',
1420 'bits_per_sample': 16,
1421 'nal_unit_length_field': 4
1423 'video_ext': 'ismv',
1424 'audio_ext': 'none',
1427 'format_id': 'video-326',
1428 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1429 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1437 '_download_params': {
1438 'stream_type': 'video',
1439 'duration': 8880746666,
1440 'timescale': 10000000,
1444 'codec_private_data': '00000001674D401FDA0241FE23FFC3BC83BA44000003000400000300C03C60CA800000000168EF32C8',
1446 'bits_per_sample': 16,
1447 'nal_unit_length_field': 4
1449 'video_ext': 'ismv',
1450 'audio_ext': 'none',
1453 'format_id': 'video-698',
1454 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1455 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1463 '_download_params': {
1464 'stream_type': 'video',
1465 'duration': 8880746666,
1466 'timescale': 10000000,
1470 'codec_private_data': '00000001674D401FDA0350BFB97FF06AF06AD1000003000100000300300F1832A00000000168EF32C8',
1472 'bits_per_sample': 16,
1473 'nal_unit_length_field': 4
1475 'video_ext': 'ismv',
1476 'audio_ext': 'none',
1479 'format_id': 'video-1493',
1480 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1481 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1489 '_download_params': {
1490 'stream_type': 'video',
1491 'duration': 8880746666,
1492 'timescale': 10000000,
1496 'codec_private_data': '00000001674D401FDA011C3DE6FFF0D890D871000003000100000300300F1832A00000000168EF32C8',
1498 'bits_per_sample': 16,
1499 'nal_unit_length_field': 4
1501 'video_ext': 'ismv',
1502 'audio_ext': 'none',
1505 'format_id': 'video-4482',
1506 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1507 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1515 '_download_params': {
1516 'stream_type': 'video',
1517 'duration': 8880746666,
1518 'timescale': 10000000,
1522 'codec_private_data': '00000001674D401FDA01A816F97FFC1ABC1AB440000003004000000C03C60CA80000000168EF32C8',
1524 'bits_per_sample': 16,
1525 'nal_unit_length_field': 4
1527 'video_ext': 'ismv',
1528 'audio_ext': 'none',
1536 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1537 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1538 '_download_params': {
1539 'stream_type': 'text',
1540 'duration': 8880746666,
1541 'timescale': 10000000,
1543 'codec_private_data': ''
1551 for ism_file
, ism_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1552 with open('./test/testdata/ism/%s.Manifest' % ism_file
, encoding
='utf-8') as f
:
1553 formats
, subtitles
= self
.ie
._parse
_ism
_formats
_and
_subtitles
(
1554 compat_etree_fromstring(f
.read().encode('utf-8')), ism_url
=ism_url
)
1555 self
.ie
._sort
_formats
(formats
)
1556 expect_value(self
, formats
, expected_formats
, None)
1557 expect_value(self
, subtitles
, expected_subtitles
, None)
1559 def test_parse_f4m_formats(self
):
1562 # https://github.com/ytdl-org/youtube-dl/issues/14660
1564 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1566 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1568 'format_id': '2148',
1577 for f4m_file
, f4m_url
, expected_formats
in _TEST_CASES
:
1578 with open('./test/testdata/f4m/%s.f4m' % f4m_file
, encoding
='utf-8') as f
:
1579 formats
= self
.ie
._parse
_f
4m
_formats
(
1580 compat_etree_fromstring(f
.read().encode('utf-8')),
1582 self
.ie
._sort
_formats
(formats
)
1583 expect_value(self
, formats
, expected_formats
, None)
1585 def test_parse_xspf(self
):
1589 'https://example.org/src/foo_xspf.xspf',
1592 'title': 'Pandemonium',
1593 'description': 'Visit http://bigbrother404.bandcamp.com',
1594 'duration': 202.416,
1596 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1597 'url': 'https://example.org/src/cd1/track%201.mp3',
1601 'title': 'Final Cartridge (Nichico Twelve Remix)',
1602 'description': 'Visit http://bigbrother404.bandcamp.com',
1603 'duration': 255.857,
1605 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1606 'url': 'https://example.org/%E3%83%88%E3%83%A9%E3%83%83%E3%82%AF%E3%80%80%EF%BC%92.mp3',
1610 'title': 'Rebuilding Nightingale',
1611 'description': 'Visit http://bigbrother404.bandcamp.com',
1612 'duration': 287.915,
1614 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1615 'url': 'https://example.org/src/track3.mp3',
1617 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1618 'url': 'https://example.com/track3.mp3',
1624 for xspf_file
, xspf_url
, expected_entries
in _TEST_CASES
:
1625 with open('./test/testdata/xspf/%s.xspf' % xspf_file
, encoding
='utf-8') as f
:
1626 entries
= self
.ie
._parse
_xspf
(
1627 compat_etree_fromstring(f
.read().encode('utf-8')),
1628 xspf_file
, xspf_url
=xspf_url
, xspf_base_url
=xspf_url
)
1629 expect_value(self
, entries
, expected_entries
, None)
1630 for i
in range(len(entries
)):
1631 expect_dict(self
, entries
[i
], expected_entries
[i
])
1633 def test_response_with_expected_status_returns_content(self
):
1634 # Checks for mitigations against the effects of
1635 # <https://bugs.python.org/issue15002> that affect Python 3.4.1+, which
1636 # manifest as `_download_webpage`, `_download_xml`, `_download_json`,
1637 # or the underlying `_download_webpage_handle` returning no content
1638 # when a response matches `expected_status`.
1640 httpd
= compat_http_server
.HTTPServer(
1641 ('127.0.0.1', 0), InfoExtractorTestRequestHandler
)
1642 port
= http_server_port(httpd
)
1643 server_thread
= threading
.Thread(target
=httpd
.serve_forever
)
1644 server_thread
.daemon
= True
1645 server_thread
.start()
1647 (content
, urlh
) = self
.ie
._download
_webpage
_handle
(
1648 'http://127.0.0.1:%d/teapot' % port
, None,
1649 expected_status
=TEAPOT_RESPONSE_STATUS
)
1650 self
.assertEqual(content
, TEAPOT_RESPONSE_BODY
)
1653 if __name__
== '__main__':