]>
Raphaƫl G. Git Repositories - youtubedl/blob - test/test_InfoExtractor.py
7b31d5198b561f7e3725a15055439ca5f35b791b
3 from __future__
import unicode_literals
5 # Allow direct execution
10 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
12 from test
.helper
import FakeYDL
, expect_dict
, expect_value
13 from youtube_dl
.compat
import compat_etree_fromstring
14 from youtube_dl
.extractor
.common
import InfoExtractor
15 from youtube_dl
.extractor
import YoutubeIE
, get_info_extractor
16 from youtube_dl
.utils
import encode_data_uri
, strip_jsonp
, ExtractorError
, RegexNotFoundError
19 class TestIE(InfoExtractor
):
23 class TestInfoExtractor(unittest
.TestCase
):
25 self
.ie
= TestIE(FakeYDL())
27 def test_ie_key(self
):
28 self
.assertEqual(get_info_extractor(YoutubeIE
.ie_key()), YoutubeIE
)
30 def test_html_search_regex(self
):
31 html
= '<p id="foo">Watch this <a href="http://www.youtube.com/watch?v=BaW_jenozKc">video</a></p>'
32 search
= lambda re
, *args
: self
.ie
._html
_search
_regex
(re
, html
, *args
)
33 self
.assertEqual(search(r
'<p id="foo">(.+?)</p>', 'foo'), 'Watch this video')
35 def test_opengraph(self
):
38 <meta name="og:title" content='Foo'/>
39 <meta content="Some video's description " name="og:description"/>
40 <meta property='og:image' content='http://domain.com/pic.jpg?key1=val1&key2=val2'/>
41 <meta content='application/x-shockwave-flash' property='og:video:type'>
42 <meta content='Foo' property=og:foobar>
43 <meta name="og:test1" content='foo > < bar'/>
44 <meta name="og:test2" content="foo >//< bar"/>
46 self
.assertEqual(ie
._og
_search
_title
(html
), 'Foo')
47 self
.assertEqual(ie
._og
_search
_description
(html
), 'Some video\'s description ')
48 self
.assertEqual(ie
._og
_search
_thumbnail
(html
), 'http://domain.com/pic.jpg?key1=val1&key2=val2')
49 self
.assertEqual(ie
._og
_search
_video
_url
(html
, default
=None), None)
50 self
.assertEqual(ie
._og
_search
_property
('foobar', html
), 'Foo')
51 self
.assertEqual(ie
._og
_search
_property
('test1', html
), 'foo > < bar')
52 self
.assertEqual(ie
._og
_search
_property
('test2', html
), 'foo >//< bar')
53 self
.assertEqual(ie
._og
_search
_property
(('test0', 'test1'), html
), 'foo > < bar')
54 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, 'test0', html
, None, fatal
=True)
55 self
.assertRaises(RegexNotFoundError
, ie
._og
_search
_property
, ('test0', 'test00'), html
, None, fatal
=True)
57 def test_html_search_meta(self
):
60 <meta name="a" content="1" />
61 <meta name='b' content='2'>
62 <meta name="c" content='3'>
63 <meta name=d content='4'>
64 <meta property="e" content='5' >
65 <meta content="6" name="f">
68 self
.assertEqual(ie
._html
_search
_meta
('a', html
), '1')
69 self
.assertEqual(ie
._html
_search
_meta
('b', html
), '2')
70 self
.assertEqual(ie
._html
_search
_meta
('c', html
), '3')
71 self
.assertEqual(ie
._html
_search
_meta
('d', html
), '4')
72 self
.assertEqual(ie
._html
_search
_meta
('e', html
), '5')
73 self
.assertEqual(ie
._html
_search
_meta
('f', html
), '6')
74 self
.assertEqual(ie
._html
_search
_meta
(('a', 'b', 'c'), html
), '1')
75 self
.assertEqual(ie
._html
_search
_meta
(('c', 'b', 'a'), html
), '3')
76 self
.assertEqual(ie
._html
_search
_meta
(('z', 'x', 'c'), html
), '3')
77 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, 'z', html
, None, fatal
=True)
78 self
.assertRaises(RegexNotFoundError
, ie
._html
_search
_meta
, ('z', 'x'), html
, None, fatal
=True)
80 def test_download_json(self
):
81 uri
= encode_data_uri(b
'{"foo": "blah"}', 'application/json')
82 self
.assertEqual(self
.ie
._download
_json
(uri
, None), {'foo': 'blah'})
83 uri
= encode_data_uri(b
'callback({"foo": "blah"})', 'application/javascript')
84 self
.assertEqual(self
.ie
._download
_json
(uri
, None, transform_source
=strip_jsonp
), {'foo': 'blah'})
85 uri
= encode_data_uri(b
'{"foo": invalid}', 'application/json')
86 self
.assertRaises(ExtractorError
, self
.ie
._download
_json
, uri
, None)
87 self
.assertEqual(self
.ie
._download
_json
(uri
, None, fatal
=False), None)
89 def test_extract_jwplayer_data_realworld(self
):
90 # from http://www.suffolk.edu/sjc/
93 self
.ie
._extract
_jwplayer
_data
(r
'''
94 <script type='text/javascript'>
95 jwplayer('my-video').setup({
96 file: 'rtmp://192.138.214.154/live/sjclive',
104 ''', None, require_title
=False),
108 'url': 'rtmp://192.138.214.154/live/sjclive',
113 # from https://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary/
116 self
.ie
._extract
_jwplayer
_data
(r
'''
117 <script type="text/javascript">
118 jwplayer("mediaplayer").setup({
121 'aspectratio': "16:9",
122 'stretching': "exactfit",
123 'autostart': 'false',
124 'flashplayer': "https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf",
125 '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",
126 'image': "https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg",
127 '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",
129 'skin': "https://t04.vipstreamservice.com/jwplayer/skin/modieus-blk.zip",
130 'plugins': "https://t04.vipstreamservice.com/jwplayer/dock/dockableskinnableplugin.swf",
131 'dockableskinnableplugin.piclink': "/index.php?key=ajax-videothumbsn&vid=7564&data=2009-12--14--4b2157147afe5efa93ce1978e0265289c193874e02597.flv--17370",
132 'controlbar': 'bottom',
134 {type: 'flash', src: 'https://t04.vipstreamservice.com/jwplayer/v5.10/player.swf'}
138 //noinspection JSAnnotator
140 adsUrl: "/banner-iframe/?zoneId=32",
145 ''', 'dummy', require_title
=False),
147 'thumbnail': 'https://t03.vipstreamservice.com/thumbs/pxo-full/2009-12/14/a4b2157147afe5efa93ce1978e0265289c193874e02597.flv-full-13.jpg',
149 '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',
154 # from http://www.indiedb.com/games/king-machine/videos
157 self
.ie
._extract
_jwplayer
_data
(r
'''
159 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) {
160 videoAnalytics("play");
161 }).once("complete", function(event) {
162 videoAnalytics("completed");
167 'title': 'king machine trailer 1',
168 'thumbnail': 'http://media.indiedb.com/cache/images/games/1/50/49678/thumb_620x2000/king-machine-trailer.mp4.jpg',
170 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode_mp4/king-machine-trailer.mp4',
174 'url': 'http://cdn.dbolical.com/cache/videos/games/1/50/49678/encode720p_mp4/king-machine-trailer.mp4',
180 def test_parse_m3u8_formats(self
):
183 # https://github.com/rg3/youtube-dl/issues/11507
184 # http://pluzz.francetv.fr/videos/le_ministere.html
185 'pluzz_francetv_11507',
186 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
188 'url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/index_0_av.m3u8?null=0',
189 'manifest_url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
193 'acodec': 'mp4a.40.2',
194 'vcodec': 'avc1.66.30',
199 'url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/index_1_av.m3u8?null=0',
200 'manifest_url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
204 'acodec': 'mp4a.40.2',
205 'vcodec': 'avc1.66.30',
210 'url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/index_2_av.m3u8?null=0',
211 'manifest_url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
215 'acodec': 'mp4a.40.2',
216 'vcodec': 'avc1.66.30',
221 'url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/index_3_av.m3u8?null=0',
222 'manifest_url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
226 'acodec': 'mp4a.40.2',
227 'vcodec': 'avc1.77.30',
232 'url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/index_4_av.m3u8?null=0',
233 'manifest_url': 'http://replayftv-vh.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2017/S16/J2/156589847-58f59130c1f52-,standard1,standard2,standard3,standard4,standard5,.mp4.csmil/master.m3u8?caption=2017%2F16%2F156589847-1492488987.m3u8%3Afra%3AFrancais&audiotrack=0%3Afra%3AFrancais',
237 'acodec': 'mp4a.40.2',
238 'vcodec': 'avc1.77.30',
245 # https://github.com/rg3/youtube-dl/issues/11995
246 # http://teamcoco.com/video/clueless-gamer-super-bowl-for-honor
248 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
250 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-audio-160k_v4.m3u8',
251 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
253 'format_id': 'audio-0-Default',
257 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-audio-64k_v4.m3u8',
258 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
260 'format_id': 'audio-1-Default',
264 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-audio-64k_v4.m3u8',
265 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
269 'acodec': 'mp4a.40.5',
273 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-400k_v4.m3u8',
274 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
279 'vcodec': 'avc1.42001e',
284 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-400k_v4.m3u8',
285 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
290 'vcodec': 'avc1.42001e',
295 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-1m_v4.m3u8',
296 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
301 'vcodec': 'avc1.4d001e',
306 'url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/hls/CONAN_020217_Highlight_show-2m_v4.m3u8',
307 'manifest_url': 'http://ak.storage-w.teamcococdn.com/cdn/2017-02/98599/ed8f/main.m3u8',
312 'vcodec': 'avc1.4d001f',
319 # https://github.com/rg3/youtube-dl/issues/12211
320 # http://video.toggle.sg/en/series/whoopie-s-world/ep3/478601
321 'toggle_mobile_12211',
322 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
324 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/2/pv/1/flavorId/0_sa2ntrdg/name/a.mp4/index.m3u8',
325 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
327 'format_id': 'audio-English',
332 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/2/pv/1/flavorId/0_r7y0nitg/name/a.mp4/index.m3u8',
333 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
335 'format_id': 'audio-Undefined',
340 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/2/pv/1/flavorId/0_qlk9hlzr/name/a.mp4/index.m3u8',
341 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
349 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/2/pv/1/flavorId/0_oefackmi/name/a.mp4/index.m3u8',
350 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
358 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/12/pv/1/flavorId/0_vyg9pj7k/name/a.mp4/index.m3u8',
359 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
367 'url': 'http://k.toggle.sg/fhls/p/2082311/sp/208231100/serveFlavor/entryId/0_89q6e8ku/v/12/pv/1/flavorId/0_50n4psvx/name/a.mp4/index.m3u8',
368 'manifest_url': 'http://cdnapi.kaltura.com/p/2082311/sp/208231100/playManifest/protocol/http/entryId/0_89q6e8ku/format/applehttp/tags/mobile_sd/f/a.m3u8',
378 # http://www.twitch.tv/riotgames/v/6528877
380 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
382 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/audio_only/index-muted-HM49I092CC.m3u8',
383 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
385 'format_id': 'Audio Only',
387 'acodec': 'mp4a.40.2',
391 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/mobile/index-muted-HM49I092CC.m3u8',
392 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
394 'format_id': 'Mobile',
396 'acodec': 'mp4a.40.2',
397 'vcodec': 'avc1.42C00D',
402 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/low/index-muted-HM49I092CC.m3u8',
403 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
407 'acodec': 'mp4a.40.2',
408 'vcodec': 'avc1.42C01E',
413 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/medium/index-muted-HM49I092CC.m3u8',
414 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
416 'format_id': 'Medium',
418 'acodec': 'mp4a.40.2',
419 'vcodec': 'avc1.42C01E',
424 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/high/index-muted-HM49I092CC.m3u8',
425 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
429 'acodec': 'mp4a.40.2',
430 'vcodec': 'avc1.42C01F',
435 'url': 'https://vod.edgecast.hls.ttvnw.net/e5da31ab49_riotgames_15001215120_261543898/chunked/index-muted-HM49I092CC.m3u8',
436 'manifest_url': 'https://usher.ttvnw.net/vod/6528877?allow_source=true&allow_audio_only=true&allow_spectre=true&player=twitchweb&nauth=%7B%22user_id%22%3Anull%2C%22vod_id%22%3A6528877%2C%22expires%22%3A1492887874%2C%22chansub%22%3A%7B%22restricted_bitrates%22%3A%5B%5D%7D%2C%22privileged%22%3Afalse%2C%22https_required%22%3Afalse%7D&nauthsig=3e29296a6824a0f48f9e731383f77a614fc79bee',
438 'format_id': 'Source',
440 'acodec': 'mp4a.40.2',
441 'vcodec': 'avc1.100.31',
448 # http://www.vidio.com/watch/165683-dj_ambred-booyah-live-2015
449 # EXT-X-STREAM-INF tag with NAME attribute that is not defined
450 # in HLS specification
452 'https://www.vidio.com/videos/165683/playlist.m3u8',
454 'url': 'https://cdn1-a.production.vidio.static6.com/uploads/165683/dj_ambred-4383-b300.mp4.m3u8',
455 'manifest_url': 'https://www.vidio.com/videos/165683/playlist.m3u8',
457 'format_id': '270p 3G',
463 'url': 'https://cdn1-a.production.vidio.static6.com/uploads/165683/dj_ambred-4383-b600.mp4.m3u8',
464 'manifest_url': 'https://www.vidio.com/videos/165683/playlist.m3u8',
466 'format_id': '360p SD',
472 'url': 'https://cdn1-a.production.vidio.static6.com/uploads/165683/dj_ambred-4383-b1200.mp4.m3u8',
473 'manifest_url': 'https://www.vidio.com/videos/165683/playlist.m3u8',
475 'format_id': '720p HD',
484 for m3u8_file
, m3u8_url
, expected_formats
in _TEST_CASES
:
485 with io
.open('./test/testdata/m3u8/%s.m3u8' % m3u8_file
,
486 mode
='r', encoding
='utf-8') as f
:
487 formats
= self
.ie
._parse
_m
3u8_formats
(
488 f
.read(), m3u8_url
, ext
='mp4')
489 self
.ie
._sort
_formats
(formats
)
490 expect_value(self
, formats
, expected_formats
, None)
492 def test_parse_mpd_formats(self
):
495 # https://github.com/rg3/youtube-dl/issues/13919
496 # Also tests duplicate representation ids, see
497 # https://github.com/rg3/youtube-dl/issues/15111
499 'http://unknown/manifest.mpd',
501 'manifest_url': 'http://unknown/manifest.mpd',
503 'format_id': '318597',
504 'format_note': 'DASH audio',
505 'protocol': 'http_dash_segments',
506 'acodec': 'mp4a.40.2',
510 'manifest_url': 'http://unknown/manifest.mpd',
512 'format_id': '318597',
513 'format_note': 'DASH video',
514 'protocol': 'http_dash_segments',
516 'vcodec': 'avc1.42001f',
521 'manifest_url': 'http://unknown/manifest.mpd',
523 'format_id': '638590',
524 'format_note': 'DASH video',
525 'protocol': 'http_dash_segments',
527 'vcodec': 'avc1.42001f',
532 'manifest_url': 'http://unknown/manifest.mpd',
534 'format_id': '1022565',
535 'format_note': 'DASH video',
536 'protocol': 'http_dash_segments',
538 'vcodec': 'avc1.4d001f',
543 'manifest_url': 'http://unknown/manifest.mpd',
545 'format_id': '2046506',
546 'format_note': 'DASH video',
547 'protocol': 'http_dash_segments',
549 'vcodec': 'avc1.4d001f',
554 'manifest_url': 'http://unknown/manifest.mpd',
556 'format_id': '3998017',
557 'format_note': 'DASH video',
558 'protocol': 'http_dash_segments',
560 'vcodec': 'avc1.640029',
565 'manifest_url': 'http://unknown/manifest.mpd',
567 'format_id': '5997485',
568 'format_note': 'DASH video',
569 'protocol': 'http_dash_segments',
571 'vcodec': 'avc1.640032',
577 # https://github.com/rg3/youtube-dl/pull/14844
579 'http://unknown/manifest.mpd',
581 'manifest_url': 'http://unknown/manifest.mpd',
583 'format_id': 'h264_aac_144p_m4s',
584 'format_note': 'DASH video',
585 'protocol': 'http_dash_segments',
586 'acodec': 'mp4a.40.2',
587 'vcodec': 'avc3.42c01e',
592 'manifest_url': 'http://unknown/manifest.mpd',
594 'format_id': 'h264_aac_240p_m4s',
595 'format_note': 'DASH video',
596 'protocol': 'http_dash_segments',
597 'acodec': 'mp4a.40.2',
598 'vcodec': 'avc3.42c01e',
603 'manifest_url': 'http://unknown/manifest.mpd',
605 'format_id': 'h264_aac_360p_m4s',
606 'format_note': 'DASH video',
607 'protocol': 'http_dash_segments',
608 'acodec': 'mp4a.40.2',
609 'vcodec': 'avc3.42c01e',
614 'manifest_url': 'http://unknown/manifest.mpd',
616 'format_id': 'h264_aac_480p_m4s',
617 'format_note': 'DASH video',
618 'protocol': 'http_dash_segments',
619 'acodec': 'mp4a.40.2',
620 'vcodec': 'avc3.42c01e',
625 'manifest_url': 'http://unknown/manifest.mpd',
627 'format_id': 'h264_aac_576p_m4s',
628 'format_note': 'DASH video',
629 'protocol': 'http_dash_segments',
630 'acodec': 'mp4a.40.2',
631 'vcodec': 'avc3.42c01e',
636 'manifest_url': 'http://unknown/manifest.mpd',
638 'format_id': 'h264_aac_720p_m4s',
639 'format_note': 'DASH video',
640 'protocol': 'http_dash_segments',
641 'acodec': 'mp4a.40.2',
642 'vcodec': 'avc3.42c01e',
647 'manifest_url': 'http://unknown/manifest.mpd',
649 'format_id': 'h264_aac_1080p_m4s',
650 'format_note': 'DASH video',
651 'protocol': 'http_dash_segments',
652 'acodec': 'mp4a.40.2',
653 'vcodec': 'avc3.42c01e',
661 for mpd_file
, mpd_url
, expected_formats
in _TEST_CASES
:
662 with io
.open('./test/testdata/mpd/%s.mpd' % mpd_file
,
663 mode
='r', encoding
='utf-8') as f
:
664 formats
= self
.ie
._parse
_mpd
_formats
(
665 compat_etree_fromstring(f
.read().encode('utf-8')),
667 self
.ie
._sort
_formats
(formats
)
668 expect_value(self
, formats
, expected_formats
, None)
670 def test_parse_f4m_formats(self
):
673 # https://github.com/rg3/youtube-dl/issues/14660
675 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
677 'manifest_url': 'http://api.new.livestream.com/accounts/6115179/events/6764928/videos/144884262.f4m',
688 for f4m_file
, f4m_url
, expected_formats
in _TEST_CASES
:
689 with io
.open('./test/testdata/f4m/%s.f4m' % f4m_file
,
690 mode
='r', encoding
='utf-8') as f
:
691 formats
= self
.ie
._parse
_f
4m
_formats
(
692 compat_etree_fromstring(f
.read().encode('utf-8')),
694 self
.ie
._sort
_formats
(formats
)
695 expect_value(self
, formats
, expected_formats
, None)
698 if __name__
== '__main__':