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
):
44 def _sort_formats(self
, formats
, field_preference
=[]):
45 self
._downloader
.sort_formats(
46 {'formats': formats, '_format_sort_fields': field_preference}
)
49 class TestInfoExtractor(unittest
.TestCase
):
51 self
.ie
= DummyIE(FakeYDL())
53 def test_ie_key(self
):
54 self
.assertEqual(get_info_extractor(YoutubeIE
.ie_key()), YoutubeIE
)
56 def test_html_search_regex(self
):
57 html
= '<p id="foo">Watch this <a href="http://www.youtube.com/watch?v=BaW_jenozKc">video</a></p>'
58 search
= lambda re
, *args
: self
.ie
._html
_search
_regex
(re
, html
, *args
)
59 self
.assertEqual(search(r
'<p id="foo">(.+?)</p>', 'foo'), 'Watch this video')
61 def test_opengraph(self
):
64 <meta name="og:title" content='Foo'/>
65 <meta content="Some video's description " name="og:description"/>
66 <meta property='og:image' content='http://domain.com/pic.jpg?key1=val1&key2=val2'/>
67 <meta content='application/x-shockwave-flash' property='og:video:type'>
68 <meta content='Foo' property=og:foobar>
69 <meta name="og:test1" content='foo > < bar'/>
70 <meta name="og:test2" content="foo >//< bar"/>
71 <meta property=og-test3 content='Ill-formatted opengraph'/>
73 self
.assertEqual(ie
._og
_search
_title
(html
), 'Foo')
74 self
.assertEqual(ie
._og
_search
_description
(html
), 'Some video\'s description ')
75 self
.assertEqual(ie
._og
_search
_thumbnail
(html
), 'http://domain.com/pic.jpg?key1=val1&key2=val2')
76 self
.assertEqual(ie
._og
_search
_video
_url
(html
, default
=None), None)
77 self
.assertEqual(ie
._og
_search
_property
('foobar', html
), 'Foo')
78 self
.assertEqual(ie
._og
_search
_property
('test1', html
), 'foo > < bar')
79 self
.assertEqual(ie
._og
_search
_property
('test2', html
), 'foo >//< bar')
80 self
.assertEqual(ie
._og
_search
_property
('test3', html
), 'Ill-formatted opengraph')
81 self
.assertEqual(ie
._og
_search
_property
(('test0', 'test1'), html
), 'foo > < bar')
82 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, 'test0', html
, None, fatal
=True)
83 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, ('test0', 'test00'), html
, None, fatal
=True)
85 def test_html_search_meta(self
):
88 <meta name="a" content="1" />
89 <meta name='b' content='2'>
90 <meta name="c" content='3'>
91 <meta name=d content='4'>
92 <meta property="e" content='5' >
93 <meta content="6" name="f">
96 self
.assertEqual(ie
._html
_search
_meta
('a', html
), '1')
97 self
.assertEqual(ie
._html
_search
_meta
('b', html
), '2')
98 self
.assertEqual(ie
._html
_search
_meta
('c', html
), '3')
99 self
.assertEqual(ie
._html
_search
_meta
('d', html
), '4')
100 self
.assertEqual(ie
._html
_search
_meta
('e', html
), '5')
101 self
.assertEqual(ie
._html
_search
_meta
('f', html
), '6')
102 self
.assertEqual(ie
._html
_search
_meta
(('a', 'b', 'c'), html
), '1')
103 self
.assertEqual(ie
._html
_search
_meta
(('c', 'b', 'a'), html
), '3')
104 self
.assertEqual(ie
._html
_search
_meta
(('z', 'x', 'c'), html
), '3')
105 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, 'z', html
, None, fatal
=True)
106 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, ('z', 'x'), html
, None, fatal
=True)
108 def test_search_json_ld_realworld(self
):
110 # https://github.com/ytdl-org/youtube-dl/issues/23306
112 r
'''<script type="application/ld+json">
114 "@context": "http://schema.org/",
115 "@type": "VideoObject",
116 "name": "1 On 1 With Kleio",
117 "url": "https://www.eporner.com/hd-porn/xN49A1cT3eB/1-On-1-With-Kleio/",
118 "duration": "PT0H12M23S",
119 "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"],
120 "contentUrl": "https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4",
121 "embedUrl": "https://www.eporner.com/embed/xN49A1cT3eB/1-On-1-With-Kleio/",
122 "image": "https://static-eu-cdn.eporner.com/thumbs/static4/7/78/780/780814/9_360.jpg",
125 "encodingFormat": "mp4",
126 "bitrate": "6617kbps",
127 "isFamilyFriendly": "False",
128 "description": "Kleio Valentien",
129 "uploadDate": "2015-12-05T21:24:35+01:00",
130 "interactionStatistic": {
131 "@type": "InteractionCounter",
132 "interactionType": { "@type": "http://schema.org/WatchAction" },
133 "userInteractionCount": 1120958
134 }, "aggregateRating": {
135 "@type": "AggregateRating",
137 "ratingCount": "630",
142 "name": "Kleio Valentien",
143 "url": "https://www.eporner.com/pornstar/kleio-valentien/"
147 'title': '1 On 1 With Kleio',
148 'description': 'Kleio Valentien',
149 'url': 'https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4',
150 'timestamp': 1449347075,
152 'view_count': 1120958,
159 r
'''<script type="application/ld+json">
161 "@context": "https://schema.org",
164 "@type": "NewsArticle",
165 "mainEntityOfPage": {
167 "@id": "https://www.ant1news.gr/Society/article/620286/symmoria-anilikon-dikigoros-thymaton-ithelan-na-toys-apoteleiosoyn"
169 "headline": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
170 "name": "Συμμορία ανηλίκων – δικηγόρος θυμάτων: ήθελαν να τους αποτελειώσουν",
171 "description": "Τα παιδιά δέχθηκαν την επίθεση επειδή αρνήθηκαν να γίνουν μέλη της συμμορίας, ανέφερε ο Γ. Ζαχαρόπουλος.",
173 "@type": "ImageObject",
174 "url": "https://ant1media.azureedge.net/imgHandler/1100/a635c968-be71-447c-bf9c-80d843ece21e.jpg",
177 "datePublished": "2021-11-10T08:50:00+03:00",
178 "dateModified": "2021-11-10T08:52:53+03:00",
181 "@id": "https://www.ant1news.gr/",
183 "image": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
184 "url": "https://www.ant1news.gr/"
187 "@type": "Organization",
188 "@id": "https://www.ant1news.gr#publisher",
190 "url": "https://www.ant1news.gr",
192 "@type": "ImageObject",
193 "url": "https://www.ant1news.gr/images/logo-e5d7e4b3e714c88e8d2eca96130142f6.png",
197 "https://www.facebook.com/Ant1news.gr",
198 "https://twitter.com/antennanews",
199 "https://www.youtube.com/channel/UC0smvAbfczoN75dP0Hw4Pzw",
200 "https://www.instagram.com/ant1news/"
204 "keywords": "μαχαίρωμα,συμμορία ανηλίκων,ΕΙΔΗΣΕΙΣ,ΕΙΔΗΣΕΙΣ ΣΗΜΕΡΑ,ΝΕΑ,Κοινωνία - Ant1news",
207 "articleSection": "Κοινωνία"
213 'timestamp': 1636523400,
214 'title': 'md5:91fe569e952e4d146485740ae927662b',
216 {'expected_type': 'NewsArticle'}
,
219 r
'''<script type="application/ld+json">
220 {"url":"/vrtnu/a-z/het-journaal/2021/het-journaal-het-journaal-19u-20211231/",
221 "name":"Het journaal 19u",
222 "description":"Het journaal 19u van vrijdag 31 december 2021.",
223 "potentialAction":{"url":"https://vrtnu.page.link/pfVy6ihgCAJKgHqe8","@type":"ShareAction"},
224 "mainEntityOfPage":{"@id":"1640092242445","@type":"WebPage"},
226 "startDate":"2021-12-31T19:00:00.000+01:00",
227 "endDate":"2022-01-30T23:55:00.000+01:00",
228 "publishedBy":{"name":"een","@type":"Organization"},
229 "publishedOn":{"url":"https://www.vrt.be/vrtnu/","name":"VRT NU","@type":"BroadcastService"},
230 "@id":"pbs-pub-3a7ec233-da95-4c1e-9b2b-cf5fdfebcbe8",
231 "@type":"BroadcastEvent"
234 "name":"Het journaal - Aflevering 365 (Seizoen 2021)",
235 "description":"Het journaal 19u van vrijdag 31 december 2021. Bekijk aflevering 365 van seizoen 2021 met VRT NU via de site of app.",
236 "thumbnailUrl":"//images.vrt.be/width1280/2021/12/31/80d5ed00-6a64-11ec-b07d-02b7b76bf47f.jpg",
237 "expires":"2022-01-30T23:55:00.000+01:00",
239 {"name":"Explosie Turnhout","startOffset":70,"@type":"Clip"},
240 {"name":"Jaarwisseling","startOffset":440,"@type":"Clip"},
241 {"name":"Natuurbranden Colorado","startOffset":1179,"@type":"Clip"},
242 {"name":"Klimaatverandering","startOffset":1263,"@type":"Clip"},
243 {"name":"Zacht weer","startOffset":1367,"@type":"Clip"},
244 {"name":"Financiële balans","startOffset":1383,"@type":"Clip"},
245 {"name":"Club Brugge","startOffset":1484,"@type":"Clip"},
246 {"name":"Mentale gezondheid bij topsporters","startOffset":1575,"@type":"Clip"},
247 {"name":"Olympische Winterspelen","startOffset":1728,"@type":"Clip"},
248 {"name":"Sober oudjaar in Nederland","startOffset":1873,"@type":"Clip"}
250 "duration":"PT34M39.23S",
251 "uploadDate":"2021-12-31T19:00:00.000+01:00",
252 "@id":"vid-9457d0c6-b8ac-4aba-b5e1-15aa3a3295b5",
253 "@type":"VideoObject"
255 "genre":["Nieuws en actua"],
257 "partOfSeries":{"name":"Het journaal","@id":"222831405527","@type":"TVSeries"},
258 "partOfSeason":{"name":"Seizoen 2021","@id":"961809365527","@type":"TVSeason"},
259 "@context":"https://schema.org","@id":"961685295527","@type":"TVEpisode"}</script>
263 {"title": "Explosie Turnhout", "start_time": 70, "end_time": 440}
,
264 {"title": "Jaarwisseling", "start_time": 440, "end_time": 1179}
,
265 {"title": "Natuurbranden Colorado", "start_time": 1179, "end_time": 1263}
,
266 {"title": "Klimaatverandering", "start_time": 1263, "end_time": 1367}
,
267 {"title": "Zacht weer", "start_time": 1367, "end_time": 1383}
,
268 {"title": "Financiële balans", "start_time": 1383, "end_time": 1484}
,
269 {"title": "Club Brugge", "start_time": 1484, "end_time": 1575}
,
270 {"title": "Mentale gezondheid bij topsporters", "start_time": 1575, "end_time": 1728}
,
271 {"title": "Olympische Winterspelen", "start_time": 1728, "end_time": 1873}
,
272 {"title": "Sober oudjaar in Nederland", "start_time": 1873, "end_time": 2079.23}
274 'title': 'Het journaal - Aflevering 365 (Seizoen 2021)'
278 # test multiple thumbnails in a list
280 <script type="application/ld+json">
281 {"@context":"https://schema.org",
282 "@type":"VideoObject",
283 "thumbnailUrl":["https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"]}
286 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}
],
291 # test single thumbnail
293 <script type="application/ld+json">
294 {"@context":"https://schema.org",
295 "@type":"VideoObject",
296 "thumbnailUrl":"https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg"}
299 'thumbnails': [{'url': 'https://www.rainews.it/cropgd/640x360/dl/img/2021/12/30/1640886376927_GettyImages.jpg'}
],
304 for html
, expected_dict
, search_json_ld_kwargs
in _TESTS
:
307 self
.ie
._search
_json
_ld
(html
, None, **search_json_ld_kwargs
),
311 def test_download_json(self
):
312 uri
= encode_data_uri(b
'{"foo": "blah"}', 'application/json')
313 self
.assertEqual(self
.ie
._download
_json
(uri
, None), {'foo': 'blah'}
)
314 uri
= encode_data_uri(b
'callback({"foo": "blah"})', 'application/javascript')
315 self
.assertEqual(self
.ie
._download
_json
(uri
, None, transform_source
=strip_jsonp
), {'foo': 'blah'}
)
316 uri
= encode_data_uri(b
'{"foo": invalid}', 'application/json')
317 self
.assertRaises(ExtractorError
, self
.ie
._download
_json
, uri
, None)
318 self
.assertEqual(self
.ie
._download
_json
(uri
, None, fatal
=False), None)
320 def test_parse_html5_media_entries(self
):
324 self
.ie
._parse
_html
5_media
_entries
(
325 'https://127.0.0.1/video.html',
326 r
'<html><video src="/vid.mp4" /></html>', None)[0],
329 'url': 'https://127.0.0.1/vid.mp4',
333 # from https://www.r18.com/
337 self
.ie
._parse
_html
5_media
_entries
(
338 'https://www.r18.com/',
340 <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">
341 <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">
342 <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">
343 <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">
344 <p>Your browser does not support the video tag.</p>
349 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_sm_w.mp4',
351 'format_id': '300kbps',
355 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dm_w.mp4',
357 'format_id': '1000kbps',
361 'url': 'https://awscc3001.r18.com/litevideo/freepv/m/mgm/mgmr105/mgmr105_dmb_w.mp4',
363 'format_id': '1500kbps',
367 'thumbnail': '//pics.r18.com/digital/amateur/mgmr105/mgmr105jp.jpg'
370 # from https://www.csfd.cz/
371 # with width and height
374 self
.ie
._parse
_html
5_media
_entries
(
375 'https://www.csfd.cz/',
377 <video width="770" height="328" preload="none" controls poster="https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360" >
378 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4" type="video/mp4" width="640" height="360">
379 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4" type="video/mp4" width="1280" height="720">
380 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4" type="video/mp4" width="1920" height="1080">
381 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm" type="video/webm" width="640" height="360">
382 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm" type="video/webm" width="1280" height="720">
383 <source src="https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm" type="video/webm" width="1920" height="1080">
384 <track src="https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt" type="text/x-srt" kind="subtitles" srclang="cs" label="cs">
389 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327358_eac647.mp4',
394 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327360_3d2646.mp4',
399 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327356_91f258.mp4',
404 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327359_962b4a.webm',
409 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327361_6feee0.webm',
414 'url': 'https://video.csfd.cz/files/videos/157/750/157750813/163327357_8ab472.webm',
420 'cs': [{'url': 'https://video.csfd.cz/files/subtitles/163/344/163344115_4c388b.srt'}
]
422 'thumbnail': 'https://img.csfd.cz/files/images/film/video/preview/163/344/163344118_748d20.png?h360'
425 # from https://tamasha.com/v/Kkdjw
426 # with height in label
429 self
.ie
._parse
_html
5_media
_entries
(
430 'https://tamasha.com/v/Kkdjw',
432 <video crossorigin="anonymous">
433 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4" label="AUTO" res="0"/>
434 <source src="https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4" type="video/mp4"
435 label="240p" res="240"/>
436 <source src="https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4" type="video/mp4"
437 label="144p" res="144"/>
442 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
444 'url': 'https://s-v2.tamasha.com/statics/videos_file/19/8f/Kkdjw_198feff8577d0057536e905cce1fb61438dd64e0_n_240.mp4',
449 'url': 'https://s-v2.tamasha.com/statics/videos_file/20/00/Kkdjw_200041c66f657fc967db464d156eafbc1ed9fe6f_n_144.mp4',
456 # from https://www.directvnow.com
460 self
.ie
._parse
_html
5_media
_entries
(
461 'https://www.directvnow.com',
463 <video id="vid1" class="header--video-masked active" muted playsinline>
464 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
470 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
474 # from https://www.directvnow.com
478 self
.ie
._parse
_html
5_media
_entries
(
479 'https://www.directvnow.com',
481 <video id="vid1" class="header--video-masked active" muted playsinline>
482 <source data-src="https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4" type="video/mp4" />
487 'url': 'https://cdn.directv.com/content/dam/dtv/prod/website_directvnow-international/videos/DTVN_hdr_HBO_v3.mp4',
492 # from https://www.klarna.com/uk/
493 # with data-video-src
496 self
.ie
._parse
_html
5_media
_entries
(
497 'https://www.directvnow.com',
499 <video loop autoplay muted class="responsive-video block-kl__video video-on-medium">
500 <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" />
505 'url': 'https://www.klarna.com/uk/wp-content/uploads/sites/11/2019/01/KL062_Smooth3_0_DogWalking_5s_920x080_.mp4',
510 # from https://0000.studio/
511 # with type attribute but without extension in URL
514 self
.ie
._parse
_html
5_media
_entries
(
515 'https://0000.studio',
517 <video src="https://d1ggyt9m8pwf3g.cloudfront.net/protected/ap-northeast-1:1864af40-28d5-492b-b739-b32314b1a527/archive/clip/838db6a7-8973-4cd6-840d-8517e4093c92"
518 controls="controls" type="video/mp4" preload="metadata" autoplay="autoplay" playsinline class="object-contain">
523 'url': 'https://d1ggyt9m8pwf3g.cloudfront.net/protected/ap-northeast-1:1864af40-28d5-492b-b739-b32314b1a527/archive/clip/838db6a7-8973-4cd6-840d-8517e4093c92',
528 def test_extract_jwplayer_data_realworld(self
):
529 # from http://www.suffolk.edu/sjc/
532 self
.ie
._extract
_jwplayer
_data
(r
'''
533 <script type='text/javascript'>
534 jwplayer('my-video').setup({
535 file: 'rtmp://192.138.214.154/live/sjclive',
543 ''', None, require_title
=False),
547 'url': 'rtmp://192.138.214.154/live/sjclive',
552 # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/
555 self
.ie
._extract
_jwplayer
_data
(r
'''
556 <script type="text/javascript">
557 jwplayer("mediaplayer").setup({
560 'aspectratio': "16:9",
561 'stretching': "exactfit",
562 'autostart': 'false',
563 'flashplayer': "https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf",
564 '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",
565 'image': "https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg",
566 '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",
568 'skin': "https://t04.vipstreamservice.com/jwplayer/skin/modieus-blk.zip",
569 'plugins': "https://t04.vipstreamservice.com/jwplayer/dock/dockableskinnableplugin.swf",
570 'dockableskinnableplugin.piclink': "/index.php?key=ajax-videothumbsn&vid=7564&data=2009-12--14--4b2157147afe5efa93ce1978e0265289c193874e02597.flv--17370",
571 'controlbar': 'bottom',
573 {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'}
577 //noinspection JSAnnotator
579 adsUrl: "/banner-iframe/?zoneId=32",
584 ''', 'dummy', require_title
=False),
586 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg',
588 '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',
593 # from http://www.indiedb.com/games/king-machine/videos
596 self
.ie
._extract
_jwplayer
_data
(r
'''
598 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) {
599 videoAnalytics("play");
600 }).once("complete", function(event) {
601 videoAnalytics("completed");
606 'title': 'king machine trailer 1',
607 'thumbnail': 'http://media.indiedb.com/cache/images/games/1/50/49678/thumb_620x2000/king-machine-trailer.mp4.jpg',
609 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4',
613 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4',
619 def test_parse_m3u8_formats(self
):
622 # https://github.com/ytdl-org/youtube-dl/issues/11995
623 # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor
624 'img_bipbop_adv_example_fmp4',
625 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
627 'format_id': 'aud1-English',
628 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a1/prog_index.m3u8',
629 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
632 'protocol': 'm3u8_native',
635 'format_id': 'aud2-English',
636 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a2/prog_index.m3u8',
637 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
640 'protocol': 'm3u8_native',
643 'format_id': 'aud3-English',
644 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/a3/prog_index.m3u8',
645 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
648 'protocol': 'm3u8_native',
652 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
653 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
655 'protocol': 'm3u8_native',
658 'vcodec': 'avc1.640015',
661 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
662 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
664 'protocol': 'm3u8_native',
667 'vcodec': 'avc1.640015',
670 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8',
671 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
673 'protocol': 'm3u8_native',
676 'vcodec': 'avc1.640015',
679 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
680 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
682 'protocol': 'm3u8_native',
685 'vcodec': 'avc1.64001e',
688 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
689 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
691 'protocol': 'm3u8_native',
694 'vcodec': 'avc1.64001e',
697 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v3/prog_index.m3u8',
698 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
700 'protocol': 'm3u8_native',
703 'vcodec': 'avc1.64001e',
706 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
707 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
709 'protocol': 'm3u8_native',
712 'vcodec': 'avc1.64001e',
715 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
716 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
718 'protocol': 'm3u8_native',
721 'vcodec': 'avc1.64001e',
724 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v4/prog_index.m3u8',
725 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
727 'protocol': 'm3u8_native',
730 'vcodec': 'avc1.64001e',
733 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
734 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
736 'protocol': 'm3u8_native',
739 'vcodec': 'avc1.640020',
742 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
743 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
745 'protocol': 'm3u8_native',
748 'vcodec': 'avc1.640020',
751 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v5/prog_index.m3u8',
752 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
754 'protocol': 'm3u8_native',
757 'vcodec': 'avc1.640020',
760 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
761 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
763 'protocol': 'm3u8_native',
766 'vcodec': 'avc1.640020',
769 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
770 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
772 'protocol': 'm3u8_native',
775 'vcodec': 'avc1.640020',
778 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v6/prog_index.m3u8',
779 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
781 'protocol': 'm3u8_native',
784 'vcodec': 'avc1.640020',
787 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
788 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
790 'protocol': 'm3u8_native',
793 'vcodec': 'avc1.64002a',
796 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
797 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
799 'protocol': 'm3u8_native',
802 'vcodec': 'avc1.64002a',
805 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v7/prog_index.m3u8',
806 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
808 'protocol': 'm3u8_native',
811 'vcodec': 'avc1.64002a',
814 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
815 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
817 'protocol': 'm3u8_native',
820 'vcodec': 'avc1.64002a',
823 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
824 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
826 'protocol': 'm3u8_native',
829 'vcodec': 'avc1.64002a',
832 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v8/prog_index.m3u8',
833 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
835 'protocol': 'm3u8_native',
838 'vcodec': 'avc1.64002a',
841 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
842 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
844 'protocol': 'm3u8_native',
847 'vcodec': 'avc1.64002a',
850 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
851 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
853 'protocol': 'm3u8_native',
856 'vcodec': 'avc1.64002a',
859 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v9/prog_index.m3u8',
860 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8',
862 'protocol': 'm3u8_native',
865 'vcodec': 'avc1.64002a',
871 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
873 'format_id': 'bipbop_audio-BipBop Audio 2',
874 'format_index': None,
875 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/alternate_audio_aac/prog_index.m3u8',
876 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
879 'protocol': 'm3u8_native',
887 'format_index': None,
888 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8',
889 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
893 'protocol': 'm3u8_native',
897 'acodec': 'mp4a.40.2',
903 'format_index': None,
904 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8',
905 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
909 'protocol': 'm3u8_native',
914 'vcodec': 'avc1.4d400d',
915 'acodec': 'mp4a.40.2',
922 'format_index': None,
923 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8',
924 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
928 'protocol': 'm3u8_native',
933 'vcodec': 'avc1.4d401e',
934 'acodec': 'mp4a.40.2',
941 'format_index': None,
942 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8',
943 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
947 'protocol': 'm3u8_native',
952 'vcodec': 'avc1.4d401f',
953 'acodec': 'mp4a.40.2',
960 'format_index': None,
961 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8',
962 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
966 'protocol': 'm3u8_native',
971 'vcodec': 'avc1.4d401f',
972 'acodec': 'mp4a.40.2',
979 'format_index': None,
980 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8',
981 'manifest_url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8',
985 'protocol': 'm3u8_native',
990 'vcodec': 'avc1.4d401f',
991 'acodec': 'mp4a.40.2',
999 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng/prog_index.m3u8',
1001 'protocol': 'm3u8_native'
1003 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng_forced/prog_index.m3u8',
1005 'protocol': 'm3u8_native'
1008 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra/prog_index.m3u8',
1010 'protocol': 'm3u8_native'
1012 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra_forced/prog_index.m3u8',
1014 'protocol': 'm3u8_native'
1017 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa/prog_index.m3u8',
1019 'protocol': 'm3u8_native'
1021 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa_forced/prog_index.m3u8',
1023 'protocol': 'm3u8_native'
1026 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn/prog_index.m3u8',
1028 'protocol': 'm3u8_native'
1030 'url': 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn_forced/prog_index.m3u8',
1032 'protocol': 'm3u8_native'
1038 for m3u8_file
, m3u8_url
, expected_formats
, expected_subs
in _TEST_CASES
:
1039 with open('./test/testdata/m3u8/%s.m3u8' % m3u8_file
, encoding
='utf-8') as f
:
1040 formats
, subs
= self
.ie
._parse
_m
3u8_formats
_and
_subtitles
(
1041 f
.read(), m3u8_url
, ext
='mp4')
1042 self
.ie
._sort
_formats
(formats
)
1043 expect_value(self
, formats
, expected_formats
, None)
1044 expect_value(self
, subs
, expected_subs
, None)
1046 def test_parse_mpd_formats(self
):
1049 # https://github.com/ytdl-org/youtube-dl/issues/13919
1050 # Also tests duplicate representation ids, see
1051 # https://github.com/ytdl-org/youtube-dl/issues/15111
1053 'http://unknown/manifest.mpd', # mpd_url
1054 None, # mpd_base_url
1056 'manifest_url': 'http://unknown/manifest.mpd',
1058 'format_id': '318597',
1059 'format_note': 'DASH audio',
1060 'protocol': 'http_dash_segments',
1061 'acodec': 'mp4a.40.2',
1065 'manifest_url': 'http://unknown/manifest.mpd',
1067 'format_id': '318597',
1068 'format_note': 'DASH video',
1069 'protocol': 'http_dash_segments',
1071 'vcodec': 'avc1.42001f',
1076 'manifest_url': 'http://unknown/manifest.mpd',
1078 'format_id': '638590',
1079 'format_note': 'DASH video',
1080 'protocol': 'http_dash_segments',
1082 'vcodec': 'avc1.42001f',
1087 'manifest_url': 'http://unknown/manifest.mpd',
1089 'format_id': '1022565',
1090 'format_note': 'DASH video',
1091 'protocol': 'http_dash_segments',
1093 'vcodec': 'avc1.4d001f',
1098 'manifest_url': 'http://unknown/manifest.mpd',
1100 'format_id': '2046506',
1101 'format_note': 'DASH video',
1102 'protocol': 'http_dash_segments',
1104 'vcodec': 'avc1.4d001f',
1109 'manifest_url': 'http://unknown/manifest.mpd',
1111 'format_id': '3998017',
1112 'format_note': 'DASH video',
1113 'protocol': 'http_dash_segments',
1115 'vcodec': 'avc1.640029',
1120 'manifest_url': 'http://unknown/manifest.mpd',
1122 'format_id': '5997485',
1123 'format_note': 'DASH video',
1124 'protocol': 'http_dash_segments',
1126 'vcodec': 'avc1.640032',
1133 # https://github.com/ytdl-org/youtube-dl/pull/14844
1135 'http://unknown/manifest.mpd', # mpd_url
1136 None, # mpd_base_url
1138 'manifest_url': 'http://unknown/manifest.mpd',
1140 'format_id': 'h264_aac_144p_m4s',
1141 'format_note': 'DASH video',
1142 'protocol': 'http_dash_segments',
1143 'acodec': 'mp4a.40.2',
1144 'vcodec': 'avc3.42c01e',
1149 'manifest_url': 'http://unknown/manifest.mpd',
1151 'format_id': 'h264_aac_240p_m4s',
1152 'format_note': 'DASH video',
1153 'protocol': 'http_dash_segments',
1154 'acodec': 'mp4a.40.2',
1155 'vcodec': 'avc3.42c01e',
1160 'manifest_url': 'http://unknown/manifest.mpd',
1162 'format_id': 'h264_aac_360p_m4s',
1163 'format_note': 'DASH video',
1164 'protocol': 'http_dash_segments',
1165 'acodec': 'mp4a.40.2',
1166 'vcodec': 'avc3.42c01e',
1171 'manifest_url': 'http://unknown/manifest.mpd',
1173 'format_id': 'h264_aac_480p_m4s',
1174 'format_note': 'DASH video',
1175 'protocol': 'http_dash_segments',
1176 'acodec': 'mp4a.40.2',
1177 'vcodec': 'avc3.42c01e',
1182 'manifest_url': 'http://unknown/manifest.mpd',
1184 'format_id': 'h264_aac_576p_m4s',
1185 'format_note': 'DASH video',
1186 'protocol': 'http_dash_segments',
1187 'acodec': 'mp4a.40.2',
1188 'vcodec': 'avc3.42c01e',
1193 'manifest_url': 'http://unknown/manifest.mpd',
1195 'format_id': 'h264_aac_720p_m4s',
1196 'format_note': 'DASH video',
1197 'protocol': 'http_dash_segments',
1198 'acodec': 'mp4a.40.2',
1199 'vcodec': 'avc3.42c01e',
1204 'manifest_url': 'http://unknown/manifest.mpd',
1206 'format_id': 'h264_aac_1080p_m4s',
1207 'format_note': 'DASH video',
1208 'protocol': 'http_dash_segments',
1209 'acodec': 'mp4a.40.2',
1210 'vcodec': 'avc3.42c01e',
1217 # https://github.com/ytdl-org/youtube-dl/issues/20346
1218 # Media considered unfragmented even though it contains
1219 # Initialization tag
1221 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd', # mpd_url
1222 'https://v.redd.it/hw1x7rcg7zl21', # mpd_base_url
1224 'url': 'https://v.redd.it/hw1x7rcg7zl21/audio',
1225 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1227 'format_id': 'AUDIO-1',
1228 'format_note': 'DASH audio',
1229 'container': 'm4a_dash',
1230 'acodec': 'mp4a.40.2',
1236 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240',
1237 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1239 'format_id': 'VIDEO-2',
1240 'format_note': 'DASH video',
1241 'container': 'mp4_dash',
1243 'vcodec': 'avc1.4d401e',
1249 'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_360',
1250 'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
1252 'format_id': 'VIDEO-1',
1253 'format_note': 'DASH video',
1254 'container': 'mp4_dash',
1256 'vcodec': 'avc1.4d401e',
1265 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1266 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/',
1268 'format_id': 'audio=128001',
1269 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1273 'format_note': 'DASH audio',
1274 'container': 'm4a_dash',
1276 'acodec': 'mp4a.40.2',
1277 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1278 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1279 'protocol': 'http_dash_segments',
1281 'video_ext': 'none',
1284 'format_id': 'video=100000',
1285 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1290 'format_note': 'DASH video',
1291 'container': 'mp4_dash',
1292 'vcodec': 'avc1.4D401F',
1294 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1295 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1296 'protocol': 'http_dash_segments',
1298 'audio_ext': 'none',
1301 'format_id': 'video=326000',
1302 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1307 'format_note': 'DASH video',
1308 'container': 'mp4_dash',
1309 'vcodec': 'avc1.4D401F',
1311 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1312 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1313 'protocol': 'http_dash_segments',
1315 'audio_ext': 'none',
1318 'format_id': 'video=698000',
1319 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1324 'format_note': 'DASH video',
1325 'container': 'mp4_dash',
1326 'vcodec': 'avc1.4D401F',
1328 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1329 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1330 'protocol': 'http_dash_segments',
1332 'audio_ext': 'none',
1335 'format_id': 'video=1493000',
1336 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1341 'format_note': 'DASH video',
1342 'container': 'mp4_dash',
1343 'vcodec': 'avc1.4D401F',
1345 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1346 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1347 'protocol': 'http_dash_segments',
1349 'audio_ext': 'none',
1352 'format_id': 'video=4482000',
1353 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1358 'format_note': 'DASH video',
1359 'container': 'mp4_dash',
1360 'vcodec': 'avc1.4D401F',
1362 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1363 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1364 'protocol': 'http_dash_segments',
1366 'audio_ext': 'none',
1373 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1374 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd',
1375 'fragment_base_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/dash/',
1376 'protocol': 'http_dash_segments',
1383 for mpd_file
, mpd_url
, mpd_base_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1384 with open('./test/testdata/mpd/%s.mpd' % mpd_file
, encoding
='utf-8') as f
:
1385 formats
, subtitles
= self
.ie
._parse
_mpd
_formats
_and
_subtitles
(
1386 compat_etree_fromstring(f
.read().encode()),
1387 mpd_base_url
=mpd_base_url
, mpd_url
=mpd_url
)
1388 self
.ie
._sort
_formats
(formats
)
1389 expect_value(self
, formats
, expected_formats
, None)
1390 expect_value(self
, subtitles
, expected_subtitles
, None)
1392 def test_parse_ism_formats(self
):
1396 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1398 'format_id': 'audio-128',
1399 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1400 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1407 '_download_params': {
1408 'stream_type': 'audio',
1409 'duration': 8880746666,
1410 'timescale': 10000000,
1414 'codec_private_data': '1190',
1415 'sampling_rate': 48000,
1417 'bits_per_sample': 16,
1418 'nal_unit_length_field': 4
1420 'audio_ext': 'isma',
1421 'video_ext': 'none',
1424 'format_id': 'video-100',
1425 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1426 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1434 '_download_params': {
1435 'stream_type': 'video',
1436 'duration': 8880746666,
1437 'timescale': 10000000,
1441 'codec_private_data': '00000001674D401FDA0544EFFC2D002CBC40000003004000000C03C60CA80000000168EF32C8',
1443 'bits_per_sample': 16,
1444 'nal_unit_length_field': 4
1446 'video_ext': 'ismv',
1447 'audio_ext': 'none',
1450 'format_id': 'video-326',
1451 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1452 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1460 '_download_params': {
1461 'stream_type': 'video',
1462 'duration': 8880746666,
1463 'timescale': 10000000,
1467 'codec_private_data': '00000001674D401FDA0241FE23FFC3BC83BA44000003000400000300C03C60CA800000000168EF32C8',
1469 'bits_per_sample': 16,
1470 'nal_unit_length_field': 4
1472 'video_ext': 'ismv',
1473 'audio_ext': 'none',
1476 'format_id': 'video-698',
1477 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1478 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1486 '_download_params': {
1487 'stream_type': 'video',
1488 'duration': 8880746666,
1489 'timescale': 10000000,
1493 'codec_private_data': '00000001674D401FDA0350BFB97FF06AF06AD1000003000100000300300F1832A00000000168EF32C8',
1495 'bits_per_sample': 16,
1496 'nal_unit_length_field': 4
1498 'video_ext': 'ismv',
1499 'audio_ext': 'none',
1502 'format_id': 'video-1493',
1503 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1504 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1512 '_download_params': {
1513 'stream_type': 'video',
1514 'duration': 8880746666,
1515 'timescale': 10000000,
1519 'codec_private_data': '00000001674D401FDA011C3DE6FFF0D890D871000003000100000300300F1832A00000000168EF32C8',
1521 'bits_per_sample': 16,
1522 'nal_unit_length_field': 4
1524 'video_ext': 'ismv',
1525 'audio_ext': 'none',
1528 'format_id': 'video-4482',
1529 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1530 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1538 '_download_params': {
1539 'stream_type': 'video',
1540 'duration': 8880746666,
1541 'timescale': 10000000,
1545 'codec_private_data': '00000001674D401FDA01A816F97FFC1ABC1AB440000003004000000C03C60CA80000000168EF32C8',
1547 'bits_per_sample': 16,
1548 'nal_unit_length_field': 4
1550 'video_ext': 'ismv',
1551 'audio_ext': 'none',
1559 'url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1560 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/Manifest',
1561 '_download_params': {
1562 'stream_type': 'text',
1563 'duration': 8880746666,
1564 'timescale': 10000000,
1566 'codec_private_data': ''
1574 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1576 'format_id': 'audio_deu_1-224',
1577 'url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1578 'manifest_url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1587 'stream_type': 'audio',
1588 'duration': 370000000,
1589 'timescale': 10000000,
1594 'codec_private_data': '00063F000000AF87FBA7022DFB42A4D405CD93843BDD0700200F00',
1595 'sampling_rate': 48000,
1597 'bits_per_sample': 16,
1598 'nal_unit_length_field': 4
1600 'audio_ext': 'isma',
1601 'video_ext': 'none',
1604 'format_id': 'audio_deu-127',
1605 'url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1606 'manifest_url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1615 'stream_type': 'audio',
1616 'duration': 370000000,
1617 'timescale': 10000000,
1622 'codec_private_data': '1190',
1623 'sampling_rate': 48000,
1625 'bits_per_sample': 16,
1626 'nal_unit_length_field': 4
1628 'audio_ext': 'isma',
1629 'video_ext': 'none',
1632 'format_id': 'video_deu-23',
1633 'url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1634 'manifest_url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1644 'stream_type': 'video',
1645 'duration': 370000000,
1646 'timescale': 10000000,
1651 'codec_private_data': '000000016742C00CDB06077E5C05A808080A00000300020000030009C0C02EE0177CC6300F142AE00000000168CA8DC8',
1653 'bits_per_sample': 16,
1654 'nal_unit_length_field': 4
1656 'video_ext': 'ismv',
1657 'audio_ext': 'none',
1660 'format_id': 'video_deu-403',
1661 'url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1662 'manifest_url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1672 'stream_type': 'video',
1673 'duration': 370000000,
1674 'timescale': 10000000,
1679 'codec_private_data': '00000001674D4014E98323B602D4040405000003000100000300320F1429380000000168EAECF2',
1681 'bits_per_sample': 16,
1682 'nal_unit_length_field': 4
1684 'video_ext': 'ismv',
1685 'audio_ext': 'none',
1688 'format_id': 'video_deu-680',
1689 'url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1690 'manifest_url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1700 'stream_type': 'video',
1701 'duration': 370000000,
1702 'timescale': 10000000,
1707 'codec_private_data': '00000001674D401EE981405FF2E02D4040405000000300100000030320F162D3800000000168EAECF2',
1709 'bits_per_sample': 16,
1710 'nal_unit_length_field': 4
1712 'video_ext': 'ismv',
1713 'audio_ext': 'none',
1716 'format_id': 'video_deu-1253',
1717 'url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1718 'manifest_url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1728 'stream_type': 'video',
1729 'duration': 370000000,
1730 'timescale': 10000000,
1735 'codec_private_data': '00000001674D401EE981405FF2E02D4040405000000300100000030320F162D3800000000168EAECF2',
1737 'bits_per_sample': 16,
1738 'nal_unit_length_field': 4
1740 'video_ext': 'ismv',
1741 'audio_ext': 'none',
1744 'format_id': 'video_deu-2121',
1745 'url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1746 'manifest_url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1756 'stream_type': 'video',
1757 'duration': 370000000,
1758 'timescale': 10000000,
1763 'codec_private_data': '00000001674D401EECA0601BD80B50101014000003000400000300C83C58B6580000000168E93B3C80',
1765 'bits_per_sample': 16,
1766 'nal_unit_length_field': 4
1768 'video_ext': 'ismv',
1769 'audio_ext': 'none',
1772 'format_id': 'video_deu-3275',
1773 'url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1774 'manifest_url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1784 'stream_type': 'video',
1785 'duration': 370000000,
1786 'timescale': 10000000,
1791 'codec_private_data': '00000001674D4020ECA02802DD80B501010140000003004000000C83C60C65800000000168E93B3C80',
1793 'bits_per_sample': 16,
1794 'nal_unit_length_field': 4
1796 'video_ext': 'ismv',
1797 'audio_ext': 'none',
1800 'format_id': 'video_deu-5300',
1801 'url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1802 'manifest_url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1812 'stream_type': 'video',
1813 'duration': 370000000,
1814 'timescale': 10000000,
1819 'codec_private_data': '00000001674D4028ECA03C0113F2E02D4040405000000300100000030320F18319600000000168E93B3C80',
1821 'bits_per_sample': 16,
1822 'nal_unit_length_field': 4
1824 'video_ext': 'ismv',
1825 'audio_ext': 'none',
1828 'format_id': 'video_deu-8079',
1829 'url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1830 'manifest_url': 'https://smstr01.dmm.t-online.de/smooth24/smoothstream_m1/streaming/sony/9221438342941275747/636887760842957027/25_km_h-Trailer-9221571562372022953_deu_20_1300k_HD_H_264_ISMV.ism/Manifest',
1840 'stream_type': 'video',
1841 'duration': 370000000,
1842 'timescale': 10000000,
1847 'codec_private_data': '00000001674D4028ECA03C0113F2E02D4040405000000300100000030320F18319600000000168E93B3C80',
1849 'bits_per_sample': 16,
1850 'nal_unit_length_field': 4
1852 'video_ext': 'ismv',
1853 'audio_ext': 'none',
1860 for ism_file
, ism_url
, expected_formats
, expected_subtitles
in _TEST_CASES
:
1861 with open('./test/testdata/ism/%s.Manifest' % ism_file
, encoding
='utf-8') as f
:
1862 formats
, subtitles
= self
.ie
._parse
_ism
_formats
_and
_subtitles
(
1863 compat_etree_fromstring(f
.read().encode()), ism_url
=ism_url
)
1864 self
.ie
._sort
_formats
(formats
)
1865 expect_value(self
, formats
, expected_formats
, None)
1866 expect_value(self
, subtitles
, expected_subtitles
, None)
1868 def test_parse_f4m_formats(self
):
1871 # https://github.com/ytdl-org/youtube-dl/issues/14660
1873 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1875 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
1877 'format_id': '2148',
1886 for f4m_file
, f4m_url
, expected_formats
in _TEST_CASES
:
1887 with open('./test/testdata/f4m/%s.f4m' % f4m_file
, encoding
='utf-8') as f
:
1888 formats
= self
.ie
._parse
_f
4m
_formats
(
1889 compat_etree_fromstring(f
.read().encode()),
1891 self
.ie
._sort
_formats
(formats
)
1892 expect_value(self
, formats
, expected_formats
, None)
1894 def test_parse_xspf(self
):
1898 'https://example.org/src/foo_xspf.xspf',
1901 'title': 'Pandemonium',
1902 'description': 'Visit http://bigbrother404.bandcamp.com',
1903 'duration': 202.416,
1905 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1906 'url': 'https://example.org/src/cd1/track%201.mp3',
1910 'title': 'Final Cartridge (Nichico Twelve Remix)',
1911 'description': 'Visit http://bigbrother404.bandcamp.com',
1912 'duration': 255.857,
1914 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1915 'url': 'https://example.org/%E3%83%88%E3%83%A9%E3%83%83%E3%82%AF%E3%80%80%EF%BC%92.mp3',
1919 'title': 'Rebuilding Nightingale',
1920 'description': 'Visit http://bigbrother404.bandcamp.com',
1921 'duration': 287.915,
1923 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1924 'url': 'https://example.org/src/track3.mp3',
1926 'manifest_url': 'https://example.org/src/foo_xspf.xspf',
1927 'url': 'https://example.com/track3.mp3',
1933 for xspf_file
, xspf_url
, expected_entries
in _TEST_CASES
:
1934 with open('./test/testdata/xspf/%s.xspf' % xspf_file
, encoding
='utf-8') as f
:
1935 entries
= self
.ie
._parse
_xspf
(
1936 compat_etree_fromstring(f
.read().encode()),
1937 xspf_file
, xspf_url
=xspf_url
, xspf_base_url
=xspf_url
)
1938 expect_value(self
, entries
, expected_entries
, None)
1939 for i
in range(len(entries
)):
1940 expect_dict(self
, entries
[i
], expected_entries
[i
])
1942 def test_response_with_expected_status_returns_content(self
):
1943 # Checks for mitigations against the effects of
1944 # <https://bugs.python.org/issue15002> that affect Python 3.4.1+, which
1945 # manifest as `_download_webpage`, `_download_xml`, `_download_json`,
1946 # or the underlying `_download_webpage_handle` returning no content
1947 # when a response matches `expected_status`.
1949 httpd
= http
.server
.HTTPServer(
1950 ('127.0.0.1', 0), InfoExtractorTestRequestHandler
)
1951 port
= http_server_port(httpd
)
1952 server_thread
= threading
.Thread(target
=httpd
.serve_forever
)
1953 server_thread
.daemon
= True
1954 server_thread
.start()
1956 (content
, urlh
) = self
.ie
._download
_webpage
_handle
(
1957 'http://127.0.0.1:%d/teapot' % port
, None,
1958 expected_status
=TEAPOT_RESPONSE_STATUS
)
1959 self
.assertEqual(content
, TEAPOT_RESPONSE_BODY
)
1962 if __name__
== '__main__':