3 # Allow direct execution
8 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
14 from test
.helper
import FakeYDL
, expect_dict
, expect_value
, http_server_port
15 from yt_dlp
.compat
import compat_etree_fromstring
16 from yt_dlp
.extractor
import YoutubeIE
, get_info_extractor
17 from yt_dlp
.extractor
.common
import InfoExtractor
18 from yt_dlp
.utils
import (
25 TEAPOT_RESPONSE_STATUS
= 418
26 TEAPOT_RESPONSE_BODY
= "<h1>418 I'm a teapot</h1>"
29 class InfoExtractorTestRequestHandler(http
.server
.BaseHTTPRequestHandler
):
30 def log_message(self
, format
, *args
):
34 if self
.path
== '/teapot':
35 self
.send_response(TEAPOT_RESPONSE_STATUS
)
36 self
.send_header('Content-Type', 'text/html; charset=utf-8')
38 self
.wfile
.write(TEAPOT_RESPONSE_BODY
.encode())
43 class DummyIE(InfoExtractor
):
47 class TestInfoExtractor(unittest
.TestCase
):
49 self
.ie
= DummyIE(FakeYDL())
51 def test_ie_key(self
):
52 self
.assertEqual(get_info_extractor(YoutubeIE
.ie_key()), YoutubeIE
)
54 def test_html_search_regex(self
):
55 html
= '<p id="foo">Watch this <a href="http://www.youtube.com/watch?v=BaW_jenozKc">video</a></p>'
56 search
= lambda re
, *args
: self
.ie
._html
_search
_regex
(re
, html
, *args
)
57 self
.assertEqual(search(r
'<p id="foo">(.+?)</p>', 'foo'), 'Watch this video')
59 def test_opengraph(self
):
62 <meta name="og:title" content='Foo'/>
63 <meta content="Some video's description " name="og:description"/>
64 <meta property='og:image' content='http://domain.com/pic.jpg?key1=val1&key2=val2'/>
65 <meta content='application/x-shockwave-flash' property='og:video:type'>
66 <meta content='Foo' property=og:foobar>
67 <meta name="og:test1" content='foo > < bar'/>
68 <meta name="og:test2" content="foo >//< bar"/>
69 <meta property=og-test3 content='Ill-formatted opengraph'/>
71 self
.assertEqual(ie
._og
_search
_title
(html
), 'Foo')
72 self
.assertEqual(ie
._og
_search
_description
(html
), 'Some video\'s description ')
73 self
.assertEqual(ie
._og
_search
_thumbnail
(html
), 'http://domain.com/pic.jpg?key1=val1&key2=val2')
74 self
.assertEqual(ie
._og
_search
_video
_url
(html
, default
=None), None)
75 self
.assertEqual(ie
._og
_search
_property
('foobar', html
), 'Foo')
76 self
.assertEqual(ie
._og
_search
_property
('test1', html
), 'foo > < bar')
77 self
.assertEqual(ie
._og
_search
_property
('test2', html
), 'foo >//< bar')
78 self
.assertEqual(ie
._og
_search
_property
('test3', html
), 'Ill-formatted opengraph')
79 self
.assertEqual(ie
._og
_search
_property
(('test0', 'test1'), html
), 'foo > < bar')
80 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, 'test0', html
, None, fatal
=True)
81 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, ('test0', 'test00'), html
, None, fatal
=True)
83 def test_html_search_meta(self
):
86 <meta name="a" content="1" />
87 <meta name='b' content='2'>
88 <meta name="c" content='3'>
89 <meta name=d content='4'>
90 <meta property="e" content='5' >
91 <meta content="6" name="f">
94 self
.assertEqual(ie
._html
_search
_meta
('a', html
), '1')
95 self
.assertEqual(ie
._html
_search
_meta
('b', html
), '2')
96 self
.assertEqual(ie
._html
_search
_meta
('c', html
), '3')
97 self
.assertEqual(ie
._html
_search
_meta
('d', html
), '4')
98 self
.assertEqual(ie
._html
_search
_meta
('e', html
), '5')
99 self
.assertEqual(ie
._html
_search
_meta
('f', html
), '6')
100 self
.assertEqual(ie
._html
_search
_meta
(('a', 'b', 'c'), html
), '1')
101 self
.assertEqual(ie
._html
_search
_meta
(('c', 'b', 'a'), html
), '3')
102 self
.assertEqual(ie
._html
_search
_meta
(('z', 'x', 'c'), html
), '3')
103 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, 'z', html
, None, fatal
=True)
104 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, ('z', 'x'), html
, None, fatal
=True)
106 def test_search_json_ld_realworld(self
):
108 # https://github.com/ytdl-org/youtube-dl/issues/23306
110 r
'''<script type="application/ld+json">
112 "@context": "http://schema.org/",
113 "@type": "VideoObject",
114 "name": "1 On 1 With Kleio",
115 "url": "https://www.eporner.com/hd-porn/xN49A1cT3eB/1-On-1-With-Kleio/",
116 "duration": "PT0H12M23S",
117 "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"],
118 "contentUrl": "https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4",
119 "embedUrl": "https://www.eporner.com/embed/xN49A1cT3eB/1-On-1-With-Kleio/",
120 "image": "https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg",
123 "encodingFormat": "mp4",
124 "bitrate": "6617kbps",
125 "isFamilyFriendly": "False",
126 "description": "Kleio Valentien",
127 "uploadDate": "2015-12-05T21:24:35+01:00",
128 "interactionStatistic": {
129 "@type": "InteractionCounter",
130 "interactionType": { "@type": "http://schema.org/WatchAction" },
131 "userInteractionCount": 1120958
132 }, "aggregateRating": {
133 "@type": "AggregateRating",
135 "ratingCount": "630",
140 "name": "Kleio Valentien",
141 "url": "https://www.eporner.com/pornstar/kleio-valentien/"
145 'title': '1 On 1 With Kleio',
146 'description': 'Kleio Valentien',
147 'url': 'https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4',
148 'timestamp': 1449347075,
150 'view_count': 1120958,
157 r
'''<script type="application/ld+json">
159 "@context": "https://schema.org",
162 "@type": "NewsArticle",
163 "mainEntityOfPage": {
165 "@id": "https://www.ant1news.gr/Society/article/620286/symmoria-anilikon-dikigoros-thymaton-ithelan-na-toys-apoteleiosoyn"
167 "headline": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
168 "name": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
169 "description": "Τα παιδιά δέχθηκαν την επίθεση επειδή αρνήθηκαν να γίνουν μέλη της συμμορίας, ανέφερε ο Γ. Ζαχαρόπουλος.",
171 "@type": "ImageObject",
172 "url": "https://ant1media.azureedge.net/imgHandler/1100/a635c968-be71-447c-bf9c-80d843ece21e.jpg",
175 "datePublished": "2021-11-10T08:50:00+03:00",
176 "dateModified": "2021-11-10T08:52:53+03:00",
179 "@id": "https://www.ant1news.gr/",
181 "image": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
182 "url": "https://www.ant1news.gr/"
185 "@type": "Organization",
186 "@id": "https://www.ant1news.gr#publisher",
188 "url": "https://www.ant1news.gr",
190 "@type": "ImageObject",
191 "url": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
195 "https://www.facebook.com/Ant1news.gr",
196 "https://twitter.com/antennanews",
197 "https://www.youtube.com/channel/UC0smvAbfczoN75dP0Hw4Pzw",
198 "https://www.instagram.com/ant1news/"
202 "keywords": "μαχαίρωμα,συμμορία ανηλίκων,ΕΙΔΗΣΕΙΣ,ΕΙΔΗΣΕΙΣ ΣΗΜΕΡΑ,ΝΕΑ,Κοινωνία - Ant1news",
205 "articleSection": "Κοινωνία"
211 'timestamp': 1636523400,
212 'title': 'md5:91fe569e952e4d146485740ae927662b',
214 {'expected_type': 'NewsArticle'},
217 r
'''<script type="application/ld+json">
218 {"url":"/vrtnu/a-z/het-journaal/2021/het-journaal-het-journaal-19u-20211231/",
219 "name":"Het journaal 19u",
220 "description":"Het journaal 19u van vrijdag 31 december 2021.",
221 "potentialAction":{"url":"https://vrtnu.page.link/pfVy6ihgCAJKgHqe8","@type":"ShareAction"},
222 "mainEntityOfPage":{"@id":"1640092242445","@type":"WebPage"},
224 "startDate":"2021-12-31T19:00:00.000+01:00",
225 "endDate":"2022-01-30T23:55:00.000+01:00",
226 "publishedBy":{"name":"een","@type":"Organization"},
227 "publishedOn":{"url":"https://www.vrt.be/vrtnu/","name":"VRT NU","@type":"BroadcastService"},
228 "@id":"pbs-pub-3a7ec233-da95-4c1e-9b2b-cf5fdfebcbe8",
229 "@type":"BroadcastEvent"
232 "name":"Het journaal - Aflevering 365 (Seizoen 2021)",
233 "description":"Het journaal 19u van vrijdag 31 december 2021. Bekijk aflevering 365 van seizoen 2021 met VRT NU via de site of app.",
234 "thumbnailUrl":"//images.vrt.be/width1280/2021/12/31/80d5ed00-6a64-11ec-b07d-02b7b76bf47f.jpg",
235 "expires":"2022-01-30T23:55:00.000+01:00",
237 {"name":"Explosie Turnhout","startOffset":70,"@type":"Clip"},
238 {"name":"Jaarwisseling","startOffset":440,"@type":"Clip"},
239 {"name":"Natuurbranden Colorado","startOffset":1179,"@type":"Clip"},
240 {"name":"Klimaatverandering","startOffset":1263,"@type":"Clip"},
241 {"name":"Zacht weer","startOffset":1367,"@type":"Clip"},
242 {"name":"Financiële balans","startOffset":1383,"@type":"Clip"},
243 {"name":"Club Brugge","startOffset":1484,"@type":"Clip"},
244 {"name":"Mentale gezondheid bij topsporters","startOffset":1575,"@type":"Clip"},
245 {"name":"Olympische Winterspelen","startOffset":1728,"@type":"Clip"},
246 {"name":"Sober oudjaar in Nederland","startOffset":1873,"@type":"Clip"}
248 "duration":"PT34M39.23S",
249 "uploadDate":"2021-12-31T19:00:00.000+01:00",
250 "@id":"vid-9457d0c6-b8ac-4aba-b5e1-15aa3a3295b5",
251 "@type":"VideoObject"
253 "genre":["Nieuws en actua"],
255 "partOfSeries":{"name":"Het journaal","@id":"222831405527","@type":"TVSeries"},
256 "partOfSeason":{"name":"Seizoen 2021","@id":"961809365527","@type":"TVSeason"},
257 "@context":"https://schema.org","@id":"961685295527","@type":"TVEpisode"}</script>
261 {"title": "Explosie Turnhout", "start_time": 70, "end_time": 440},
262 {"title": "Jaarwisseling", "start_time": 440, "end_time": 1179},
263 {"title": "Natuurbranden Colorado", "start_time": 1179, "end_time": 1263},
264 {"title": "Klimaatverandering", "start_time": 1263, "end_time": 1367},
265 {"title": "Zacht weer", "start_time": 1367, "end_time": 1383},
266 {"title": "Financiële balans", "start_time": 1383, "end_time": 1484},
267 {"title": "Club Brugge", "start_time": 1484, "end_time": 1575},
268 {"title": "Mentale gezondheid bij topsporters", "start_time": 1575, "end_time": 1728},
269 {"title": "Olympische Winterspelen", "start_time": 1728, "end_time": 1873},
270 {"title": "Sober oudjaar in Nederland", "start_time": 1873, "end_time": 2079.23}
272 'title': 'Het journaal - Aflevering 365 (Seizoen 2021)'
276 # test multiple thumbnails in a list
278 <script type="application/ld+json">
279 {"@context":"https://schema.org",
280 "@type":"VideoObject",
281 "thumbnailUrl":["https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"]}
284 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}],
289 # test single thumbnail
291 <script type="application/ld+json">
292 {"@context":"https://schema.org",
293 "@type":"VideoObject",
294 "thumbnailUrl":"https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"}
297 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}],
302 for html
, expected_dict
, search_json_ld_kwargs
in _TESTS
:
305 self
.ie
._search
_json
_ld
(html
, None, **search_json_ld_kwargs
),
309 def test_download_json(self
):
310 uri
= encode_data_uri(b
'{"foo": "blah"}', 'application/json')
311 self
.assertEqual(self
.ie
._download
_json
(uri
, None), {'foo': 'blah'})
312 uri
= encode_data_uri(b
'callback({"foo": "blah"})', 'application/javascript')
313 self
.assertEqual(self
.ie
._download
_json
(uri
, None, transform_source
=strip_jsonp
), {'foo': 'blah'})
314 uri
= encode_data_uri(b
'{"foo": invalid}', 'application/json')
315 self
.assertRaises(ExtractorError
, self
.ie
._download
_json
, uri
, None)
316 self
.assertEqual(self
.ie
._download
_json
(uri
, None, fatal
=False), None)
318 def test_parse_html5_media_entries(self
):
322 self
.ie
._parse
_html
5_media
_entries
(
323 'https://127.0.0.1/video.html',
324 r
'<html><video src="/vid.mp4" /></html>', None)[0],
327 'url': 'https://127.0.0.1/vid.mp4',
331 # from https://www.r18.com/
335 self
.ie
._parse
_html
5_media
_entries
(
336 'https://www.r18.com/',
338 <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">
339 <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">
340 <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">
341 <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">
342 <p>Your browser does not support the video tag.</p>
347 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4',
349 'format_id': '300kbps',
353 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4',
355 'format_id': '1000kbps',
359 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4',
361 'format_id': '1500kbps',
365 'thumbnail': '//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg'
368 # from https://www.csfd.cz/
369 # with width and height
372 self
.ie
._parse
_html
5_media
_entries
(
373 'https://www.csfd.cz/',
375 <video width="770" height="328" preload="none" controls poster="https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360" >
376 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4" type="video/mp4" width="640" height="360">
377 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4" type="video/mp4" width="1280" height="720">
378 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4" type="video/mp4" width="1920" height="1080">
379 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm" type="video/webm" width="640" height="360">
380 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm" type="video/webm" width="1280" height="720">
381 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm" type="video/webm" width="1920" height="1080">
382 <track src="https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt" type="text/x-srt" kind="subtitles" srclang="cs" label="cs">
387 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4',
392 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4',
397 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4',
402 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm',
407 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm',
412 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm',
418 'cs': [{'url': 'https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt'}]
420 'thumbnail': 'https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360'
423 # from https://tamasha.com/v/Kkdjw
424 # with height in label
427 self
.ie
._parse
_html
5_media
_entries
(
428 'https://tamasha.com/v/Kkdjw',
430 <video crossorigin="anonymous">
431 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4" label="AUTO" res="0"/>
432 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4"
433 label="240p" res="240"/>
434 <source src="https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4" type="video/mp4"
435 label="144p" res="144"/>
440 '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/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
447 'url': 'https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4',
454 # from https://www.directvnow.com
458 self
.ie
._parse
_html
5_media
_entries
(
459 'https://www.directvnow.com',
461 <video id="vid1" class="header--video-masked active" muted playsinline>
462 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
468 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
472 # from https://www.directvnow.com
476 self
.ie
._parse
_html
5_media
_entries
(
477 'https://www.directvnow.com',
479 <video id="vid1" class="header--video-masked active" muted playsinline>
480 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
485 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
490 # from https://www.klarna.com/uk/
491 # with data-video-src
494 self
.ie
._parse
_html
5_media
_entries
(
495 'https://www.directvnow.com',
497 <video loop autoplay muted class="responsive-video block-kl__video video-on-medium">
498 <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" />
503 'url': 'https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4',
508 # from https://0000.studio/
509 # with type attribute but without extension in URL
512 self
.ie
._parse
_html
5_media
_entries
(
513 'https://0000.studio',
515 <video src="https://d1ggyt9m8pwf3g.cloudfront.net/protected/ap-northeast-1:1864af40-28d5-492b-b739-b32314b1a527/archive/clip/838db6a7-8973-4cd6-840d-8517e4093c92"
516 controls="controls" type="video/mp4" preload="metadata" autoplay="autoplay" playsinline class="object-contain">
521 'url': 'https://d1ggyt9m8pwf3g.cloudfront.net/protected/ap-northeast-1:1864af40-28d5-492b-b739-b32314b1a527/archive/clip/838db6a7-8973-4cd6-840d-8517e4093c92',
526 def test_extract_jwplayer_data_realworld(self
):
527 # from http://www.suffolk.edu/sjc/
530 self
.ie
._extract
_jwplayer
_data
(r
'''
531 <script type='text/javascript'>
532 jwplayer('my-video').setup({
533 file: 'rtmp://192.138.214.154/live/sjclive',
541 ''', None, require_title
=False),
545 'url': 'rtmp://192.138.214.154/live/sjclive',
550 # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/
553 self
.ie
._extract
_jwplayer
_data
(r
'''
554 <script type="text/javascript">
555 jwplayer("mediaplayer").setup({
558 'aspectratio': "16:9",
559 'stretching': "exactfit",
560 'autostart': 'false',
561 'flashplayer': "https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf",
562 '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",
563 'image': "https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg",
564 '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",
566 'skin': "https://t04.vipstreamservice.com/jwplayer/skin/modieus-blk.zip",
567 'plugins': "https://t04.vipstreamservice.com/jwplayer/dock/dockableskinnableplugin.swf",
568 'dockableskinnableplugin.piclink': "/index.php?key=ajax-videothumbsn&vid=7564&data=2009-12--14--4b2157147afe5efa93ce1978e0265289c193874e02597.flv--17370",
569 'controlbar': 'bottom',
571 {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'}
575 //noinspection JSAnnotator
577 adsUrl: "/banner-iframe/?zoneId=32",
582 ''', 'dummy', require_title
=False),
584 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg',
586 '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',
591 # from http://www.indiedb.com/games/king-machine/videos
594 self
.ie
._extract
_jwplayer
_data
(r
'''
596 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) {
597 videoAnalytics("play");
598 }).once("complete", function(event) {
599 videoAnalytics("completed");
604 'title': 'king machine trailer 1',
605 'thumbnail': 'http://media.indiedb.com/cache/images/games/1/50/49678/thumb_620x2000/king-machine-trailer.mp4.jpg',
607 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4',
611 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4',
617 def test_parse_m3u8_formats(self
):
620 # https://github.com/ytdl-org/youtube-dl/issues/11995
621 # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor
622 'img_bipbop_adv_example_fmp4',
623 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
625 'format_id': 'aud1-English',
626 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a1/prog_index.m3u8',
627 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
630 'protocol': 'm3u8_native',
633 'format_id': 'aud2-English',
634 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a2/prog_index.m3u8',
635 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
638 'protocol': 'm3u8_native',
641 'format_id': 'aud3-English',
642 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a3/prog_index.m3u8',
643 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
646 'protocol': 'm3u8_native',
650 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
651 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
653 'protocol': 'm3u8_native',
656 'vcodec': 'avc1.640015',
659 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
660 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
662 'protocol': 'm3u8_native',
665 'vcodec': 'avc1.640015',
668 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
669 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
671 'protocol': 'm3u8_native',
674 'vcodec': 'avc1.640015',
677 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
678 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
680 'protocol': 'm3u8_native',
683 'vcodec': 'avc1.64001e',
686 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
687 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
689 'protocol': 'm3u8_native',
692 'vcodec': 'avc1.64001e',
695 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
696 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
698 'protocol': 'm3u8_native',
701 'vcodec': 'avc1.64001e',
704 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
705 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
707 'protocol': 'm3u8_native',
710 'vcodec': 'avc1.64001e',
713 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
714 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
716 'protocol': 'm3u8_native',
719 'vcodec': 'avc1.64001e',
722 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
723 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
725 'protocol': 'm3u8_native',
728 'vcodec': 'avc1.64001e',
731 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
732 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
734 'protocol': 'm3u8_native',
737 'vcodec': 'avc1.640020',
740 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
741 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
743 'protocol': 'm3u8_native',
746 'vcodec': 'avc1.640020',
749 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
750 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
752 'protocol': 'm3u8_native',
755 'vcodec': 'avc1.640020',
758 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
759 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
761 'protocol': 'm3u8_native',
764 'vcodec': 'avc1.640020',
767 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
768 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
770 'protocol': 'm3u8_native',
773 'vcodec': 'avc1.640020',
776 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
777 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
779 'protocol': 'm3u8_native',
782 'vcodec': 'avc1.640020',
785 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
786 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
788 'protocol': 'm3u8_native',
791 'vcodec': 'avc1.64002a',
794 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
795 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
797 'protocol': 'm3u8_native',
800 'vcodec': 'avc1.64002a',
803 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
804 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
806 'protocol': 'm3u8_native',
809 'vcodec': 'avc1.64002a',
812 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
813 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
815 'protocol': 'm3u8_native',
818 'vcodec': 'avc1.64002a',
821 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
822 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
824 'protocol': 'm3u8_native',
827 'vcodec': 'avc1.64002a',
830 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
831 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
833 'protocol': 'm3u8_native',
836 'vcodec': 'avc1.64002a',
839 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
840 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
842 'protocol': 'm3u8_native',
845 'vcodec': 'avc1.64002a',
848 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
849 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
851 'protocol': 'm3u8_native',
854 'vcodec': 'avc1.64002a',
857 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
858 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
860 'protocol': 'm3u8_native',
863 'vcodec': 'avc1.64002a',
869 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
871 'format_id': 'bipbop_audio-BipBop Audio 2',
872 'format_index': None,
873 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/alternate_audio_aac/prog_index.m3u8',
874 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
877 'protocol': 'm3u8_native',
885 'format_index': None,
886 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8',
887 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
891 'protocol': 'm3u8_native',
895 'acodec': 'mp4a.40.2',
901 'format_index': None,
902 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8',
903 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
907 'protocol': 'm3u8_native',
912 'vcodec': 'avc1.4d400d',
913 'acodec': 'mp4a.40.2',
920 'format_index': None,
921 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8',
922 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
926 'protocol': 'm3u8_native',
931 'vcodec': 'avc1.4d401e',
932 'acodec': 'mp4a.40.2',
939 'format_index': None,
940 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8',
941 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
945 'protocol': 'm3u8_native',
950 'vcodec': 'avc1.4d401f',
951 'acodec': 'mp4a.40.2',
958 'format_index': None,
959 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8',
960 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
964 'protocol': 'm3u8_native',
969 'vcodec': 'avc1.4d401f',
970 'acodec': 'mp4a.40.2',
977 'format_index': None,
978 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8',
979 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
983 'protocol': 'm3u8_native',
988 'vcodec': 'avc1.4d401f',
989 'acodec': 'mp4a.40.2',
997 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng/prog_index.m3u8',
999 'protocol': 'm3u8_native'
1001 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng_forced/prog_index.m3u8',
1003 'protocol': 'm3u8_native'
1006 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra/prog_index.m3u8',
1008 'protocol': 'm3u8_native'
1010 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra_forced/prog_index.m3u8',
1012 'protocol': 'm3u8_native'
1015 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa/prog_index.m3u8',
1017 'protocol': 'm3u8_native'
1019 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa_forced/prog_index.m3u8',
1021 'protocol': 'm3u8_native'
1024 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn/prog_index.m3u8',
1026 'protocol': 'm3u8_native'
1028 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn_forced/prog_index.m3u8',
1030 'protocol': 'm3u8_native'
1036 for m3u8_file
, m3u8_url
, expected_formats
, expected_subs
in _TEST_CASES
:
1037 with
open('./test/testdata/m3u8/%s.m3u8' % m3u8_file
, encoding
='utf-8') as f
:
1038 formats
, subs
= self
.ie
._parse
_m
3u8_formats
_and
_subtitles
(
1039 f
.read(), m3u8_url
, ext
='mp4')
1040 self
.ie
._sort
_formats
(formats
)
1041 expect_value(self
, formats
, expected_formats
, None)
1042 expect_value(self
, subs
, expected_subs
, None)
1044 def test_parse_mpd_formats(self
):
1047 # https://github.com/ytdl-org/youtube-dl/issues/13919
1048 # Also tests duplicate representation ids, see
1049 # https://github.com/ytdl-org/youtube-dl/issues/15111
1051 'http://unknown/manifest.mpd', # mpd_url
1052 None, # mpd_base_url
1054 'manifest_url': 'http://unknown/manifest.mpd',
1056 'format_id': '318597',
1057 'format_note': 'DASH audio',
1058 'protocol': 'http_dash_segments',
1059 'acodec': 'mp4a.40.2',
1063 'manifest_url': 'http://unknown/manifest.mpd',
1065 'format_id': '318597',
1066 'format_note': 'DASH video',
1067 'protocol': 'http_dash_segments',
1069 'vcodec': 'avc1.42001f',
1074 'manifest_url': 'http://unknown/manifest.mpd',
1076 'format_id': '638590',
1077 'format_note': 'DASH video',
1078 'protocol': 'http_dash_segments',
1080 'vcodec': 'avc1.42001f',
1085 'manifest_url': 'http://unknown/manifest.mpd',
1087 'format_id': '1022565',
1088 'format_note': 'DASH video',
1089 'protocol': 'http_dash_segments',
1091 'vcodec': 'avc1.4d001f',
1096 'manifest_url': 'http://unknown/manifest.mpd',
1098 'format_id': '2046506',
1099 'format_note': 'DASH video',
1100 'protocol': 'http_dash_segments',
1102 'vcodec': 'avc1.4d001f',
1107 'manifest_url': 'http://unknown/manifest.mpd',
1109 'format_id': '3998017',
1110 'format_note': 'DASH video',
1111 'protocol': 'http_dash_segments',
1113 'vcodec': 'avc1.640029',
1118 'manifest_url': 'http://unknown/manifest.mpd',
1120 'format_id': '5997485',
1121 'format_note': 'DASH video',
1122 'protocol': 'http_dash_segments',
1124 'vcodec': 'avc1.640032',
1131 # https://github.com/ytdl-org/youtube-dl/pull/14844
1133 'http://unknown/manifest.mpd', # mpd_url
1134 None, # mpd_base_url
1136 'manifest_url': 'http://unknown/manifest.mpd',
1138 'format_id': 'h264_aac_144p_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_240p_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_360p_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_480p_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_576p_m4s',
1183 'format_note': 'DASH video',
1184 'protocol': 'http_dash_segments',
1185 'acodec': 'mp4a.40.2',
1186 'vcodec': 'avc3.42c01e',
1191 'manifest_url': 'http://unknown/manifest.mpd',
1193 'format_id': 'h264_aac_720p_m4s',
1194 'format_note': 'DASH video',
1195 'protocol': 'http_dash_segments',
1196 'acodec': 'mp4a.40.2',
1197 'vcodec': 'avc3.42c01e',
1202 'manifest_url': 'http://unknown/manifest.mpd',
1204 'format_id': 'h264_aac_1080p_m4s',
1205 'format_note': 'DASH video',
1206 'protocol': 'http_dash_segments',
1207 'acodec': 'mp4a.40.2',
1208 'vcodec': 'avc3.42c01e',
1215 # https://github.com/ytdl-org/youtube-dl/issues/20346
1216 # Media considered unfragmented even though it contains
1217 # Initialization tag
1219 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', # mpd_url
1220 'https://v.redd.it/hw1x7rcg7zl21', # mpd_base_url
1222 'url': 'https://v.redd.it/hw1x7rcg7zl21/audio',
1223 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1225 'format_id': 'AUDIO-1',
1226 'format_note': 'DASH audio',
1227 'container': 'm4a_dash',
1228 'acodec': 'mp4a.40.2',
1234 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240',
1235 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1237 'format_id': 'VIDEO-2',
1238 'format_note': 'DASH video',
1239 'container': 'mp4_dash',
1241 'vcodec': 'avc1.4d401e',
1247 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_360',
1248 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1250 'format_id': 'VIDEO-1',
1251 'format_note': 'DASH video',
1252 'container': 'mp4_dash',
1254 'vcodec': 'avc1.4d401e',
1263 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1264 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/',
1266 'format_id': 'audio=128001',
1267 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1271 'format_note': 'DASH audio',
1272 'container': 'm4a_dash',
1274 'acodec': 'mp4a.40.2',
1275 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1276 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1277 'protocol': 'http_dash_segments',
1279 'video_ext': 'none',
1282 'format_id': 'video=100000',
1283 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1288 'format_note': 'DASH video',
1289 'container': 'mp4_dash',
1290 'vcodec': 'avc1.4D401F',
1292 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1293 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1294 'protocol': 'http_dash_segments',
1296 'audio_ext': 'none',
1299 'format_id': 'video=326000',
1300 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1305 'format_note': 'DASH video',
1306 'container': 'mp4_dash',
1307 'vcodec': 'avc1.4D401F',
1309 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1310 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1311 'protocol': 'http_dash_segments',
1313 'audio_ext': 'none',
1316 'format_id': 'video=698000',
1317 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1322 'format_note': 'DASH video',
1323 'container': 'mp4_dash',
1324 'vcodec': 'avc1.4D401F',
1326 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1327 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1328 'protocol': 'http_dash_segments',
1330 'audio_ext': 'none',
1333 'format_id': 'video=1493000',
1334 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1339 'format_note': 'DASH video',
1340 'container': 'mp4_dash',
1341 'vcodec': 'avc1.4D401F',
1343 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1344 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1345 'protocol': 'http_dash_segments',
1347 'audio_ext': 'none',
1350 'format_id': 'video=4482000',
1351 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1356 'format_note': 'DASH video',
1357 'container': 'mp4_dash',
1358 'vcodec': 'avc1.4D401F',
1360 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1361 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1362 'protocol': 'http_dash_segments',
1364 'audio_ext': 'none',
1371 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1372 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1373 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1374 'protocol': 'http_dash_segments',
1381 for mpd_file
, mpd_url
, mpd_base_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1382 with
open('./test/testdata/mpd/%s.mpd' % mpd_file
, encoding
='utf-8') as f
:
1383 formats
, subtitles
= self
.ie
._parse
_mpd
_formats
_and
_subtitles
(
1384 compat_etree_fromstring(f
.read().encode()),
1385 mpd_base_url
=mpd_base_url
, mpd_url
=mpd_url
)
1386 self
.ie
._sort
_formats
(formats
)
1387 expect_value(self
, formats
, expected_formats
, None)
1388 expect_value(self
, subtitles
, expected_subtitles
, None)
1390 def test_parse_ism_formats(self
):
1394 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1396 'format_id': 'audio-128',
1397 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1398 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1405 '_download_params': {
1406 'stream_type': 'audio',
1407 'duration': 8880746666,
1408 'timescale': 10000000,
1412 'codec_private_data': '1190',
1413 'sampling_rate': 48000,
1415 'bits_per_sample': 16,
1416 'nal_unit_length_field': 4
1418 'audio_ext': 'isma',
1419 'video_ext': 'none',
1422 'format_id': 'video-100',
1423 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1424 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1432 '_download_params': {
1433 'stream_type': 'video',
1434 'duration': 8880746666,
1435 'timescale': 10000000,
1439 'codec_private_data': '00000001674D401FDA0544EFFC2D002CBC40000003004000000C03C60CA80000000168EF32C8',
1441 'bits_per_sample': 16,
1442 'nal_unit_length_field': 4
1444 'video_ext': 'ismv',
1445 'audio_ext': 'none',
1448 'format_id': 'video-326',
1449 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1450 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1458 '_download_params': {
1459 'stream_type': 'video',
1460 'duration': 8880746666,
1461 'timescale': 10000000,
1465 'codec_private_data': '00000001674D401FDA0241FE23FFC3BC83BA44000003000400000300C03C60CA800000000168EF32C8',
1467 'bits_per_sample': 16,
1468 'nal_unit_length_field': 4
1470 'video_ext': 'ismv',
1471 'audio_ext': 'none',
1474 'format_id': 'video-698',
1475 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1476 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1484 '_download_params': {
1485 'stream_type': 'video',
1486 'duration': 8880746666,
1487 'timescale': 10000000,
1491 'codec_private_data': '00000001674D401FDA0350BFB97FF06AF06AD1000003000100000300300F1832A00000000168EF32C8',
1493 'bits_per_sample': 16,
1494 'nal_unit_length_field': 4
1496 'video_ext': 'ismv',
1497 'audio_ext': 'none',
1500 'format_id': 'video-1493',
1501 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1502 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1510 '_download_params': {
1511 'stream_type': 'video',
1512 'duration': 8880746666,
1513 'timescale': 10000000,
1517 'codec_private_data': '00000001674D401FDA011C3DE6FFF0D890D871000003000100000300300F1832A00000000168EF32C8',
1519 'bits_per_sample': 16,
1520 'nal_unit_length_field': 4
1522 'video_ext': 'ismv',
1523 'audio_ext': 'none',
1526 'format_id': 'video-4482',
1527 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1528 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1536 '_download_params': {
1537 'stream_type': 'video',
1538 'duration': 8880746666,
1539 'timescale': 10000000,
1543 'codec_private_data': '00000001674D401FDA01A816F97FFC1ABC1AB440000003004000000C03C60CA80000000168EF32C8',
1545 'bits_per_sample': 16,
1546 'nal_unit_length_field': 4
1548 'video_ext': 'ismv',
1549 'audio_ext': 'none',
1557 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1558 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1559 '_download_params': {
1560 'stream_type': 'text',
1561 'duration': 8880746666,
1562 'timescale': 10000000,
1564 'codec_private_data': ''
1572 for ism_file
, ism_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1573 with
open('./test/testdata/ism/%s.Manifest' % ism_file
, encoding
='utf-8') as f
:
1574 formats
, subtitles
= self
.ie
._parse
_ism
_formats
_and
_subtitles
(
1575 compat_etree_fromstring(f
.read().encode()), ism_url
=ism_url
)
1576 self
.ie
._sort
_formats
(formats
)
1577 expect_value(self
, formats
, expected_formats
, None)
1578 expect_value(self
, subtitles
, expected_subtitles
, None)
1580 def test_parse_f4m_formats(self
):
1583 # https://github.com/ytdl-org/youtube-dl/issues/14660
1585 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1587 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1589 'format_id': '2148',
1598 for f4m_file
, f4m_url
, expected_formats
in _TEST_CASES
:
1599 with
open('./test/testdata/f4m/%s.f4m' % f4m_file
, encoding
='utf-8') as f
:
1600 formats
= self
.ie
._parse
_f
4m
_formats
(
1601 compat_etree_fromstring(f
.read().encode()),
1603 self
.ie
._sort
_formats
(formats
)
1604 expect_value(self
, formats
, expected_formats
, None)
1606 def test_parse_xspf(self
):
1610 'https://example.org/src/foo_xspf.xspf',
1613 'title': 'Pandemonium',
1614 'description': 'Visit http://bigbrother404.bandcamp.com',
1615 'duration': 202.416,
1617 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1618 'url': 'https://example.org/src/cd1/track%201.mp3',
1622 'title': 'Final Cartridge (Nichico Twelve Remix)',
1623 'description': 'Visit http://bigbrother404.bandcamp.com',
1624 'duration': 255.857,
1626 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1627 'url': 'https://example.org/%E3%83%88%E3%83%A9%E3%83%83%E3%82%AF%E3%80%80%EF%BC%92.mp3',
1631 'title': 'Rebuilding Nightingale',
1632 'description': 'Visit http://bigbrother404.bandcamp.com',
1633 'duration': 287.915,
1635 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1636 'url': 'https://example.org/src/track3.mp3',
1638 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1639 'url': 'https://example.com/track3.mp3',
1645 for xspf_file
, xspf_url
, expected_entries
in _TEST_CASES
:
1646 with
open('./test/testdata/xspf/%s.xspf' % xspf_file
, encoding
='utf-8') as f
:
1647 entries
= self
.ie
._parse
_xspf
(
1648 compat_etree_fromstring(f
.read().encode()),
1649 xspf_file
, xspf_url
=xspf_url
, xspf_base_url
=xspf_url
)
1650 expect_value(self
, entries
, expected_entries
, None)
1651 for i
in range(len(entries
)):
1652 expect_dict(self
, entries
[i
], expected_entries
[i
])
1654 def test_response_with_expected_status_returns_content(self
):
1655 # Checks for mitigations against the effects of
1656 # <https://bugs.python.org/issue15002> that affect Python 3.4.1+, which
1657 # manifest as `_download_webpage`, `_download_xml`, `_download_json`,
1658 # or the underlying `_download_webpage_handle` returning no content
1659 # when a response matches `expected_status`.
1661 httpd
= http
.server
.HTTPServer(
1662 ('127.0.0.1', 0), InfoExtractorTestRequestHandler
)
1663 port
= http_server_port(httpd
)
1664 server_thread
= threading
.Thread(target
=httpd
.serve_forever
)
1665 server_thread
.daemon
= True
1666 server_thread
.start()
1668 (content
, urlh
) = self
.ie
._download
_webpage
_handle
(
1669 'http://127.0.0.1:%d/teapot' % port
, None,
1670 expected_status
=TEAPOT_RESPONSE_STATUS
)
1671 self
.assertEqual(content
, TEAPOT_RESPONSE_BODY
)
1674 if __name__
== '__main__':