3 from __future__
import unicode_literals
5 # Allow direct execution
10 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
12 from test
.helper
import FakeYDL
, expect_dict
, expect_value
, http_server_port
13 from yt_dlp
.compat
import compat_etree_fromstring
, compat_http_server
14 from yt_dlp
.extractor
.common
import InfoExtractor
15 from yt_dlp
.extractor
import YoutubeIE
, get_info_extractor
16 from yt_dlp
.utils
import encode_data_uri
, strip_jsonp
, ExtractorError
, RegexNotFoundError
20 TEAPOT_RESPONSE_STATUS
= 418
21 TEAPOT_RESPONSE_BODY
= "<h1>418 I'm a teapot</h1>"
24 class InfoExtractorTestRequestHandler(compat_http_server
.BaseHTTPRequestHandler
):
25 def log_message(self
, format
, *args
):
29 if self
.path
== '/teapot':
30 self
.send_response(TEAPOT_RESPONSE_STATUS
)
31 self
.send_header('Content-Type', 'text/html; charset=utf-8')
33 self
.wfile
.write(TEAPOT_RESPONSE_BODY
.encode())
38 class DummyIE(InfoExtractor
):
42 class TestInfoExtractor(unittest
.TestCase
):
44 self
.ie
= DummyIE(FakeYDL())
46 def test_ie_key(self
):
47 self
.assertEqual(get_info_extractor(YoutubeIE
.ie_key()), YoutubeIE
)
49 def test_html_search_regex(self
):
50 html
= '<p id="foo">Watch this <a href="http://www.youtube.com/watch?v=BaW_jenozKc">video</a></p>'
51 search
= lambda re
, *args
: self
.ie
._html
_search
_regex
(re
, html
, *args
)
52 self
.assertEqual(search(r
'<p id="foo">(.+?)</p>', 'foo'), 'Watch this video')
54 def test_opengraph(self
):
57 <meta name="og:title" content='Foo'/>
58 <meta content="Some video's description " name="og:description"/>
59 <meta property='og:image' content='http://domain.com/pic.jpg?key1=val1&key2=val2'/>
60 <meta content='application/x-shockwave-flash' property='og:video:type'>
61 <meta content='Foo' property=og:foobar>
62 <meta name="og:test1" content='foo > < bar'/>
63 <meta name="og:test2" content="foo >//< bar"/>
64 <meta property=og-test3 content='Ill-formatted opengraph'/>
66 self
.assertEqual(ie
._og
_search
_title
(html
), 'Foo')
67 self
.assertEqual(ie
._og
_search
_description
(html
), 'Some video\'s description ')
68 self
.assertEqual(ie
._og
_search
_thumbnail
(html
), 'http://domain.com/pic.jpg?key1=val1&key2=val2')
69 self
.assertEqual(ie
._og
_search
_video
_url
(html
, default
=None), None)
70 self
.assertEqual(ie
._og
_search
_property
('foobar', html
), 'Foo')
71 self
.assertEqual(ie
._og
_search
_property
('test1', html
), 'foo > < bar')
72 self
.assertEqual(ie
._og
_search
_property
('test2', html
), 'foo >//< bar')
73 self
.assertEqual(ie
._og
_search
_property
('test3', html
), 'Ill-formatted opengraph')
74 self
.assertEqual(ie
._og
_search
_property
(('test0', 'test1'), html
), 'foo > < bar')
75 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, 'test0', html
, None, fatal
=True)
76 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, ('test0', 'test00'), html
, None, fatal
=True)
78 def test_html_search_meta(self
):
81 <meta name="a" content="1" />
82 <meta name='b' content='2'>
83 <meta name="c" content='3'>
84 <meta name=d content='4'>
85 <meta property="e" content='5' >
86 <meta content="6" name="f">
89 self
.assertEqual(ie
._html
_search
_meta
('a', html
), '1')
90 self
.assertEqual(ie
._html
_search
_meta
('b', html
), '2')
91 self
.assertEqual(ie
._html
_search
_meta
('c', html
), '3')
92 self
.assertEqual(ie
._html
_search
_meta
('d', html
), '4')
93 self
.assertEqual(ie
._html
_search
_meta
('e', html
), '5')
94 self
.assertEqual(ie
._html
_search
_meta
('f', html
), '6')
95 self
.assertEqual(ie
._html
_search
_meta
(('a', 'b', 'c'), html
), '1')
96 self
.assertEqual(ie
._html
_search
_meta
(('c', 'b', 'a'), html
), '3')
97 self
.assertEqual(ie
._html
_search
_meta
(('z', 'x', 'c'), html
), '3')
98 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, 'z', html
, None, fatal
=True)
99 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, ('z', 'x'), html
, None, fatal
=True)
101 def test_search_json_ld_realworld(self
):
103 # https://github.com/ytdl-org/youtube-dl/issues/23306
105 r
'''<script type="application/ld+json">
107 "@context": "http://schema.org/",
108 "@type": "VideoObject",
109 "name": "1 On 1 With Kleio",
110 "url": "https://www.eporner.com/hd-porn/xN49A1cT3eB/1-On-1-With-Kleio/",
111 "duration": "PT0H12M23S",
112 "thumbnailUrl": ["https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg", "https://imggen.eporner.com/780814/1920/1080/9.jpg"],
113 "contentUrl": "https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4",
114 "embedUrl": "https://www.eporner.com/embed/xN49A1cT3eB/1-On-1-With-Kleio/",
115 "image": "https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg",
118 "encodingFormat": "mp4",
119 "bitrate": "6617kbps",
120 "isFamilyFriendly": "False",
121 "description": "Kleio Valentien",
122 "uploadDate": "2015-12-05T21:24:35+01:00",
123 "interactionStatistic": {
124 "@type": "InteractionCounter",
125 "interactionType": { "@type": "http://schema.org/WatchAction" },
126 "userInteractionCount": 1120958
127 }, "aggregateRating": {
128 "@type": "AggregateRating",
130 "ratingCount": "630",
135 "name": "Kleio Valentien",
136 "url": "https://www.eporner.com/pornstar/kleio-valentien/"
140 'title': '1 On 1 With Kleio',
141 'description': 'Kleio Valentien',
142 'url': 'https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4',
143 'timestamp': 1449347075,
145 'view_count': 1120958,
152 r
'''<script type="application/ld+json">
154 "@context": "https://schema.org",
157 "@type": "NewsArticle",
158 "mainEntityOfPage": {
160 "@id": "https://www.ant1news.gr/Society/article/620286/symmoria-anilikon-dikigoros-thymaton-ithelan-na-toys-apoteleiosoyn"
162 "headline": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
163 "name": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
164 "description": "Τα παιδιά δέχθηκαν την επίθεση επειδή αρνήθηκαν να γίνουν μέλη της συμμορίας, ανέφερε ο Γ. Ζαχαρόπουλος.",
166 "@type": "ImageObject",
167 "url": "https://ant1media.azureedge.net/imgHandler/1100/a635c968-be71-447c-bf9c-80d843ece21e.jpg",
170 "datePublished": "2021-11-10T08:50:00+03:00",
171 "dateModified": "2021-11-10T08:52:53+03:00",
174 "@id": "https://www.ant1news.gr/",
176 "image": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
177 "url": "https://www.ant1news.gr/"
180 "@type": "Organization",
181 "@id": "https://www.ant1news.gr#publisher",
183 "url": "https://www.ant1news.gr",
185 "@type": "ImageObject",
186 "url": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
190 "https://www.facebook.com/Ant1news.gr",
191 "https://twitter.com/antennanews",
192 "https://www.youtube.com/channel/UC0smvAbfczoN75dP0Hw4Pzw",
193 "https://www.instagram.com/ant1news/"
197 "keywords": "μαχαίρωμα,συμμορία ανηλίκων,ΕΙΔΗΣΕΙΣ,ΕΙΔΗΣΕΙΣ ΣΗΜΕΡΑ,ΝΕΑ,Κοινωνία - Ant1news",
200 "articleSection": "Κοινωνία"
206 'timestamp': 1636523400,
207 'title': 'md5:91fe569e952e4d146485740ae927662b',
209 {'expected_type': 'NewsArticle'}
,
212 r
'''<script type="application/ld+json">
213 {"url":"/vrtnu/a-z/het-journaal/2021/het-journaal-het-journaal-19u-20211231/",
214 "name":"Het journaal 19u",
215 "description":"Het journaal 19u van vrijdag 31 december 2021.",
216 "potentialAction":{"url":"https://vrtnu.page.link/pfVy6ihgCAJKgHqe8","@type":"ShareAction"},
217 "mainEntityOfPage":{"@id":"1640092242445","@type":"WebPage"},
219 "startDate":"2021-12-31T19:00:00.000+01:00",
220 "endDate":"2022-01-30T23:55:00.000+01:00",
221 "publishedBy":{"name":"een","@type":"Organization"},
222 "publishedOn":{"url":"https://www.vrt.be/vrtnu/","name":"VRT NU","@type":"BroadcastService"},
223 "@id":"pbs-pub-3a7ec233-da95-4c1e-9b2b-cf5fdfebcbe8",
224 "@type":"BroadcastEvent"
227 "name":"Het journaal - Aflevering 365 (Seizoen 2021)",
228 "description":"Het journaal 19u van vrijdag 31 december 2021. Bekijk aflevering 365 van seizoen 2021 met VRT NU via de site of app.",
229 "thumbnailUrl":"//images.vrt.be/width1280/2021/12/31/80d5ed00-6a64-11ec-b07d-02b7b76bf47f.jpg",
230 "expires":"2022-01-30T23:55:00.000+01:00",
232 {"name":"Explosie Turnhout","startOffset":70,"@type":"Clip"},
233 {"name":"Jaarwisseling","startOffset":440,"@type":"Clip"},
234 {"name":"Natuurbranden Colorado","startOffset":1179,"@type":"Clip"},
235 {"name":"Klimaatverandering","startOffset":1263,"@type":"Clip"},
236 {"name":"Zacht weer","startOffset":1367,"@type":"Clip"},
237 {"name":"Financiële balans","startOffset":1383,"@type":"Clip"},
238 {"name":"Club Brugge","startOffset":1484,"@type":"Clip"},
239 {"name":"Mentale gezondheid bij topsporters","startOffset":1575,"@type":"Clip"},
240 {"name":"Olympische Winterspelen","startOffset":1728,"@type":"Clip"},
241 {"name":"Sober oudjaar in Nederland","startOffset":1873,"@type":"Clip"}
243 "duration":"PT34M39.23S",
244 "uploadDate":"2021-12-31T19:00:00.000+01:00",
245 "@id":"vid-9457d0c6-b8ac-4aba-b5e1-15aa3a3295b5",
246 "@type":"VideoObject"
248 "genre":["Nieuws en actua"],
250 "partOfSeries":{"name":"Het journaal","@id":"222831405527","@type":"TVSeries"},
251 "partOfSeason":{"name":"Seizoen 2021","@id":"961809365527","@type":"TVSeason"},
252 "@context":"https://schema.org","@id":"961685295527","@type":"TVEpisode"}</script>
256 {"title": "Explosie Turnhout", "start_time": 70, "end_time": 440}
,
257 {"title": "Jaarwisseling", "start_time": 440, "end_time": 1179}
,
258 {"title": "Natuurbranden Colorado", "start_time": 1179, "end_time": 1263}
,
259 {"title": "Klimaatverandering", "start_time": 1263, "end_time": 1367}
,
260 {"title": "Zacht weer", "start_time": 1367, "end_time": 1383}
,
261 {"title": "Financiële balans", "start_time": 1383, "end_time": 1484}
,
262 {"title": "Club Brugge", "start_time": 1484, "end_time": 1575}
,
263 {"title": "Mentale gezondheid bij topsporters", "start_time": 1575, "end_time": 1728}
,
264 {"title": "Olympische Winterspelen", "start_time": 1728, "end_time": 1873}
,
265 {"title": "Sober oudjaar in Nederland", "start_time": 1873, "end_time": 2079.23}
267 'title': 'Het journaal - Aflevering 365 (Seizoen 2021)'
271 # test multiple thumbnails in a list
273 <script type="application/ld+json">
274 {"@context":"https://schema.org",
275 "@type":"VideoObject",
276 "thumbnailUrl":["https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"]}
279 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}
],
284 # test single thumbnail
286 <script type="application/ld+json">
287 {"@context":"https://schema.org",
288 "@type":"VideoObject",
289 "thumbnailUrl":"https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"}
292 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}
],
297 for html
, expected_dict
, search_json_ld_kwargs
in _TESTS
:
300 self
.ie
._search
_json
_ld
(html
, None, **search_json_ld_kwargs
),
304 def test_download_json(self
):
305 uri
= encode_data_uri(b
'{"foo": "blah"}', 'application/json')
306 self
.assertEqual(self
.ie
._download
_json
(uri
, None), {'foo': 'blah'}
)
307 uri
= encode_data_uri(b
'callback({"foo": "blah"})', 'application/javascript')
308 self
.assertEqual(self
.ie
._download
_json
(uri
, None, transform_source
=strip_jsonp
), {'foo': 'blah'}
)
309 uri
= encode_data_uri(b
'{"foo": invalid}', 'application/json')
310 self
.assertRaises(ExtractorError
, self
.ie
._download
_json
, uri
, None)
311 self
.assertEqual(self
.ie
._download
_json
(uri
, None, fatal
=False), None)
313 def test_parse_html5_media_entries(self
):
317 self
.ie
._parse
_html
5_media
_entries
(
318 'https://127.0.0.1/video.html',
319 r
'<html><video src="/vid.mp4" /></html>', None)[0],
322 'url': 'https://127.0.0.1/vid.mp4',
326 # from https://www.r18.com/
330 self
.ie
._parse
_html
5_media
_entries
(
331 'https://www.r18.com/',
333 <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">
334 <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">
335 <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">
336 <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">
337 <p>Your browser does not support the video tag.</p>
342 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4',
344 'format_id': '300kbps',
348 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4',
350 'format_id': '1000kbps',
354 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4',
356 'format_id': '1500kbps',
360 'thumbnail': '//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg'
363 # from https://www.csfd.cz/
364 # with width and height
367 self
.ie
._parse
_html
5_media
_entries
(
368 'https://www.csfd.cz/',
370 <video width="770" height="328" preload="none" controls poster="https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360" >
371 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4" type="video/mp4" width="640" height="360">
372 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4" type="video/mp4" width="1280" height="720">
373 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4" type="video/mp4" width="1920" height="1080">
374 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm" type="video/webm" width="640" height="360">
375 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm" type="video/webm" width="1280" height="720">
376 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm" type="video/webm" width="1920" height="1080">
377 <track src="https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt" type="text/x-srt" kind="subtitles" srclang="cs" label="cs">
382 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4',
387 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4',
392 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4',
397 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm',
402 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm',
407 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm',
413 'cs': [{'url': 'https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt'}
]
415 'thumbnail': 'https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360'
418 # from https://tamasha.com/v/Kkdjw
419 # with height in label
422 self
.ie
._parse
_html
5_media
_entries
(
423 'https://tamasha.com/v/Kkdjw',
425 <video crossorigin="anonymous">
426 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4" label="AUTO" res="0"/>
427 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4"
428 label="240p" res="240"/>
429 <source src="https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4" type="video/mp4"
430 label="144p" res="144"/>
435 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
437 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
442 'url': 'https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4',
449 # from https://www.directvnow.com
453 self
.ie
._parse
_html
5_media
_entries
(
454 'https://www.directvnow.com',
456 <video id="vid1" class="header--video-masked active" muted playsinline>
457 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
463 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
467 # from https://www.directvnow.com
471 self
.ie
._parse
_html
5_media
_entries
(
472 'https://www.directvnow.com',
474 <video id="vid1" class="header--video-masked active" muted playsinline>
475 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
480 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
485 # from https://www.klarna.com/uk/
486 # with data-video-src
489 self
.ie
._parse
_html
5_media
_entries
(
490 'https://www.directvnow.com',
492 <video loop autoplay muted class="responsive-video block-kl__video video-on-medium">
493 <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" />
498 'url': 'https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4',
503 def test_extract_jwplayer_data_realworld(self
):
504 # from http://www.suffolk.edu/sjc/
507 self
.ie
._extract
_jwplayer
_data
(r
'''
508 <script type='text/javascript'>
509 jwplayer('my-video').setup({
510 file: 'rtmp://192.138.214.154/live/sjclive',
518 ''', None, require_title
=False),
522 'url': 'rtmp://192.138.214.154/live/sjclive',
527 # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/
530 self
.ie
._extract
_jwplayer
_data
(r
'''
531 <script type="text/javascript">
532 jwplayer("mediaplayer").setup({
535 'aspectratio': "16:9",
536 'stretching': "exactfit",
537 'autostart': 'false',
538 'flashplayer': "https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf",
539 '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",
540 'image': "https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg",
541 '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",
543 'skin': "https://t04.vipstreamservice.com/jwplayer/skin/modieus-blk.zip",
544 'plugins': "https://t04.vipstreamservice.com/jwplayer/dock/dockableskinnableplugin.swf",
545 'dockableskinnableplugin.piclink': "/index.php?key=ajax-videothumbsn&vid=7564&data=2009-12--14--4b2157147afe5efa93ce1978e0265289c193874e02597.flv--17370",
546 'controlbar': 'bottom',
548 {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'}
552 //noinspection JSAnnotator
554 adsUrl: "/banner-iframe/?zoneId=32",
559 ''', 'dummy', require_title
=False),
561 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg',
563 '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',
568 # from http://www.indiedb.com/games/king-machine/videos
571 self
.ie
._extract
_jwplayer
_data
(r
'''
573 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) {
574 videoAnalytics("play");
575 }).once("complete", function(event) {
576 videoAnalytics("completed");
581 'title': 'king machine trailer 1',
582 'thumbnail': 'http://media.indiedb.com/cache/images/games/1/50/49678/thumb_620x2000/king-machine-trailer.mp4.jpg',
584 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4',
588 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4',
594 def test_parse_m3u8_formats(self
):
597 # https://github.com/ytdl-org/youtube-dl/issues/11995
598 # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor
599 'img_bipbop_adv_example_fmp4',
600 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
602 'format_id': 'aud1-English',
603 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a1/prog_index.m3u8',
604 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
607 'protocol': 'm3u8_native',
610 'format_id': 'aud2-English',
611 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a2/prog_index.m3u8',
612 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
615 'protocol': 'm3u8_native',
618 'format_id': 'aud3-English',
619 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a3/prog_index.m3u8',
620 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
623 'protocol': 'm3u8_native',
627 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
628 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
630 'protocol': 'm3u8_native',
633 'vcodec': 'avc1.640015',
636 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
637 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
639 'protocol': 'm3u8_native',
642 'vcodec': 'avc1.640015',
645 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
646 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
648 'protocol': 'm3u8_native',
651 'vcodec': 'avc1.640015',
654 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
655 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
657 'protocol': 'm3u8_native',
660 'vcodec': 'avc1.64001e',
663 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
664 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
666 'protocol': 'm3u8_native',
669 'vcodec': 'avc1.64001e',
672 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
673 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
675 'protocol': 'm3u8_native',
678 'vcodec': 'avc1.64001e',
681 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
682 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
684 'protocol': 'm3u8_native',
687 'vcodec': 'avc1.64001e',
690 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
691 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
693 'protocol': 'm3u8_native',
696 'vcodec': 'avc1.64001e',
699 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
700 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
702 'protocol': 'm3u8_native',
705 'vcodec': 'avc1.64001e',
708 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
709 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
711 'protocol': 'm3u8_native',
714 'vcodec': 'avc1.640020',
717 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
718 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
720 'protocol': 'm3u8_native',
723 'vcodec': 'avc1.640020',
726 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
727 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
729 'protocol': 'm3u8_native',
732 'vcodec': 'avc1.640020',
735 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
736 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
738 'protocol': 'm3u8_native',
741 'vcodec': 'avc1.640020',
744 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
745 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
747 'protocol': 'm3u8_native',
750 'vcodec': 'avc1.640020',
753 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
754 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
756 'protocol': 'm3u8_native',
759 'vcodec': 'avc1.640020',
762 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
763 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
765 'protocol': 'm3u8_native',
768 'vcodec': 'avc1.64002a',
771 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
772 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
774 'protocol': 'm3u8_native',
777 'vcodec': 'avc1.64002a',
780 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
781 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
783 'protocol': 'm3u8_native',
786 'vcodec': 'avc1.64002a',
789 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
790 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
792 'protocol': 'm3u8_native',
795 'vcodec': 'avc1.64002a',
798 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
799 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
801 'protocol': 'm3u8_native',
804 'vcodec': 'avc1.64002a',
807 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
808 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
810 'protocol': 'm3u8_native',
813 'vcodec': 'avc1.64002a',
816 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
817 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
819 'protocol': 'm3u8_native',
822 'vcodec': 'avc1.64002a',
825 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
826 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
828 'protocol': 'm3u8_native',
831 'vcodec': 'avc1.64002a',
834 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
835 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
837 'protocol': 'm3u8_native',
840 'vcodec': 'avc1.64002a',
846 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
848 'format_id': 'bipbop_audio-BipBop Audio 2',
849 'format_index': None,
850 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/alternate_audio_aac/prog_index.m3u8',
851 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
854 'protocol': 'm3u8_native',
862 'format_index': None,
863 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8',
864 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
868 'protocol': 'm3u8_native',
872 'acodec': 'mp4a.40.2',
878 'format_index': None,
879 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8',
880 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
884 'protocol': 'm3u8_native',
889 'vcodec': 'avc1.4d400d',
890 'acodec': 'mp4a.40.2',
897 'format_index': None,
898 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8',
899 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
903 'protocol': 'm3u8_native',
908 'vcodec': 'avc1.4d401e',
909 'acodec': 'mp4a.40.2',
916 'format_index': None,
917 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8',
918 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
922 'protocol': 'm3u8_native',
927 'vcodec': 'avc1.4d401f',
928 'acodec': 'mp4a.40.2',
935 'format_index': None,
936 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8',
937 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
941 'protocol': 'm3u8_native',
946 'vcodec': 'avc1.4d401f',
947 'acodec': 'mp4a.40.2',
954 'format_index': None,
955 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8',
956 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
960 'protocol': 'm3u8_native',
965 'vcodec': 'avc1.4d401f',
966 'acodec': 'mp4a.40.2',
974 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng/prog_index.m3u8',
976 'protocol': 'm3u8_native'
978 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng_forced/prog_index.m3u8',
980 'protocol': 'm3u8_native'
983 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra/prog_index.m3u8',
985 'protocol': 'm3u8_native'
987 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra_forced/prog_index.m3u8',
989 'protocol': 'm3u8_native'
992 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa/prog_index.m3u8',
994 'protocol': 'm3u8_native'
996 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa_forced/prog_index.m3u8',
998 'protocol': 'm3u8_native'
1001 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn/prog_index.m3u8',
1003 'protocol': 'm3u8_native'
1005 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn_forced/prog_index.m3u8',
1007 'protocol': 'm3u8_native'
1013 for m3u8_file
, m3u8_url
, expected_formats
, expected_subs
in _TEST_CASES
:
1014 with io
.open('./test/testdata/m3u8/%s.m3u8' % m3u8_file
,
1015 mode
='r', encoding
='utf-8') as f
:
1016 formats
, subs
= self
.ie
._parse
_m
3u8_formats
_and
_subtitles
(
1017 f
.read(), m3u8_url
, ext
='mp4')
1018 self
.ie
._sort
_formats
(formats
)
1019 expect_value(self
, formats
, expected_formats
, None)
1020 expect_value(self
, subs
, expected_subs
, None)
1022 def test_parse_mpd_formats(self
):
1025 # https://github.com/ytdl-org/youtube-dl/issues/13919
1026 # Also tests duplicate representation ids, see
1027 # https://github.com/ytdl-org/youtube-dl/issues/15111
1029 'http://unknown/manifest.mpd', # mpd_url
1030 None, # mpd_base_url
1032 'manifest_url': 'http://unknown/manifest.mpd',
1034 'format_id': '318597',
1035 'format_note': 'DASH audio',
1036 'protocol': 'http_dash_segments',
1037 'acodec': 'mp4a.40.2',
1041 'manifest_url': 'http://unknown/manifest.mpd',
1043 'format_id': '318597',
1044 'format_note': 'DASH video',
1045 'protocol': 'http_dash_segments',
1047 'vcodec': 'avc1.42001f',
1052 'manifest_url': 'http://unknown/manifest.mpd',
1054 'format_id': '638590',
1055 'format_note': 'DASH video',
1056 'protocol': 'http_dash_segments',
1058 'vcodec': 'avc1.42001f',
1063 'manifest_url': 'http://unknown/manifest.mpd',
1065 'format_id': '1022565',
1066 'format_note': 'DASH video',
1067 'protocol': 'http_dash_segments',
1069 'vcodec': 'avc1.4d001f',
1074 'manifest_url': 'http://unknown/manifest.mpd',
1076 'format_id': '2046506',
1077 'format_note': 'DASH video',
1078 'protocol': 'http_dash_segments',
1080 'vcodec': 'avc1.4d001f',
1085 'manifest_url': 'http://unknown/manifest.mpd',
1087 'format_id': '3998017',
1088 'format_note': 'DASH video',
1089 'protocol': 'http_dash_segments',
1091 'vcodec': 'avc1.640029',
1096 'manifest_url': 'http://unknown/manifest.mpd',
1098 'format_id': '5997485',
1099 'format_note': 'DASH video',
1100 'protocol': 'http_dash_segments',
1102 'vcodec': 'avc1.640032',
1109 # https://github.com/ytdl-org/youtube-dl/pull/14844
1111 'http://unknown/manifest.mpd', # mpd_url
1112 None, # mpd_base_url
1114 'manifest_url': 'http://unknown/manifest.mpd',
1116 'format_id': 'h264_aac_144p_m4s',
1117 'format_note': 'DASH video',
1118 'protocol': 'http_dash_segments',
1119 'acodec': 'mp4a.40.2',
1120 'vcodec': 'avc3.42c01e',
1125 'manifest_url': 'http://unknown/manifest.mpd',
1127 'format_id': 'h264_aac_240p_m4s',
1128 'format_note': 'DASH video',
1129 'protocol': 'http_dash_segments',
1130 'acodec': 'mp4a.40.2',
1131 'vcodec': 'avc3.42c01e',
1136 'manifest_url': 'http://unknown/manifest.mpd',
1138 'format_id': 'h264_aac_360p_m4s',
1139 'format_note': 'DASH video',
1140 'protocol': 'http_dash_segments',
1141 'acodec': 'mp4a.40.2',
1142 'vcodec': 'avc3.42c01e',
1147 'manifest_url': 'http://unknown/manifest.mpd',
1149 'format_id': 'h264_aac_480p_m4s',
1150 'format_note': 'DASH video',
1151 'protocol': 'http_dash_segments',
1152 'acodec': 'mp4a.40.2',
1153 'vcodec': 'avc3.42c01e',
1158 'manifest_url': 'http://unknown/manifest.mpd',
1160 'format_id': 'h264_aac_576p_m4s',
1161 'format_note': 'DASH video',
1162 'protocol': 'http_dash_segments',
1163 'acodec': 'mp4a.40.2',
1164 'vcodec': 'avc3.42c01e',
1169 'manifest_url': 'http://unknown/manifest.mpd',
1171 'format_id': 'h264_aac_720p_m4s',
1172 'format_note': 'DASH video',
1173 'protocol': 'http_dash_segments',
1174 'acodec': 'mp4a.40.2',
1175 'vcodec': 'avc3.42c01e',
1180 'manifest_url': 'http://unknown/manifest.mpd',
1182 'format_id': 'h264_aac_1080p_m4s',
1183 'format_note': 'DASH video',
1184 'protocol': 'http_dash_segments',
1185 'acodec': 'mp4a.40.2',
1186 'vcodec': 'avc3.42c01e',
1193 # https://github.com/ytdl-org/youtube-dl/issues/20346
1194 # Media considered unfragmented even though it contains
1195 # Initialization tag
1197 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', # mpd_url
1198 'https://v.redd.it/hw1x7rcg7zl21', # mpd_base_url
1200 'url': 'https://v.redd.it/hw1x7rcg7zl21/audio',
1201 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1203 'format_id': 'AUDIO-1',
1204 'format_note': 'DASH audio',
1205 'container': 'm4a_dash',
1206 'acodec': 'mp4a.40.2',
1212 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240',
1213 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1215 'format_id': 'VIDEO-2',
1216 'format_note': 'DASH video',
1217 'container': 'mp4_dash',
1219 'vcodec': 'avc1.4d401e',
1225 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_360',
1226 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1228 'format_id': 'VIDEO-1',
1229 'format_note': 'DASH video',
1230 'container': 'mp4_dash',
1232 'vcodec': 'avc1.4d401e',
1241 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1242 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/',
1244 'format_id': 'audio=128001',
1245 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1249 'format_note': 'DASH audio',
1250 'container': 'm4a_dash',
1252 'acodec': 'mp4a.40.2',
1253 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1254 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1255 'protocol': 'http_dash_segments',
1257 'video_ext': 'none',
1260 'format_id': 'video=100000',
1261 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1266 'format_note': 'DASH video',
1267 'container': 'mp4_dash',
1268 'vcodec': 'avc1.4D401F',
1270 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1271 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1272 'protocol': 'http_dash_segments',
1274 'audio_ext': 'none',
1277 'format_id': 'video=326000',
1278 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1283 'format_note': 'DASH video',
1284 'container': 'mp4_dash',
1285 'vcodec': 'avc1.4D401F',
1287 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1288 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1289 'protocol': 'http_dash_segments',
1291 'audio_ext': 'none',
1294 'format_id': 'video=698000',
1295 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1300 'format_note': 'DASH video',
1301 'container': 'mp4_dash',
1302 'vcodec': 'avc1.4D401F',
1304 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1305 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1306 'protocol': 'http_dash_segments',
1308 'audio_ext': 'none',
1311 'format_id': 'video=1493000',
1312 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1317 'format_note': 'DASH video',
1318 'container': 'mp4_dash',
1319 'vcodec': 'avc1.4D401F',
1321 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1322 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1323 'protocol': 'http_dash_segments',
1325 'audio_ext': 'none',
1328 'format_id': 'video=4482000',
1329 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1334 'format_note': 'DASH video',
1335 'container': 'mp4_dash',
1336 'vcodec': 'avc1.4D401F',
1338 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1339 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1340 'protocol': 'http_dash_segments',
1342 'audio_ext': 'none',
1349 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1350 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1351 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1352 'protocol': 'http_dash_segments',
1359 for mpd_file
, mpd_url
, mpd_base_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1360 with io
.open('./test/testdata/mpd/%s.mpd' % mpd_file
,
1361 mode
='r', 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 io
.open('./test/testdata/ism/%s.Manifest' % ism_file
,
1553 mode
='r', encoding
='utf-8') as f
:
1554 formats
, subtitles
= self
.ie
._parse
_ism
_formats
_and
_subtitles
(
1555 compat_etree_fromstring(f
.read().encode('utf-8')), ism_url
=ism_url
)
1556 self
.ie
._sort
_formats
(formats
)
1557 expect_value(self
, formats
, expected_formats
, None)
1558 expect_value(self
, subtitles
, expected_subtitles
, None)
1560 def test_parse_f4m_formats(self
):
1563 # https://github.com/ytdl-org/youtube-dl/issues/14660
1565 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1567 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1569 'format_id': '2148',
1578 for f4m_file
, f4m_url
, expected_formats
in _TEST_CASES
:
1579 with io
.open('./test/testdata/f4m/%s.f4m' % f4m_file
,
1580 mode
='r', encoding
='utf-8') as f
:
1581 formats
= self
.ie
._parse
_f
4m
_formats
(
1582 compat_etree_fromstring(f
.read().encode('utf-8')),
1584 self
.ie
._sort
_formats
(formats
)
1585 expect_value(self
, formats
, expected_formats
, None)
1587 def test_parse_xspf(self
):
1591 'https://example.org/src/foo_xspf.xspf',
1594 'title': 'Pandemonium',
1595 'description': 'Visit http://bigbrother404.bandcamp.com',
1596 'duration': 202.416,
1598 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1599 'url': 'https://example.org/src/cd1/track%201.mp3',
1603 'title': 'Final Cartridge (Nichico Twelve Remix)',
1604 'description': 'Visit http://bigbrother404.bandcamp.com',
1605 'duration': 255.857,
1607 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1608 'url': 'https://example.org/%E3%83%88%E3%83%A9%E3%83%83%E3%82%AF%E3%80%80%EF%BC%92.mp3',
1612 'title': 'Rebuilding Nightingale',
1613 'description': 'Visit http://bigbrother404.bandcamp.com',
1614 'duration': 287.915,
1616 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1617 'url': 'https://example.org/src/track3.mp3',
1619 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1620 'url': 'https://example.com/track3.mp3',
1626 for xspf_file
, xspf_url
, expected_entries
in _TEST_CASES
:
1627 with io
.open('./test/testdata/xspf/%s.xspf' % xspf_file
,
1628 mode
='r', encoding
='utf-8') as f
:
1629 entries
= self
.ie
._parse
_xspf
(
1630 compat_etree_fromstring(f
.read().encode('utf-8')),
1631 xspf_file
, xspf_url
=xspf_url
, xspf_base_url
=xspf_url
)
1632 expect_value(self
, entries
, expected_entries
, None)
1633 for i
in range(len(entries
)):
1634 expect_dict(self
, entries
[i
], expected_entries
[i
])
1636 def test_response_with_expected_status_returns_content(self
):
1637 # Checks for mitigations against the effects of
1638 # <https://bugs.python.org/issue15002> that affect Python 3.4.1+, which
1639 # manifest as `_download_webpage`, `_download_xml`, `_download_json`,
1640 # or the underlying `_download_webpage_handle` returning no content
1641 # when a response matches `expected_status`.
1643 httpd
= compat_http_server
.HTTPServer(
1644 ('127.0.0.1', 0), InfoExtractorTestRequestHandler
)
1645 port
= http_server_port(httpd
)
1646 server_thread
= threading
.Thread(target
=httpd
.serve_forever
)
1647 server_thread
.daemon
= True
1648 server_thread
.start()
1650 (content
, urlh
) = self
.ie
._download
_webpage
_handle
(
1651 'http://127.0.0.1:%d/teapot' % port
, None,
1652 expected_status
=TEAPOT_RESPONSE_STATUS
)
1653 self
.assertEqual(content
, TEAPOT_RESPONSE_BODY
)
1656 if __name__
== '__main__':