2 # Allow direct execution
7 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
13 from test
.helper
import FakeYDL
, expect_dict
, expect_value
, http_server_port
14 from yt_dlp
.compat
import compat_etree_fromstring
15 from yt_dlp
.extractor
import YoutubeIE
, get_info_extractor
16 from yt_dlp
.extractor
.common
import InfoExtractor
17 from yt_dlp
.utils
import (
24 TEAPOT_RESPONSE_STATUS
= 418
25 TEAPOT_RESPONSE_BODY
= "<h1>418 I'm a teapot</h1>"
28 class InfoExtractorTestRequestHandler(http
.server
.BaseHTTPRequestHandler
):
29 def log_message(self
, format
, *args
):
33 if self
.path
== '/teapot':
34 self
.send_response(TEAPOT_RESPONSE_STATUS
)
35 self
.send_header('Content-Type', 'text/html; charset=utf-8')
37 self
.wfile
.write(TEAPOT_RESPONSE_BODY
.encode())
42 class DummyIE(InfoExtractor
):
46 class TestInfoExtractor(unittest
.TestCase
):
48 self
.ie
= DummyIE(FakeYDL())
50 def test_ie_key(self
):
51 self
.assertEqual(get_info_extractor(YoutubeIE
.ie_key()), YoutubeIE
)
53 def test_html_search_regex(self
):
54 html
= '<p id="foo">Watch this <a href="http://www.youtube.com/watch?v=BaW_jenozKc">video</a></p>'
55 search
= lambda re
, *args
: self
.ie
._html
_search
_regex
(re
, html
, *args
)
56 self
.assertEqual(search(r
'<p id="foo">(.+?)</p>', 'foo'), 'Watch this video')
58 def test_opengraph(self
):
61 <meta name="og:title" content='Foo'/>
62 <meta content="Some video's description " name="og:description"/>
63 <meta property='og:image' content='http://domain.com/pic.jpg?key1=val1&key2=val2'/>
64 <meta content='application/x-shockwave-flash' property='og:video:type'>
65 <meta content='Foo' property=og:foobar>
66 <meta name="og:test1" content='foo > < bar'/>
67 <meta name="og:test2" content="foo >//< bar"/>
68 <meta property=og-test3 content='Ill-formatted opengraph'/>
70 self
.assertEqual(ie
._og
_search
_title
(html
), 'Foo')
71 self
.assertEqual(ie
._og
_search
_description
(html
), 'Some video\'s description ')
72 self
.assertEqual(ie
._og
_search
_thumbnail
(html
), 'http://domain.com/pic.jpg?key1=val1&key2=val2')
73 self
.assertEqual(ie
._og
_search
_video
_url
(html
, default
=None), None)
74 self
.assertEqual(ie
._og
_search
_property
('foobar', html
), 'Foo')
75 self
.assertEqual(ie
._og
_search
_property
('test1', html
), 'foo > < bar')
76 self
.assertEqual(ie
._og
_search
_property
('test2', html
), 'foo >//< bar')
77 self
.assertEqual(ie
._og
_search
_property
('test3', html
), 'Ill-formatted opengraph')
78 self
.assertEqual(ie
._og
_search
_property
(('test0', 'test1'), html
), 'foo > < bar')
79 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, 'test0', html
, None, fatal
=True)
80 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, ('test0', 'test00'), html
, None, fatal
=True)
82 def test_html_search_meta(self
):
85 <meta name="a" content="1" />
86 <meta name='b' content='2'>
87 <meta name="c" content='3'>
88 <meta name=d content='4'>
89 <meta property="e" content='5' >
90 <meta content="6" name="f">
93 self
.assertEqual(ie
._html
_search
_meta
('a', html
), '1')
94 self
.assertEqual(ie
._html
_search
_meta
('b', html
), '2')
95 self
.assertEqual(ie
._html
_search
_meta
('c', html
), '3')
96 self
.assertEqual(ie
._html
_search
_meta
('d', html
), '4')
97 self
.assertEqual(ie
._html
_search
_meta
('e', html
), '5')
98 self
.assertEqual(ie
._html
_search
_meta
('f', html
), '6')
99 self
.assertEqual(ie
._html
_search
_meta
(('a', 'b', 'c'), html
), '1')
100 self
.assertEqual(ie
._html
_search
_meta
(('c', 'b', 'a'), html
), '3')
101 self
.assertEqual(ie
._html
_search
_meta
(('z', 'x', 'c'), html
), '3')
102 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, 'z', html
, None, fatal
=True)
103 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, ('z', 'x'), html
, None, fatal
=True)
105 def test_search_json_ld_realworld(self
):
107 # https://github.com/ytdl-org/youtube-dl/issues/23306
109 r
'''<script type="application/ld+json">
111 "@context": "http://schema.org/",
112 "@type": "VideoObject",
113 "name": "1 On 1 With Kleio",
114 "url": "https://www.eporner.com/hd-porn/xN49A1cT3eB/1-On-1-With-Kleio/",
115 "duration": "PT0H12M23S",
116 "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"],
117 "contentUrl": "https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4",
118 "embedUrl": "https://www.eporner.com/embed/xN49A1cT3eB/1-On-1-With-Kleio/",
119 "image": "https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg",
122 "encodingFormat": "mp4",
123 "bitrate": "6617kbps",
124 "isFamilyFriendly": "False",
125 "description": "Kleio Valentien",
126 "uploadDate": "2015-12-05T21:24:35+01:00",
127 "interactionStatistic": {
128 "@type": "InteractionCounter",
129 "interactionType": { "@type": "http://schema.org/WatchAction" },
130 "userInteractionCount": 1120958
131 }, "aggregateRating": {
132 "@type": "AggregateRating",
134 "ratingCount": "630",
139 "name": "Kleio Valentien",
140 "url": "https://www.eporner.com/pornstar/kleio-valentien/"
144 'title': '1 On 1 With Kleio',
145 'description': 'Kleio Valentien',
146 'url': 'https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4',
147 'timestamp': 1449347075,
149 'view_count': 1120958,
156 r
'''<script type="application/ld+json">
158 "@context": "https://schema.org",
161 "@type": "NewsArticle",
162 "mainEntityOfPage": {
164 "@id": "https://www.ant1news.gr/Society/article/620286/symmoria-anilikon-dikigoros-thymaton-ithelan-na-toys-apoteleiosoyn"
166 "headline": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
167 "name": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
168 "description": "Τα παιδιά δέχθηκαν την επίθεση επειδή αρνήθηκαν να γίνουν μέλη της συμμορίας, ανέφερε ο Γ. Ζαχαρόπουλος.",
170 "@type": "ImageObject",
171 "url": "https://ant1media.azureedge.net/imgHandler/1100/a635c968-be71-447c-bf9c-80d843ece21e.jpg",
174 "datePublished": "2021-11-10T08:50:00+03:00",
175 "dateModified": "2021-11-10T08:52:53+03:00",
178 "@id": "https://www.ant1news.gr/",
180 "image": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
181 "url": "https://www.ant1news.gr/"
184 "@type": "Organization",
185 "@id": "https://www.ant1news.gr#publisher",
187 "url": "https://www.ant1news.gr",
189 "@type": "ImageObject",
190 "url": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
194 "https://www.facebook.com/Ant1news.gr",
195 "https://twitter.com/antennanews",
196 "https://www.youtube.com/channel/UC0smvAbfczoN75dP0Hw4Pzw",
197 "https://www.instagram.com/ant1news/"
201 "keywords": "μαχαίρωμα,συμμορία ανηλίκων,ΕΙΔΗΣΕΙΣ,ΕΙΔΗΣΕΙΣ ΣΗΜΕΡΑ,ΝΕΑ,Κοινωνία - Ant1news",
204 "articleSection": "Κοινωνία"
210 'timestamp': 1636523400,
211 'title': 'md5:91fe569e952e4d146485740ae927662b',
213 {'expected_type': 'NewsArticle'}
,
216 r
'''<script type="application/ld+json">
217 {"url":"/vrtnu/a-z/het-journaal/2021/het-journaal-het-journaal-19u-20211231/",
218 "name":"Het journaal 19u",
219 "description":"Het journaal 19u van vrijdag 31 december 2021.",
220 "potentialAction":{"url":"https://vrtnu.page.link/pfVy6ihgCAJKgHqe8","@type":"ShareAction"},
221 "mainEntityOfPage":{"@id":"1640092242445","@type":"WebPage"},
223 "startDate":"2021-12-31T19:00:00.000+01:00",
224 "endDate":"2022-01-30T23:55:00.000+01:00",
225 "publishedBy":{"name":"een","@type":"Organization"},
226 "publishedOn":{"url":"https://www.vrt.be/vrtnu/","name":"VRT NU","@type":"BroadcastService"},
227 "@id":"pbs-pub-3a7ec233-da95-4c1e-9b2b-cf5fdfebcbe8",
228 "@type":"BroadcastEvent"
231 "name":"Het journaal - Aflevering 365 (Seizoen 2021)",
232 "description":"Het journaal 19u van vrijdag 31 december 2021. Bekijk aflevering 365 van seizoen 2021 met VRT NU via de site of app.",
233 "thumbnailUrl":"//images.vrt.be/width1280/2021/12/31/80d5ed00-6a64-11ec-b07d-02b7b76bf47f.jpg",
234 "expires":"2022-01-30T23:55:00.000+01:00",
236 {"name":"Explosie Turnhout","startOffset":70,"@type":"Clip"},
237 {"name":"Jaarwisseling","startOffset":440,"@type":"Clip"},
238 {"name":"Natuurbranden Colorado","startOffset":1179,"@type":"Clip"},
239 {"name":"Klimaatverandering","startOffset":1263,"@type":"Clip"},
240 {"name":"Zacht weer","startOffset":1367,"@type":"Clip"},
241 {"name":"Financiële balans","startOffset":1383,"@type":"Clip"},
242 {"name":"Club Brugge","startOffset":1484,"@type":"Clip"},
243 {"name":"Mentale gezondheid bij topsporters","startOffset":1575,"@type":"Clip"},
244 {"name":"Olympische Winterspelen","startOffset":1728,"@type":"Clip"},
245 {"name":"Sober oudjaar in Nederland","startOffset":1873,"@type":"Clip"}
247 "duration":"PT34M39.23S",
248 "uploadDate":"2021-12-31T19:00:00.000+01:00",
249 "@id":"vid-9457d0c6-b8ac-4aba-b5e1-15aa3a3295b5",
250 "@type":"VideoObject"
252 "genre":["Nieuws en actua"],
254 "partOfSeries":{"name":"Het journaal","@id":"222831405527","@type":"TVSeries"},
255 "partOfSeason":{"name":"Seizoen 2021","@id":"961809365527","@type":"TVSeason"},
256 "@context":"https://schema.org","@id":"961685295527","@type":"TVEpisode"}</script>
260 {"title": "Explosie Turnhout", "start_time": 70, "end_time": 440}
,
261 {"title": "Jaarwisseling", "start_time": 440, "end_time": 1179}
,
262 {"title": "Natuurbranden Colorado", "start_time": 1179, "end_time": 1263}
,
263 {"title": "Klimaatverandering", "start_time": 1263, "end_time": 1367}
,
264 {"title": "Zacht weer", "start_time": 1367, "end_time": 1383}
,
265 {"title": "Financiële balans", "start_time": 1383, "end_time": 1484}
,
266 {"title": "Club Brugge", "start_time": 1484, "end_time": 1575}
,
267 {"title": "Mentale gezondheid bij topsporters", "start_time": 1575, "end_time": 1728}
,
268 {"title": "Olympische Winterspelen", "start_time": 1728, "end_time": 1873}
,
269 {"title": "Sober oudjaar in Nederland", "start_time": 1873, "end_time": 2079.23}
271 'title': 'Het journaal - Aflevering 365 (Seizoen 2021)'
275 # test multiple thumbnails in a list
277 <script type="application/ld+json">
278 {"@context":"https://schema.org",
279 "@type":"VideoObject",
280 "thumbnailUrl":["https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"]}
283 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}
],
288 # test single thumbnail
290 <script type="application/ld+json">
291 {"@context":"https://schema.org",
292 "@type":"VideoObject",
293 "thumbnailUrl":"https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"}
296 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}
],
301 for html
, expected_dict
, search_json_ld_kwargs
in _TESTS
:
304 self
.ie
._search
_json
_ld
(html
, None, **search_json_ld_kwargs
),
308 def test_download_json(self
):
309 uri
= encode_data_uri(b
'{"foo": "blah"}', 'application/json')
310 self
.assertEqual(self
.ie
._download
_json
(uri
, None), {'foo': 'blah'}
)
311 uri
= encode_data_uri(b
'callback({"foo": "blah"})', 'application/javascript')
312 self
.assertEqual(self
.ie
._download
_json
(uri
, None, transform_source
=strip_jsonp
), {'foo': 'blah'}
)
313 uri
= encode_data_uri(b
'{"foo": invalid}', 'application/json')
314 self
.assertRaises(ExtractorError
, self
.ie
._download
_json
, uri
, None)
315 self
.assertEqual(self
.ie
._download
_json
(uri
, None, fatal
=False), None)
317 def test_parse_html5_media_entries(self
):
321 self
.ie
._parse
_html
5_media
_entries
(
322 'https://127.0.0.1/video.html',
323 r
'<html><video src="/vid.mp4" /></html>', None)[0],
326 'url': 'https://127.0.0.1/vid.mp4',
330 # from https://www.r18.com/
334 self
.ie
._parse
_html
5_media
_entries
(
335 'https://www.r18.com/',
337 <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">
338 <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">
339 <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">
340 <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">
341 <p>Your browser does not support the video tag.</p>
346 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4',
348 'format_id': '300kbps',
352 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4',
354 'format_id': '1000kbps',
358 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4',
360 'format_id': '1500kbps',
364 'thumbnail': '//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg'
367 # from https://www.csfd.cz/
368 # with width and height
371 self
.ie
._parse
_html
5_media
_entries
(
372 'https://www.csfd.cz/',
374 <video width="770" height="328" preload="none" controls poster="https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360" >
375 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4" type="video/mp4" width="640" height="360">
376 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4" type="video/mp4" width="1280" height="720">
377 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4" type="video/mp4" width="1920" height="1080">
378 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm" type="video/webm" width="640" height="360">
379 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm" type="video/webm" width="1280" height="720">
380 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm" type="video/webm" width="1920" height="1080">
381 <track src="https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt" type="text/x-srt" kind="subtitles" srclang="cs" label="cs">
386 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4',
391 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4',
396 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4',
401 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm',
406 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm',
411 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm',
417 'cs': [{'url': 'https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt'}
]
419 'thumbnail': 'https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360'
422 # from https://tamasha.com/v/Kkdjw
423 # with height in label
426 self
.ie
._parse
_html
5_media
_entries
(
427 'https://tamasha.com/v/Kkdjw',
429 <video crossorigin="anonymous">
430 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4" label="AUTO" res="0"/>
431 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4"
432 label="240p" res="240"/>
433 <source src="https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4" type="video/mp4"
434 label="144p" res="144"/>
439 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
441 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
446 'url': 'https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4',
453 # from https://www.directvnow.com
457 self
.ie
._parse
_html
5_media
_entries
(
458 'https://www.directvnow.com',
460 <video id="vid1" class="header--video-masked active" muted playsinline>
461 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
467 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
471 # from https://www.directvnow.com
475 self
.ie
._parse
_html
5_media
_entries
(
476 'https://www.directvnow.com',
478 <video id="vid1" class="header--video-masked active" muted playsinline>
479 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
484 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
489 # from https://www.klarna.com/uk/
490 # with data-video-src
493 self
.ie
._parse
_html
5_media
_entries
(
494 'https://www.directvnow.com',
496 <video loop autoplay muted class="responsive-video block-kl__video video-on-medium">
497 <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" />
502 'url': 'https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4',
507 # from https://0000.studio/
508 # with type attribute but without extension in URL
511 self
.ie
._parse
_html
5_media
_entries
(
512 'https://0000.studio',
514 <video src="https://d1ggyt9m8pwf3g.cloudfront.net/protected/ap-northeast-1:1864af40-28d5-492b-b739-b32314b1a527/archive/clip/838db6a7-8973-4cd6-840d-8517e4093c92"
515 controls="controls" type="video/mp4" preload="metadata" autoplay="autoplay" playsinline class="object-contain">
520 'url': 'https://d1ggyt9m8pwf3g.cloudfront.net/protected/ap-northeast-1:1864af40-28d5-492b-b739-b32314b1a527/archive/clip/838db6a7-8973-4cd6-840d-8517e4093c92',
525 def test_extract_jwplayer_data_realworld(self
):
526 # from http://www.suffolk.edu/sjc/
529 self
.ie
._extract
_jwplayer
_data
(r
'''
530 <script type='text/javascript'>
531 jwplayer('my-video').setup({
532 file: 'rtmp://192.138.214.154/live/sjclive',
540 ''', None, require_title
=False),
544 'url': 'rtmp://192.138.214.154/live/sjclive',
549 # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/
552 self
.ie
._extract
_jwplayer
_data
(r
'''
553 <script type="text/javascript">
554 jwplayer("mediaplayer").setup({
557 'aspectratio': "16:9",
558 'stretching': "exactfit",
559 'autostart': 'false',
560 'flashplayer': "https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf",
561 '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",
562 'image': "https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg",
563 '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",
565 'skin': "https://t04.vipstreamservice.com/jwplayer/skin/modieus-blk.zip",
566 'plugins': "https://t04.vipstreamservice.com/jwplayer/dock/dockableskinnableplugin.swf",
567 'dockableskinnableplugin.piclink': "/index.php?key=ajax-videothumbsn&vid=7564&data=2009-12--14--4b2157147afe5efa93ce1978e0265289c193874e02597.flv--17370",
568 'controlbar': 'bottom',
570 {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'}
574 //noinspection JSAnnotator
576 adsUrl: "/banner-iframe/?zoneId=32",
581 ''', 'dummy', require_title
=False),
583 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg',
585 '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',
590 # from http://www.indiedb.com/games/king-machine/videos
593 self
.ie
._extract
_jwplayer
_data
(r
'''
595 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) {
596 videoAnalytics("play");
597 }).once("complete", function(event) {
598 videoAnalytics("completed");
603 'title': 'king machine trailer 1',
604 'thumbnail': 'http://media.indiedb.com/cache/images/games/1/50/49678/thumb_620x2000/king-machine-trailer.mp4.jpg',
606 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4',
610 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4',
616 def test_parse_m3u8_formats(self
):
619 # https://github.com/ytdl-org/youtube-dl/issues/11995
620 # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor
621 'img_bipbop_adv_example_fmp4',
622 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
624 'format_id': 'aud1-English',
625 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a1/prog_index.m3u8',
626 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
629 'protocol': 'm3u8_native',
632 'format_id': 'aud2-English',
633 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a2/prog_index.m3u8',
634 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
637 'protocol': 'm3u8_native',
640 'format_id': 'aud3-English',
641 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a3/prog_index.m3u8',
642 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
645 'protocol': 'm3u8_native',
649 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
650 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
652 'protocol': 'm3u8_native',
655 'vcodec': 'avc1.640015',
658 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
659 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
661 'protocol': 'm3u8_native',
664 'vcodec': 'avc1.640015',
667 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
668 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
670 'protocol': 'm3u8_native',
673 'vcodec': 'avc1.640015',
676 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
677 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
679 'protocol': 'm3u8_native',
682 'vcodec': 'avc1.64001e',
685 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
686 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
688 'protocol': 'm3u8_native',
691 'vcodec': 'avc1.64001e',
694 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
695 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
697 'protocol': 'm3u8_native',
700 'vcodec': 'avc1.64001e',
703 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
704 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
706 'protocol': 'm3u8_native',
709 'vcodec': 'avc1.64001e',
712 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
713 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
715 'protocol': 'm3u8_native',
718 'vcodec': 'avc1.64001e',
721 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
722 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
724 'protocol': 'm3u8_native',
727 'vcodec': 'avc1.64001e',
730 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
731 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
733 'protocol': 'm3u8_native',
736 'vcodec': 'avc1.640020',
739 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
740 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
742 'protocol': 'm3u8_native',
745 'vcodec': 'avc1.640020',
748 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
749 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
751 'protocol': 'm3u8_native',
754 'vcodec': 'avc1.640020',
757 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
758 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
760 'protocol': 'm3u8_native',
763 'vcodec': 'avc1.640020',
766 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
767 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
769 'protocol': 'm3u8_native',
772 'vcodec': 'avc1.640020',
775 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
776 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
778 'protocol': 'm3u8_native',
781 'vcodec': 'avc1.640020',
784 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
785 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
787 'protocol': 'm3u8_native',
790 'vcodec': 'avc1.64002a',
793 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
794 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
796 'protocol': 'm3u8_native',
799 'vcodec': 'avc1.64002a',
802 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
803 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
805 'protocol': 'm3u8_native',
808 'vcodec': 'avc1.64002a',
811 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
812 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
814 'protocol': 'm3u8_native',
817 'vcodec': 'avc1.64002a',
820 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
821 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
823 'protocol': 'm3u8_native',
826 'vcodec': 'avc1.64002a',
829 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
830 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
832 'protocol': 'm3u8_native',
835 'vcodec': 'avc1.64002a',
838 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
839 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
841 'protocol': 'm3u8_native',
844 'vcodec': 'avc1.64002a',
847 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
848 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
850 'protocol': 'm3u8_native',
853 'vcodec': 'avc1.64002a',
856 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
857 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
859 'protocol': 'm3u8_native',
862 'vcodec': 'avc1.64002a',
868 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
870 'format_id': 'bipbop_audio-BipBop Audio 2',
871 'format_index': None,
872 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/alternate_audio_aac/prog_index.m3u8',
873 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
876 'protocol': 'm3u8_native',
884 'format_index': None,
885 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8',
886 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
890 'protocol': 'm3u8_native',
894 'acodec': 'mp4a.40.2',
900 'format_index': None,
901 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8',
902 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
906 'protocol': 'm3u8_native',
911 'vcodec': 'avc1.4d400d',
912 'acodec': 'mp4a.40.2',
919 'format_index': None,
920 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8',
921 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
925 'protocol': 'm3u8_native',
930 'vcodec': 'avc1.4d401e',
931 'acodec': 'mp4a.40.2',
938 'format_index': None,
939 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8',
940 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
944 'protocol': 'm3u8_native',
949 'vcodec': 'avc1.4d401f',
950 'acodec': 'mp4a.40.2',
957 'format_index': None,
958 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8',
959 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
963 'protocol': 'm3u8_native',
968 'vcodec': 'avc1.4d401f',
969 'acodec': 'mp4a.40.2',
976 'format_index': None,
977 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8',
978 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
982 'protocol': 'm3u8_native',
987 'vcodec': 'avc1.4d401f',
988 'acodec': 'mp4a.40.2',
996 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng/prog_index.m3u8',
998 'protocol': 'm3u8_native'
1000 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng_forced/prog_index.m3u8',
1002 'protocol': 'm3u8_native'
1005 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra/prog_index.m3u8',
1007 'protocol': 'm3u8_native'
1009 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra_forced/prog_index.m3u8',
1011 'protocol': 'm3u8_native'
1014 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa/prog_index.m3u8',
1016 'protocol': 'm3u8_native'
1018 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa_forced/prog_index.m3u8',
1020 'protocol': 'm3u8_native'
1023 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn/prog_index.m3u8',
1025 'protocol': 'm3u8_native'
1027 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn_forced/prog_index.m3u8',
1029 'protocol': 'm3u8_native'
1035 for m3u8_file
, m3u8_url
, expected_formats
, expected_subs
in _TEST_CASES
:
1036 with open('./test/testdata/m3u8/%s.m3u8' % m3u8_file
, encoding
='utf-8') as f
:
1037 formats
, subs
= self
.ie
._parse
_m
3u8_formats
_and
_subtitles
(
1038 f
.read(), m3u8_url
, ext
='mp4')
1039 self
.ie
._sort
_formats
(formats
)
1040 expect_value(self
, formats
, expected_formats
, None)
1041 expect_value(self
, subs
, expected_subs
, None)
1043 def test_parse_mpd_formats(self
):
1046 # https://github.com/ytdl-org/youtube-dl/issues/13919
1047 # Also tests duplicate representation ids, see
1048 # https://github.com/ytdl-org/youtube-dl/issues/15111
1050 'http://unknown/manifest.mpd', # mpd_url
1051 None, # mpd_base_url
1053 'manifest_url': 'http://unknown/manifest.mpd',
1055 'format_id': '318597',
1056 'format_note': 'DASH audio',
1057 'protocol': 'http_dash_segments',
1058 'acodec': 'mp4a.40.2',
1062 'manifest_url': 'http://unknown/manifest.mpd',
1064 'format_id': '318597',
1065 'format_note': 'DASH video',
1066 'protocol': 'http_dash_segments',
1068 'vcodec': 'avc1.42001f',
1073 'manifest_url': 'http://unknown/manifest.mpd',
1075 'format_id': '638590',
1076 'format_note': 'DASH video',
1077 'protocol': 'http_dash_segments',
1079 'vcodec': 'avc1.42001f',
1084 'manifest_url': 'http://unknown/manifest.mpd',
1086 'format_id': '1022565',
1087 'format_note': 'DASH video',
1088 'protocol': 'http_dash_segments',
1090 'vcodec': 'avc1.4d001f',
1095 'manifest_url': 'http://unknown/manifest.mpd',
1097 'format_id': '2046506',
1098 'format_note': 'DASH video',
1099 'protocol': 'http_dash_segments',
1101 'vcodec': 'avc1.4d001f',
1106 'manifest_url': 'http://unknown/manifest.mpd',
1108 'format_id': '3998017',
1109 'format_note': 'DASH video',
1110 'protocol': 'http_dash_segments',
1112 'vcodec': 'avc1.640029',
1117 'manifest_url': 'http://unknown/manifest.mpd',
1119 'format_id': '5997485',
1120 'format_note': 'DASH video',
1121 'protocol': 'http_dash_segments',
1123 'vcodec': 'avc1.640032',
1130 # https://github.com/ytdl-org/youtube-dl/pull/14844
1132 'http://unknown/manifest.mpd', # mpd_url
1133 None, # mpd_base_url
1135 'manifest_url': 'http://unknown/manifest.mpd',
1137 'format_id': 'h264_aac_144p_m4s',
1138 'format_note': 'DASH video',
1139 'protocol': 'http_dash_segments',
1140 'acodec': 'mp4a.40.2',
1141 'vcodec': 'avc3.42c01e',
1146 'manifest_url': 'http://unknown/manifest.mpd',
1148 'format_id': 'h264_aac_240p_m4s',
1149 'format_note': 'DASH video',
1150 'protocol': 'http_dash_segments',
1151 'acodec': 'mp4a.40.2',
1152 'vcodec': 'avc3.42c01e',
1157 'manifest_url': 'http://unknown/manifest.mpd',
1159 'format_id': 'h264_aac_360p_m4s',
1160 'format_note': 'DASH video',
1161 'protocol': 'http_dash_segments',
1162 'acodec': 'mp4a.40.2',
1163 'vcodec': 'avc3.42c01e',
1168 'manifest_url': 'http://unknown/manifest.mpd',
1170 'format_id': 'h264_aac_480p_m4s',
1171 'format_note': 'DASH video',
1172 'protocol': 'http_dash_segments',
1173 'acodec': 'mp4a.40.2',
1174 'vcodec': 'avc3.42c01e',
1179 'manifest_url': 'http://unknown/manifest.mpd',
1181 'format_id': 'h264_aac_576p_m4s',
1182 'format_note': 'DASH video',
1183 'protocol': 'http_dash_segments',
1184 'acodec': 'mp4a.40.2',
1185 'vcodec': 'avc3.42c01e',
1190 'manifest_url': 'http://unknown/manifest.mpd',
1192 'format_id': 'h264_aac_720p_m4s',
1193 'format_note': 'DASH video',
1194 'protocol': 'http_dash_segments',
1195 'acodec': 'mp4a.40.2',
1196 'vcodec': 'avc3.42c01e',
1201 'manifest_url': 'http://unknown/manifest.mpd',
1203 'format_id': 'h264_aac_1080p_m4s',
1204 'format_note': 'DASH video',
1205 'protocol': 'http_dash_segments',
1206 'acodec': 'mp4a.40.2',
1207 'vcodec': 'avc3.42c01e',
1214 # https://github.com/ytdl-org/youtube-dl/issues/20346
1215 # Media considered unfragmented even though it contains
1216 # Initialization tag
1218 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', # mpd_url
1219 'https://v.redd.it/hw1x7rcg7zl21', # mpd_base_url
1221 'url': 'https://v.redd.it/hw1x7rcg7zl21/audio',
1222 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1224 'format_id': 'AUDIO-1',
1225 'format_note': 'DASH audio',
1226 'container': 'm4a_dash',
1227 'acodec': 'mp4a.40.2',
1233 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240',
1234 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1236 'format_id': 'VIDEO-2',
1237 'format_note': 'DASH video',
1238 'container': 'mp4_dash',
1240 'vcodec': 'avc1.4d401e',
1246 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_360',
1247 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1249 'format_id': 'VIDEO-1',
1250 'format_note': 'DASH video',
1251 'container': 'mp4_dash',
1253 'vcodec': 'avc1.4d401e',
1262 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1263 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/',
1265 'format_id': 'audio=128001',
1266 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1270 'format_note': 'DASH audio',
1271 'container': 'm4a_dash',
1273 'acodec': 'mp4a.40.2',
1274 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1275 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1276 'protocol': 'http_dash_segments',
1278 'video_ext': 'none',
1281 'format_id': 'video=100000',
1282 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1287 'format_note': 'DASH video',
1288 'container': 'mp4_dash',
1289 'vcodec': 'avc1.4D401F',
1291 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1292 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1293 'protocol': 'http_dash_segments',
1295 'audio_ext': 'none',
1298 'format_id': 'video=326000',
1299 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1304 'format_note': 'DASH video',
1305 'container': 'mp4_dash',
1306 'vcodec': 'avc1.4D401F',
1308 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1309 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1310 'protocol': 'http_dash_segments',
1312 'audio_ext': 'none',
1315 'format_id': 'video=698000',
1316 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1321 'format_note': 'DASH video',
1322 'container': 'mp4_dash',
1323 'vcodec': 'avc1.4D401F',
1325 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1326 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1327 'protocol': 'http_dash_segments',
1329 'audio_ext': 'none',
1332 'format_id': 'video=1493000',
1333 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1338 'format_note': 'DASH video',
1339 'container': 'mp4_dash',
1340 'vcodec': 'avc1.4D401F',
1342 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1343 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1344 'protocol': 'http_dash_segments',
1346 'audio_ext': 'none',
1349 'format_id': 'video=4482000',
1350 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1355 'format_note': 'DASH video',
1356 'container': 'mp4_dash',
1357 'vcodec': 'avc1.4D401F',
1359 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1360 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1361 'protocol': 'http_dash_segments',
1363 'audio_ext': 'none',
1370 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1371 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1372 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1373 'protocol': 'http_dash_segments',
1380 for mpd_file
, mpd_url
, mpd_base_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1381 with open('./test/testdata/mpd/%s.mpd' % mpd_file
, encoding
='utf-8') as f
:
1382 formats
, subtitles
= self
.ie
._parse
_mpd
_formats
_and
_subtitles
(
1383 compat_etree_fromstring(f
.read().encode()),
1384 mpd_base_url
=mpd_base_url
, mpd_url
=mpd_url
)
1385 self
.ie
._sort
_formats
(formats
)
1386 expect_value(self
, formats
, expected_formats
, None)
1387 expect_value(self
, subtitles
, expected_subtitles
, None)
1389 def test_parse_ism_formats(self
):
1393 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1395 'format_id': 'audio-128',
1396 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1397 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1404 '_download_params': {
1405 'stream_type': 'audio',
1406 'duration': 8880746666,
1407 'timescale': 10000000,
1411 'codec_private_data': '1190',
1412 'sampling_rate': 48000,
1414 'bits_per_sample': 16,
1415 'nal_unit_length_field': 4
1417 'audio_ext': 'isma',
1418 'video_ext': 'none',
1421 'format_id': 'video-100',
1422 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1423 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1431 '_download_params': {
1432 'stream_type': 'video',
1433 'duration': 8880746666,
1434 'timescale': 10000000,
1438 'codec_private_data': '00000001674D401FDA0544EFFC2D002CBC40000003004000000C03C60CA80000000168EF32C8',
1440 'bits_per_sample': 16,
1441 'nal_unit_length_field': 4
1443 'video_ext': 'ismv',
1444 'audio_ext': 'none',
1447 'format_id': 'video-326',
1448 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1449 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1457 '_download_params': {
1458 'stream_type': 'video',
1459 'duration': 8880746666,
1460 'timescale': 10000000,
1464 'codec_private_data': '00000001674D401FDA0241FE23FFC3BC83BA44000003000400000300C03C60CA800000000168EF32C8',
1466 'bits_per_sample': 16,
1467 'nal_unit_length_field': 4
1469 'video_ext': 'ismv',
1470 'audio_ext': 'none',
1473 'format_id': 'video-698',
1474 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1475 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1483 '_download_params': {
1484 'stream_type': 'video',
1485 'duration': 8880746666,
1486 'timescale': 10000000,
1490 'codec_private_data': '00000001674D401FDA0350BFB97FF06AF06AD1000003000100000300300F1832A00000000168EF32C8',
1492 'bits_per_sample': 16,
1493 'nal_unit_length_field': 4
1495 'video_ext': 'ismv',
1496 'audio_ext': 'none',
1499 'format_id': 'video-1493',
1500 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1501 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1509 '_download_params': {
1510 'stream_type': 'video',
1511 'duration': 8880746666,
1512 'timescale': 10000000,
1516 'codec_private_data': '00000001674D401FDA011C3DE6FFF0D890D871000003000100000300300F1832A00000000168EF32C8',
1518 'bits_per_sample': 16,
1519 'nal_unit_length_field': 4
1521 'video_ext': 'ismv',
1522 'audio_ext': 'none',
1525 'format_id': 'video-4482',
1526 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1527 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1535 '_download_params': {
1536 'stream_type': 'video',
1537 'duration': 8880746666,
1538 'timescale': 10000000,
1542 'codec_private_data': '00000001674D401FDA01A816F97FFC1ABC1AB440000003004000000C03C60CA80000000168EF32C8',
1544 'bits_per_sample': 16,
1545 'nal_unit_length_field': 4
1547 'video_ext': 'ismv',
1548 'audio_ext': 'none',
1556 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1557 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1558 '_download_params': {
1559 'stream_type': 'text',
1560 'duration': 8880746666,
1561 'timescale': 10000000,
1563 'codec_private_data': ''
1571 for ism_file
, ism_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1572 with open('./test/testdata/ism/%s.Manifest' % ism_file
, encoding
='utf-8') as f
:
1573 formats
, subtitles
= self
.ie
._parse
_ism
_formats
_and
_subtitles
(
1574 compat_etree_fromstring(f
.read().encode()), ism_url
=ism_url
)
1575 self
.ie
._sort
_formats
(formats
)
1576 expect_value(self
, formats
, expected_formats
, None)
1577 expect_value(self
, subtitles
, expected_subtitles
, None)
1579 def test_parse_f4m_formats(self
):
1582 # https://github.com/ytdl-org/youtube-dl/issues/14660
1584 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1586 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1588 'format_id': '2148',
1597 for f4m_file
, f4m_url
, expected_formats
in _TEST_CASES
:
1598 with open('./test/testdata/f4m/%s.f4m' % f4m_file
, encoding
='utf-8') as f
:
1599 formats
= self
.ie
._parse
_f
4m
_formats
(
1600 compat_etree_fromstring(f
.read().encode()),
1602 self
.ie
._sort
_formats
(formats
)
1603 expect_value(self
, formats
, expected_formats
, None)
1605 def test_parse_xspf(self
):
1609 'https://example.org/src/foo_xspf.xspf',
1612 'title': 'Pandemonium',
1613 'description': 'Visit http://bigbrother404.bandcamp.com',
1614 'duration': 202.416,
1616 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1617 'url': 'https://example.org/src/cd1/track%201.mp3',
1621 'title': 'Final Cartridge (Nichico Twelve Remix)',
1622 'description': 'Visit http://bigbrother404.bandcamp.com',
1623 'duration': 255.857,
1625 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1626 'url': 'https://example.org/%E3%83%88%E3%83%A9%E3%83%83%E3%82%AF%E3%80%80%EF%BC%92.mp3',
1630 'title': 'Rebuilding Nightingale',
1631 'description': 'Visit http://bigbrother404.bandcamp.com',
1632 'duration': 287.915,
1634 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1635 'url': 'https://example.org/src/track3.mp3',
1637 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1638 'url': 'https://example.com/track3.mp3',
1644 for xspf_file
, xspf_url
, expected_entries
in _TEST_CASES
:
1645 with open('./test/testdata/xspf/%s.xspf' % xspf_file
, encoding
='utf-8') as f
:
1646 entries
= self
.ie
._parse
_xspf
(
1647 compat_etree_fromstring(f
.read().encode()),
1648 xspf_file
, xspf_url
=xspf_url
, xspf_base_url
=xspf_url
)
1649 expect_value(self
, entries
, expected_entries
, None)
1650 for i
in range(len(entries
)):
1651 expect_dict(self
, entries
[i
], expected_entries
[i
])
1653 def test_response_with_expected_status_returns_content(self
):
1654 # Checks for mitigations against the effects of
1655 # <https://bugs.python.org/issue15002> that affect Python 3.4.1+, which
1656 # manifest as `_download_webpage`, `_download_xml`, `_download_json`,
1657 # or the underlying `_download_webpage_handle` returning no content
1658 # when a response matches `expected_status`.
1660 httpd
= http
.server
.HTTPServer(
1661 ('127.0.0.1', 0), InfoExtractorTestRequestHandler
)
1662 port
= http_server_port(httpd
)
1663 server_thread
= threading
.Thread(target
=httpd
.serve_forever
)
1664 server_thread
.daemon
= True
1665 server_thread
.start()
1667 (content
, urlh
) = self
.ie
._download
_webpage
_handle
(
1668 'http://127.0.0.1:%d/teapot' % port
, None,
1669 expected_status
=TEAPOT_RESPONSE_STATUS
)
1670 self
.assertEqual(content
, TEAPOT_RESPONSE_BODY
)
1673 if __name__
== '__main__':