]> jfr.im git - yt-dlp.git/blame - test/test_playlists.py
[test/test_utils] Fix typo in method name
[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,
d8624e6a 14 assertGreaterEqual,
ea38e55f
PH
15 expect_info_dict,
16 FakeYDL,
17)
a3c736de 18
39baacc4 19from youtube_dl.extractor import (
d90df974 20 AcademicEarthCourseIE,
39baacc4
JMF
21 DailymotionPlaylistIE,
22 DailymotionUserIE,
23 VimeoChannelIE,
55a10eab 24 VimeoUserIE,
5cc14c2f 25 VimeoAlbumIE,
fb30ec22 26 VimeoGroupsIE,
ea783d01 27 VineUserIE,
39baacc4 28 UstreamChannelIE,
12c167c8 29 SoundcloudSetIE,
39baacc4 30 SoundcloudUserIE,
20991253 31 SoundcloudPlaylistIE,
31a196d7 32 TeacherTubeUserIE,
b00ca882 33 LivestreamIE,
78338f71 34 LivestreamOriginalIE,
91dbaef4 35 NHLVideocenterIE,
165e3bb6 36 BambuserChannelIE,
5270d8cb 37 BandcampAlbumIE,
38 SmotriCommunityIE,
5ce54a82 39 SmotriUserIE,
41cc67c5 40 IviCompilationIE,
4fb757d1 41 ImdbListIE,
3d3538e4 42 KhanAcademyIE,
484aaeb2 43 EveryonesMixtapeIE,
87fac323 44 RutubeChannelIE,
fd69098a 45 RutubePersonIE,
ccf9114e 46 GoogleSearchIE,
99877772 47 GenericIE,
ca1fee34 48 TEDIE,
231f76b5 49 ToypicsUserIE,
9f5809b3 50 XTubeUserIE,
ea38e55f 51 InstagramUserIE,
aea6e7fc 52 CSpanIE,
de906ef5 53 AolIE,
39baacc4 54)
a3c736de 55
a3c736de
JMF
56
57class TestPlaylists(unittest.TestCase):
58 def assertIsPlaylist(self, info):
59 """Make sure the info has '_type' set to 'playlist'"""
60 self.assertEqual(info['_type'], 'playlist')
61
62 def test_dailymotion_playlist(self):
63 dl = FakeYDL()
64 ie = DailymotionPlaylistIE(dl)
65 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
66 self.assertIsPlaylist(result)
ecfef3e5 67 self.assertEqual(result['title'], 'SPORT')
a3c736de 68 self.assertTrue(len(result['entries']) > 20)
b00ca882 69
39baacc4
JMF
70 def test_dailymotion_user(self):
71 dl = FakeYDL()
72 ie = DailymotionUserIE(dl)
99043c2e 73 result = ie.extract('https://www.dailymotion.com/user/nqtv')
39baacc4 74 self.assertIsPlaylist(result)
d8624e6a 75 assertGreaterEqual(self, len(result['entries']), 100)
99043c2e 76 self.assertEqual(result['title'], 'Rémi Gaillard')
a3c736de 77
caeefc29
JMF
78 def test_vimeo_channel(self):
79 dl = FakeYDL()
80 ie = VimeoChannelIE(dl)
81 result = ie.extract('http://vimeo.com/channels/tributes')
82 self.assertIsPlaylist(result)
ecfef3e5 83 self.assertEqual(result['title'], 'Vimeo Tributes')
caeefc29
JMF
84 self.assertTrue(len(result['entries']) > 24)
85
55a10eab
JMF
86 def test_vimeo_user(self):
87 dl = FakeYDL()
88 ie = VimeoUserIE(dl)
89 result = ie.extract('http://vimeo.com/nkistudio/videos')
90 self.assertIsPlaylist(result)
ecfef3e5 91 self.assertEqual(result['title'], 'Nki')
55a10eab
JMF
92 self.assertTrue(len(result['entries']) > 65)
93
5cc14c2f
JMF
94 def test_vimeo_album(self):
95 dl = FakeYDL()
96 ie = VimeoAlbumIE(dl)
97 result = ie.extract('http://vimeo.com/album/2632481')
98 self.assertIsPlaylist(result)
ecfef3e5 99 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
5cc14c2f
JMF
100 self.assertTrue(len(result['entries']) > 12)
101
fb30ec22
JMF
102 def test_vimeo_groups(self):
103 dl = FakeYDL()
104 ie = VimeoGroupsIE(dl)
105 result = ie.extract('http://vimeo.com/groups/rolexawards')
106 self.assertIsPlaylist(result)
ecfef3e5 107 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
fb30ec22
JMF
108 self.assertTrue(len(result['entries']) > 72)
109
ea783d01
JN
110 def test_vine_user(self):
111 dl = FakeYDL()
112 ie = VineUserIE(dl)
113 result = ie.extract('https://vine.co/Visa')
114 self.assertIsPlaylist(result)
d8624e6a 115 assertGreaterEqual(self, len(result['entries']), 47)
ea783d01 116
74ac9bdd
JMF
117 def test_ustream_channel(self):
118 dl = FakeYDL()
119 ie = UstreamChannelIE(dl)
a14e1538 120 result = ie.extract('http://www.ustream.tv/channel/channeljapan')
74ac9bdd 121 self.assertIsPlaylist(result)
a14e1538 122 self.assertEqual(result['id'], '10874166')
d8624e6a 123 assertGreaterEqual(self, len(result['entries']), 54)
74ac9bdd 124
12c167c8
JMF
125 def test_soundcloud_set(self):
126 dl = FakeYDL()
127 ie = SoundcloudSetIE(dl)
128 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
129 self.assertIsPlaylist(result)
ecfef3e5 130 self.assertEqual(result['title'], 'The Royal Concept EP')
d8624e6a 131 assertGreaterEqual(self, len(result['entries']), 6)
12c167c8 132
92790f4e
JMF
133 def test_soundcloud_user(self):
134 dl = FakeYDL()
135 ie = SoundcloudUserIE(dl)
136 result = ie.extract('https://soundcloud.com/the-concept-band')
137 self.assertIsPlaylist(result)
ecfef3e5 138 self.assertEqual(result['id'], '9615865')
d8624e6a 139 assertGreaterEqual(self, len(result['entries']), 12)
92790f4e 140
3941669d 141 def test_soundcloud_likes(self):
142 dl = FakeYDL()
143 ie = SoundcloudUserIE(dl)
144 result = ie.extract('https://soundcloud.com/the-concept-band/likes')
145 self.assertIsPlaylist(result)
146 self.assertEqual(result['id'], '9615865')
d8624e6a 147 assertGreaterEqual(self, len(result['entries']), 1)
3941669d 148
20991253
PH
149 def test_soundcloud_playlist(self):
150 dl = FakeYDL()
151 ie = SoundcloudPlaylistIE(dl)
152 result = ie.extract('http://api.soundcloud.com/playlists/4110309')
153 self.assertIsPlaylist(result)
154 self.assertEqual(result['id'], '4110309')
155 self.assertEqual(result['title'], 'TILT Brass - Bowery Poetry Club, August \'03 [Non-Site SCR 02]')
156 assertRegexpMatches(
d82ba23b 157 self, result['description'], r'.*?TILT Brass - Bowery Poetry Club')
20991253
PH
158 self.assertEqual(len(result['entries']), 6)
159
b00ca882
JMF
160 def test_livestream_event(self):
161 dl = FakeYDL()
162 ie = LivestreamIE(dl)
163 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
164 self.assertIsPlaylist(result)
ecfef3e5 165 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
d8624e6a 166 assertGreaterEqual(self, len(result['entries']), 4)
b00ca882 167
78338f71
JMF
168 def test_livestreamoriginal_folder(self):
169 dl = FakeYDL()
170 ie = LivestreamOriginalIE(dl)
171 result = ie.extract('https://www.livestream.com/newplay/folder?dirId=a07bf706-d0e4-4e75-a747-b021d84f2fd3')
172 self.assertIsPlaylist(result)
173 self.assertEqual(result['id'], 'a07bf706-d0e4-4e75-a747-b021d84f2fd3')
d8624e6a 174 assertGreaterEqual(self, len(result['entries']), 28)
78338f71 175
91dbaef4
JMF
176 def test_nhl_videocenter(self):
177 dl = FakeYDL()
178 ie = NHLVideocenterIE(dl)
179 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
180 self.assertIsPlaylist(result)
ecfef3e5
PH
181 self.assertEqual(result['id'], '999')
182 self.assertEqual(result['title'], 'Highlights')
91dbaef4
JMF
183 self.assertEqual(len(result['entries']), 12)
184
165e3bb6
JMF
185 def test_bambuser_channel(self):
186 dl = FakeYDL()
187 ie = BambuserChannelIE(dl)
188 result = ie.extract('http://bambuser.com/channel/pixelversity')
189 self.assertIsPlaylist(result)
ecfef3e5 190 self.assertEqual(result['title'], 'pixelversity')
d8624e6a 191 assertGreaterEqual(self, len(result['entries']), 60)
165e3bb6 192
09804265
JMF
193 def test_bandcamp_album(self):
194 dl = FakeYDL()
195 ie = BandcampAlbumIE(dl)
a954584f 196 result = ie.extract('http://nightbringer.bandcamp.com/album/hierophany-of-the-open-grave')
09804265 197 self.assertIsPlaylist(result)
a954584f
S
198 self.assertEqual(result['title'], 'Hierophany of the Open Grave')
199 assertGreaterEqual(self, len(result['entries']), 9)
5270d8cb 200
201 def test_smotri_community(self):
202 dl = FakeYDL()
203 ie = SmotriCommunityIE(dl)
204 result = ie.extract('http://smotri.com/community/video/kommuna')
205 self.assertIsPlaylist(result)
ecfef3e5
PH
206 self.assertEqual(result['id'], 'kommuna')
207 self.assertEqual(result['title'], 'КПРФ')
d8624e6a 208 assertGreaterEqual(self, len(result['entries']), 4)
5270d8cb 209
210 def test_smotri_user(self):
211 dl = FakeYDL()
212 ie = SmotriUserIE(dl)
213 result = ie.extract('http://smotri.com/user/inspector')
214 self.assertIsPlaylist(result)
ecfef3e5
PH
215 self.assertEqual(result['id'], 'inspector')
216 self.assertEqual(result['title'], 'Inspector')
d8624e6a 217 assertGreaterEqual(self, len(result['entries']), 9)
09804265 218
d90df974
PH
219 def test_AcademicEarthCourse(self):
220 dl = FakeYDL()
221 ie = AcademicEarthCourseIE(dl)
9e57ce71 222 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
d90df974 223 self.assertIsPlaylist(result)
9e57ce71
JMF
224 self.assertEqual(result['id'], 'laws-of-nature')
225 self.assertEqual(result['title'], 'Laws of Nature')
226 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.")
227 self.assertEqual(len(result['entries']), 4)
8c21b7c6 228
229 def test_ivi_compilation(self):
230 dl = FakeYDL()
231 ie = IviCompilationIE(dl)
6ebb46c1 232 result = ie.extract('http://www.ivi.ru/watch/dvoe_iz_lartsa')
8c21b7c6 233 self.assertIsPlaylist(result)
6ebb46c1
S
234 self.assertEqual(result['id'], 'dvoe_iz_lartsa')
235 self.assertEqual(result['title'], 'Двое из ларца (2006 - 2008)')
d8624e6a 236 assertGreaterEqual(self, len(result['entries']), 24)
3a9d6790 237
8c21b7c6 238 def test_ivi_compilation_season(self):
239 dl = FakeYDL()
240 ie = IviCompilationIE(dl)
6ebb46c1 241 result = ie.extract('http://www.ivi.ru/watch/dvoe_iz_lartsa/season1')
8c21b7c6 242 self.assertIsPlaylist(result)
6ebb46c1
S
243 self.assertEqual(result['id'], 'dvoe_iz_lartsa/season1')
244 self.assertEqual(result['title'], 'Двое из ларца (2006 - 2008) 1 сезон')
d8624e6a 245 assertGreaterEqual(self, len(result['entries']), 12)
41cc67c5 246
247 def test_imdb_list(self):
248 dl = FakeYDL()
249 ie = ImdbListIE(dl)
98669ed7 250 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
41cc67c5 251 self.assertIsPlaylist(result)
98669ed7 252 self.assertEqual(result['id'], 'JFs9NWw6XI0')
253 self.assertEqual(result['title'], 'March 23, 2012 Releases')
254 self.assertEqual(len(result['entries']), 7)
d90df974 255
3d3538e4
PH
256 def test_khanacademy_topic(self):
257 dl = FakeYDL()
258 ie = KhanAcademyIE(dl)
259 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
260 self.assertIsPlaylist(result)
ecfef3e5
PH
261 self.assertEqual(result['id'], 'cryptography')
262 self.assertEqual(result['title'], 'Journey into cryptography')
263 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
d8624e6a 264 assertGreaterEqual(self, len(result['entries']), 3)
3d3538e4 265
484aaeb2
PH
266 def test_EveryonesMixtape(self):
267 dl = FakeYDL()
268 ie = EveryonesMixtapeIE(dl)
269 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
270 self.assertIsPlaylist(result)
271 self.assertEqual(result['id'], 'm7m0jJAbMQi')
272 self.assertEqual(result['title'], 'Driving')
273 self.assertEqual(len(result['entries']), 24)
87fac323 274
275 def test_rutube_channel(self):
276 dl = FakeYDL()
277 ie = RutubeChannelIE(dl)
fd69098a 278 result = ie.extract('http://rutube.ru/tags/video/1800/')
87fac323 279 self.assertIsPlaylist(result)
fd69098a 280 self.assertEqual(result['id'], '1800')
d8624e6a 281 assertGreaterEqual(self, len(result['entries']), 68)
fd69098a
S
282
283 def test_rutube_person(self):
284 dl = FakeYDL()
285 ie = RutubePersonIE(dl)
286 result = ie.extract('http://rutube.ru/video/person/313878/')
287 self.assertIsPlaylist(result)
288 self.assertEqual(result['id'], '313878')
d8624e6a 289 assertGreaterEqual(self, len(result['entries']), 37)
484aaeb2 290
99877772
PH
291 def test_multiple_brightcove_videos(self):
292 # https://github.com/rg3/youtube-dl/issues/2283
293 dl = FakeYDL()
294 ie = GenericIE(dl)
295 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
296 self.assertIsPlaylist(result)
297 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
298 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
299 self.assertEqual(len(result['entries']), 3)
300
ccf9114e
PH
301 def test_GoogleSearch(self):
302 dl = FakeYDL()
303 ie = GoogleSearchIE(dl)
304 result = ie.extract('gvsearch15:python language')
305 self.assertIsPlaylist(result)
306 self.assertEqual(result['id'], 'python language')
307 self.assertEqual(result['title'], 'python language')
c3d36f13 308 self.assertEqual(len(result['entries']), 15)
d90df974 309
4fc946b5
PH
310 def test_generic_rss_feed(self):
311 dl = FakeYDL()
312 ie = GenericIE(dl)
6a724239 313 result = ie.extract('http://phihag.de/2014/youtube-dl/rss.xml')
4fc946b5 314 self.assertIsPlaylist(result)
6a724239 315 self.assertEqual(result['id'], 'http://phihag.de/2014/youtube-dl/rss.xml')
4fc946b5
PH
316 self.assertEqual(result['title'], 'Zero Punctuation')
317 self.assertTrue(len(result['entries']) > 10)
318
ca1fee34
JMF
319 def test_ted_playlist(self):
320 dl = FakeYDL()
321 ie = TEDIE(dl)
322 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
323 self.assertIsPlaylist(result)
324 self.assertEqual(result['id'], '10')
325 self.assertEqual(result['title'], 'Who are the hackers?')
d8624e6a 326 assertGreaterEqual(self, len(result['entries']), 6)
ca1fee34 327
231f76b5
PH
328 def test_toypics_user(self):
329 dl = FakeYDL()
330 ie = ToypicsUserIE(dl)
331 result = ie.extract('http://videos.toypics.net/Mikey')
332 self.assertIsPlaylist(result)
333 self.assertEqual(result['id'], 'Mikey')
d8624e6a 334 assertGreaterEqual(self, len(result['entries']), 17)
231f76b5 335
9f5809b3 336 def test_xtube_user(self):
337 dl = FakeYDL()
338 ie = XTubeUserIE(dl)
339 result = ie.extract('http://www.xtube.com/community/profile.php?user=greenshowers')
340 self.assertIsPlaylist(result)
341 self.assertEqual(result['id'], 'greenshowers')
d8624e6a 342 assertGreaterEqual(self, len(result['entries']), 155)
9f5809b3 343
ea38e55f
PH
344 def test_InstagramUser(self):
345 dl = FakeYDL()
346 ie = InstagramUserIE(dl)
347 result = ie.extract('http://instagram.com/porsche')
348 self.assertIsPlaylist(result)
349 self.assertEqual(result['id'], 'porsche')
d8624e6a 350 assertGreaterEqual(self, len(result['entries']), 2)
ea38e55f
PH
351 test_video = next(
352 e for e in result['entries']
353 if e['id'] == '614605558512799803_462752227')
354 dl.add_default_extra_info(test_video, ie, '(irrelevant URL)')
355 dl.process_video_result(test_video, download=False)
356 EXPECTED = {
357 'id': '614605558512799803_462752227',
358 'ext': 'mp4',
359 'title': '#Porsche Intelligent Performance.',
360 'thumbnail': 're:^https?://.*\.jpg',
361 'uploader': 'Porsche',
362 'uploader_id': 'porsche',
912b38b4
PH
363 'timestamp': 1387486713,
364 'upload_date': '20131219',
ea38e55f
PH
365 }
366 expect_info_dict(self, EXPECTED, test_video)
367
aea6e7fc
PH
368 def test_CSpan_playlist(self):
369 dl = FakeYDL()
370 ie = CSpanIE(dl)
371 result = ie.extract(
372 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall')
373 self.assertIsPlaylist(result)
374 self.assertEqual(result['id'], '342759')
375 self.assertEqual(
376 result['title'], 'General Motors Ignition Switch Recall')
aea6e7fc
PH
377 whole_duration = sum(e['duration'] for e in result['entries'])
378 self.assertEqual(whole_duration, 14855)
379
de906ef5
PH
380 def test_aol_playlist(self):
381 dl = FakeYDL()
382 ie = AolIE(dl)
383 result = ie.extract(
384 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316')
385 self.assertIsPlaylist(result)
386 self.assertEqual(result['id'], '152147')
387 self.assertEqual(
388 result['title'], 'Brace Yourself - Today\'s Weirdest News')
d8624e6a 389 assertGreaterEqual(self, len(result['entries']), 10)
ea38e55f 390
31a196d7 391 def test_TeacherTubeUser(self):
b4e74474 392 dl = FakeYDL()
31a196d7
PP
393 ie = TeacherTubeUserIE(dl)
394 result = ie.extract('http://www.teachertube.com/user/profile/rbhagwati2')
b4e74474 395 self.assertIsPlaylist(result)
396 self.assertEqual(result['id'], 'rbhagwati2')
d8624e6a 397 assertGreaterEqual(self, len(result['entries']), 179)
b4e74474 398
a3c736de
JMF
399if __name__ == '__main__':
400 unittest.main()