]> jfr.im git - yt-dlp.git/blame - test/test_playlists.py
Allow recoding the video to mkv
[yt-dlp.git] / test / test_playlists.py
CommitLineData
a3c736de 1#!/usr/bin/env python
39baacc4 2# encoding: utf-8
a3c736de 3
ecfef3e5
PH
4from __future__ import unicode_literals
5
a3c736de
JMF
6# Allow direct execution
7import os
44a5f171
PH
8import sys
9import unittest
10sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11
ea38e55f 12from test.helper import (
20991253 13 assertRegexpMatches,
ea38e55f
PH
14 expect_info_dict,
15 FakeYDL,
16)
a3c736de 17
39baacc4 18from youtube_dl.extractor import (
d90df974 19 AcademicEarthCourseIE,
39baacc4
JMF
20 DailymotionPlaylistIE,
21 DailymotionUserIE,
22 VimeoChannelIE,
55a10eab 23 VimeoUserIE,
5cc14c2f 24 VimeoAlbumIE,
fb30ec22 25 VimeoGroupsIE,
39baacc4 26 UstreamChannelIE,
12c167c8 27 SoundcloudSetIE,
39baacc4 28 SoundcloudUserIE,
20991253 29 SoundcloudPlaylistIE,
b00ca882 30 LivestreamIE,
91dbaef4 31 NHLVideocenterIE,
165e3bb6 32 BambuserChannelIE,
5270d8cb 33 BandcampAlbumIE,
34 SmotriCommunityIE,
5ce54a82 35 SmotriUserIE,
41cc67c5 36 IviCompilationIE,
4fb757d1 37 ImdbListIE,
3d3538e4 38 KhanAcademyIE,
484aaeb2 39 EveryonesMixtapeIE,
87fac323 40 RutubeChannelIE,
ccf9114e 41 GoogleSearchIE,
99877772 42 GenericIE,
ca1fee34 43 TEDIE,
231f76b5 44 ToypicsUserIE,
9f5809b3 45 XTubeUserIE,
ea38e55f 46 InstagramUserIE,
aea6e7fc 47 CSpanIE,
de906ef5 48 AolIE,
39baacc4 49)
a3c736de 50
a3c736de
JMF
51
52class TestPlaylists(unittest.TestCase):
53 def assertIsPlaylist(self, info):
54 """Make sure the info has '_type' set to 'playlist'"""
55 self.assertEqual(info['_type'], 'playlist')
56
57 def test_dailymotion_playlist(self):
58 dl = FakeYDL()
59 ie = DailymotionPlaylistIE(dl)
60 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
61 self.assertIsPlaylist(result)
ecfef3e5 62 self.assertEqual(result['title'], 'SPORT')
a3c736de 63 self.assertTrue(len(result['entries']) > 20)
b00ca882 64
39baacc4
JMF
65 def test_dailymotion_user(self):
66 dl = FakeYDL()
67 ie = DailymotionUserIE(dl)
99043c2e 68 result = ie.extract('https://www.dailymotion.com/user/nqtv')
39baacc4 69 self.assertIsPlaylist(result)
99043c2e
JMF
70 self.assertEqual(result['title'], 'Rémi Gaillard')
71 self.assertTrue(len(result['entries']) >= 100)
a3c736de 72
caeefc29
JMF
73 def test_vimeo_channel(self):
74 dl = FakeYDL()
75 ie = VimeoChannelIE(dl)
76 result = ie.extract('http://vimeo.com/channels/tributes')
77 self.assertIsPlaylist(result)
ecfef3e5 78 self.assertEqual(result['title'], 'Vimeo Tributes')
caeefc29
JMF
79 self.assertTrue(len(result['entries']) > 24)
80
55a10eab
JMF
81 def test_vimeo_user(self):
82 dl = FakeYDL()
83 ie = VimeoUserIE(dl)
84 result = ie.extract('http://vimeo.com/nkistudio/videos')
85 self.assertIsPlaylist(result)
ecfef3e5 86 self.assertEqual(result['title'], 'Nki')
55a10eab
JMF
87 self.assertTrue(len(result['entries']) > 65)
88
5cc14c2f
JMF
89 def test_vimeo_album(self):
90 dl = FakeYDL()
91 ie = VimeoAlbumIE(dl)
92 result = ie.extract('http://vimeo.com/album/2632481')
93 self.assertIsPlaylist(result)
ecfef3e5 94 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
5cc14c2f
JMF
95 self.assertTrue(len(result['entries']) > 12)
96
fb30ec22
JMF
97 def test_vimeo_groups(self):
98 dl = FakeYDL()
99 ie = VimeoGroupsIE(dl)
100 result = ie.extract('http://vimeo.com/groups/rolexawards')
101 self.assertIsPlaylist(result)
ecfef3e5 102 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
fb30ec22
JMF
103 self.assertTrue(len(result['entries']) > 72)
104
74ac9bdd
JMF
105 def test_ustream_channel(self):
106 dl = FakeYDL()
107 ie = UstreamChannelIE(dl)
108 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
109 self.assertIsPlaylist(result)
ecfef3e5 110 self.assertEqual(result['id'], '5124905')
957688ce 111 self.assertTrue(len(result['entries']) >= 6)
74ac9bdd 112
12c167c8
JMF
113 def test_soundcloud_set(self):
114 dl = FakeYDL()
115 ie = SoundcloudSetIE(dl)
116 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
117 self.assertIsPlaylist(result)
ecfef3e5 118 self.assertEqual(result['title'], 'The Royal Concept EP')
12c167c8
JMF
119 self.assertTrue(len(result['entries']) >= 6)
120
92790f4e
JMF
121 def test_soundcloud_user(self):
122 dl = FakeYDL()
123 ie = SoundcloudUserIE(dl)
124 result = ie.extract('https://soundcloud.com/the-concept-band')
125 self.assertIsPlaylist(result)
ecfef3e5 126 self.assertEqual(result['id'], '9615865')
92790f4e
JMF
127 self.assertTrue(len(result['entries']) >= 12)
128
20991253
PH
129 def test_soundcloud_playlist(self):
130 dl = FakeYDL()
131 ie = SoundcloudPlaylistIE(dl)
132 result = ie.extract('http://api.soundcloud.com/playlists/4110309')
133 self.assertIsPlaylist(result)
134 self.assertEqual(result['id'], '4110309')
135 self.assertEqual(result['title'], 'TILT Brass - Bowery Poetry Club, August \'03 [Non-Site SCR 02]')
136 assertRegexpMatches(
137 self, result['description'], r'TILT Brass - Bowery Poetry Club')
138 self.assertEqual(len(result['entries']), 6)
139
b00ca882
JMF
140 def test_livestream_event(self):
141 dl = FakeYDL()
142 ie = LivestreamIE(dl)
143 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
144 self.assertIsPlaylist(result)
ecfef3e5 145 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
b00ca882
JMF
146 self.assertTrue(len(result['entries']) >= 4)
147
91dbaef4
JMF
148 def test_nhl_videocenter(self):
149 dl = FakeYDL()
150 ie = NHLVideocenterIE(dl)
151 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
152 self.assertIsPlaylist(result)
ecfef3e5
PH
153 self.assertEqual(result['id'], '999')
154 self.assertEqual(result['title'], 'Highlights')
91dbaef4
JMF
155 self.assertEqual(len(result['entries']), 12)
156
165e3bb6
JMF
157 def test_bambuser_channel(self):
158 dl = FakeYDL()
159 ie = BambuserChannelIE(dl)
160 result = ie.extract('http://bambuser.com/channel/pixelversity')
161 self.assertIsPlaylist(result)
ecfef3e5 162 self.assertEqual(result['title'], 'pixelversity')
d3b30148 163 self.assertTrue(len(result['entries']) >= 60)
165e3bb6 164
09804265
JMF
165 def test_bandcamp_album(self):
166 dl = FakeYDL()
167 ie = BandcampAlbumIE(dl)
168 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
169 self.assertIsPlaylist(result)
ecfef3e5 170 self.assertEqual(result['title'], 'Nightmare Night EP')
09804265 171 self.assertTrue(len(result['entries']) >= 4)
5270d8cb 172
173 def test_smotri_community(self):
174 dl = FakeYDL()
175 ie = SmotriCommunityIE(dl)
176 result = ie.extract('http://smotri.com/community/video/kommuna')
177 self.assertIsPlaylist(result)
ecfef3e5
PH
178 self.assertEqual(result['id'], 'kommuna')
179 self.assertEqual(result['title'], 'КПРФ')
5270d8cb 180 self.assertTrue(len(result['entries']) >= 4)
181
182 def test_smotri_user(self):
183 dl = FakeYDL()
184 ie = SmotriUserIE(dl)
185 result = ie.extract('http://smotri.com/user/inspector')
186 self.assertIsPlaylist(result)
ecfef3e5
PH
187 self.assertEqual(result['id'], 'inspector')
188 self.assertEqual(result['title'], 'Inspector')
5270d8cb 189 self.assertTrue(len(result['entries']) >= 9)
09804265 190
d90df974
PH
191 def test_AcademicEarthCourse(self):
192 dl = FakeYDL()
193 ie = AcademicEarthCourseIE(dl)
9e57ce71 194 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
d90df974 195 self.assertIsPlaylist(result)
9e57ce71
JMF
196 self.assertEqual(result['id'], 'laws-of-nature')
197 self.assertEqual(result['title'], 'Laws of Nature')
198 self.assertEqual(result['description'],u'Introduce yourself to the laws of nature with these free online college lectures from Yale, Harvard, and MIT.')# u"Today's websites are increasingly dynamic. Pages are no longer static HTML files but instead generated by scripts and database calls. User interfaces are more seamless, with technologies like Ajax replacing traditional page reloads. This course teaches students how to build dynamic websites with Ajax and with Linux, Apache, MySQL, and PHP (LAMP), one of today's most popular frameworks. Students learn how to set up domain names with DNS, how to structure pages with XHTML and CSS, how to program in JavaScript and PHP, how to configure Apache and MySQL, how to design and query databases with SQL, how to use Ajax with both XML and JSON, and how to build mashups. The course explores issues of security, scalability, and cross-browser support and also discusses enterprise-level deployments of websites, including third-party hosting, virtualization, colocation in data centers, firewalling, and load-balancing.")
199 self.assertEqual(len(result['entries']), 4)
8c21b7c6 200
201 def test_ivi_compilation(self):
202 dl = FakeYDL()
203 ie = IviCompilationIE(dl)
204 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
205 self.assertIsPlaylist(result)
ecfef3e5
PH
206 self.assertEqual(result['id'], 'dezhurnyi_angel')
207 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
3a9d6790
S
208 self.assertTrue(len(result['entries']) >= 23)
209
8c21b7c6 210 def test_ivi_compilation_season(self):
211 dl = FakeYDL()
212 ie = IviCompilationIE(dl)
213 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
214 self.assertIsPlaylist(result)
ecfef3e5
PH
215 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
216 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
3a9d6790 217 self.assertTrue(len(result['entries']) >= 7)
41cc67c5 218
219 def test_imdb_list(self):
220 dl = FakeYDL()
221 ie = ImdbListIE(dl)
98669ed7 222 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
41cc67c5 223 self.assertIsPlaylist(result)
98669ed7 224 self.assertEqual(result['id'], 'JFs9NWw6XI0')
225 self.assertEqual(result['title'], 'March 23, 2012 Releases')
226 self.assertEqual(len(result['entries']), 7)
d90df974 227
3d3538e4
PH
228 def test_khanacademy_topic(self):
229 dl = FakeYDL()
230 ie = KhanAcademyIE(dl)
231 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
232 self.assertIsPlaylist(result)
ecfef3e5
PH
233 self.assertEqual(result['id'], 'cryptography')
234 self.assertEqual(result['title'], 'Journey into cryptography')
235 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
3d3538e4
PH
236 self.assertTrue(len(result['entries']) >= 3)
237
484aaeb2
PH
238 def test_EveryonesMixtape(self):
239 dl = FakeYDL()
240 ie = EveryonesMixtapeIE(dl)
241 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
242 self.assertIsPlaylist(result)
243 self.assertEqual(result['id'], 'm7m0jJAbMQi')
244 self.assertEqual(result['title'], 'Driving')
245 self.assertEqual(len(result['entries']), 24)
87fac323 246
247 def test_rutube_channel(self):
248 dl = FakeYDL()
249 ie = RutubeChannelIE(dl)
250 result = ie.extract('http://rutube.ru/tags/video/1409')
251 self.assertIsPlaylist(result)
252 self.assertEqual(result['id'], '1409')
253 self.assertTrue(len(result['entries']) >= 34)
484aaeb2 254
99877772
PH
255 def test_multiple_brightcove_videos(self):
256 # https://github.com/rg3/youtube-dl/issues/2283
257 dl = FakeYDL()
258 ie = GenericIE(dl)
259 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
260 self.assertIsPlaylist(result)
261 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
262 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
263 self.assertEqual(len(result['entries']), 3)
264
ccf9114e
PH
265 def test_GoogleSearch(self):
266 dl = FakeYDL()
267 ie = GoogleSearchIE(dl)
268 result = ie.extract('gvsearch15:python language')
269 self.assertIsPlaylist(result)
270 self.assertEqual(result['id'], 'python language')
271 self.assertEqual(result['title'], 'python language')
c3d36f13 272 self.assertEqual(len(result['entries']), 15)
d90df974 273
4fc946b5
PH
274 def test_generic_rss_feed(self):
275 dl = FakeYDL()
276 ie = GenericIE(dl)
6a724239 277 result = ie.extract('http://phihag.de/2014/youtube-dl/rss.xml')
4fc946b5 278 self.assertIsPlaylist(result)
6a724239 279 self.assertEqual(result['id'], 'http://phihag.de/2014/youtube-dl/rss.xml')
4fc946b5
PH
280 self.assertEqual(result['title'], 'Zero Punctuation')
281 self.assertTrue(len(result['entries']) > 10)
282
ca1fee34
JMF
283 def test_ted_playlist(self):
284 dl = FakeYDL()
285 ie = TEDIE(dl)
286 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
287 self.assertIsPlaylist(result)
288 self.assertEqual(result['id'], '10')
289 self.assertEqual(result['title'], 'Who are the hackers?')
290 self.assertTrue(len(result['entries']) >= 6)
291
231f76b5
PH
292 def test_toypics_user(self):
293 dl = FakeYDL()
294 ie = ToypicsUserIE(dl)
295 result = ie.extract('http://videos.toypics.net/Mikey')
296 self.assertIsPlaylist(result)
297 self.assertEqual(result['id'], 'Mikey')
298 self.assertTrue(len(result['entries']) >= 17)
299
9f5809b3 300 def test_xtube_user(self):
301 dl = FakeYDL()
302 ie = XTubeUserIE(dl)
303 result = ie.extract('http://www.xtube.com/community/profile.php?user=greenshowers')
304 self.assertIsPlaylist(result)
305 self.assertEqual(result['id'], 'greenshowers')
306 self.assertTrue(len(result['entries']) >= 155)
307
ea38e55f
PH
308 def test_InstagramUser(self):
309 dl = FakeYDL()
310 ie = InstagramUserIE(dl)
311 result = ie.extract('http://instagram.com/porsche')
312 self.assertIsPlaylist(result)
313 self.assertEqual(result['id'], 'porsche')
314 self.assertTrue(len(result['entries']) >= 2)
315 test_video = next(
316 e for e in result['entries']
317 if e['id'] == '614605558512799803_462752227')
318 dl.add_default_extra_info(test_video, ie, '(irrelevant URL)')
319 dl.process_video_result(test_video, download=False)
320 EXPECTED = {
321 'id': '614605558512799803_462752227',
322 'ext': 'mp4',
323 'title': '#Porsche Intelligent Performance.',
324 'thumbnail': 're:^https?://.*\.jpg',
325 'uploader': 'Porsche',
326 'uploader_id': 'porsche',
912b38b4
PH
327 'timestamp': 1387486713,
328 'upload_date': '20131219',
ea38e55f
PH
329 }
330 expect_info_dict(self, EXPECTED, test_video)
331
aea6e7fc
PH
332 def test_CSpan_playlist(self):
333 dl = FakeYDL()
334 ie = CSpanIE(dl)
335 result = ie.extract(
336 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall')
337 self.assertIsPlaylist(result)
338 self.assertEqual(result['id'], '342759')
339 self.assertEqual(
340 result['title'], 'General Motors Ignition Switch Recall')
aea6e7fc
PH
341 whole_duration = sum(e['duration'] for e in result['entries'])
342 self.assertEqual(whole_duration, 14855)
343
de906ef5
PH
344 def test_aol_playlist(self):
345 dl = FakeYDL()
346 ie = AolIE(dl)
347 result = ie.extract(
348 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316')
349 self.assertIsPlaylist(result)
350 self.assertEqual(result['id'], '152147')
351 self.assertEqual(
352 result['title'], 'Brace Yourself - Today\'s Weirdest News')
353 self.assertTrue(len(result['entries']) >= 10)
ea38e55f 354
a3c736de
JMF
355if __name__ == '__main__':
356 unittest.main()