5 # Add new tests to the extractors themselves, like this:
7 # 'url': 'http://example.com/playlist/42',
8 # 'playlist_mincount': 99,
11 # 'title': 'Playlist number forty-two',
15 from __future__ import unicode_literals
17 # Allow direct execution
21 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
23 from test.helper import (
30 from youtube_dl.extractor import (
31 AcademicEarthCourseIE,
32 DailymotionPlaylistIE,
69 class TestPlaylists(unittest.TestCase):
70 def assertIsPlaylist(self, info):
71 """Make sure the info has '_type' set to 'playlist'"""
72 self.assertEqual(info['_type'], 'playlist')
74 def test_dailymotion_playlist(self):
76 ie = DailymotionPlaylistIE(dl)
77 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
78 self.assertIsPlaylist(result)
79 self.assertEqual(result['title'], 'SPORT')
80 self.assertTrue(len(result['entries']) > 20)
82 def test_dailymotion_user(self):
84 ie = DailymotionUserIE(dl)
85 result = ie.extract('https://www.dailymotion.com/user/nqtv')
86 self.assertIsPlaylist(result)
87 assertGreaterEqual(self, len(result['entries']), 100)
88 self.assertEqual(result['title'], 'Rémi Gaillard')
90 def test_vimeo_channel(self):
92 ie = VimeoChannelIE(dl)
93 result = ie.extract('http://vimeo.com/channels/tributes')
94 self.assertIsPlaylist(result)
95 self.assertEqual(result['title'], 'Vimeo Tributes')
96 self.assertTrue(len(result['entries']) > 24)
98 def test_vimeo_user(self):
101 result = ie.extract('http://vimeo.com/nkistudio/videos')
102 self.assertIsPlaylist(result)
103 self.assertEqual(result['title'], 'Nki')
104 self.assertTrue(len(result['entries']) > 65)
106 def test_vimeo_album(self):
108 ie = VimeoAlbumIE(dl)
109 result = ie.extract('http://vimeo.com/album/2632481')
110 self.assertIsPlaylist(result)
111 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
112 self.assertTrue(len(result['entries']) > 12)
114 def test_vimeo_groups(self):
116 ie = VimeoGroupsIE(dl)
117 result = ie.extract('http://vimeo.com/groups/rolexawards')
118 self.assertIsPlaylist(result)
119 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
120 self.assertTrue(len(result['entries']) > 72)
122 def test_vine_user(self):
125 result = ie.extract('https://vine.co/Visa')
126 self.assertIsPlaylist(result)
127 assertGreaterEqual(self, len(result['entries']), 47)
129 def test_ustream_channel(self):
131 ie = UstreamChannelIE(dl)
132 result = ie.extract('http://www.ustream.tv/channel/channeljapan')
133 self.assertIsPlaylist(result)
134 self.assertEqual(result['id'], '10874166')
135 assertGreaterEqual(self, len(result['entries']), 54)
137 def test_soundcloud_set(self):
139 ie = SoundcloudSetIE(dl)
140 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
141 self.assertIsPlaylist(result)
142 self.assertEqual(result['title'], 'The Royal Concept EP')
143 assertGreaterEqual(self, len(result['entries']), 6)
145 def test_soundcloud_user(self):
147 ie = SoundcloudUserIE(dl)
148 result = ie.extract('https://soundcloud.com/the-concept-band')
149 self.assertIsPlaylist(result)
150 self.assertEqual(result['id'], '9615865')
151 assertGreaterEqual(self, len(result['entries']), 12)
153 def test_soundcloud_likes(self):
155 ie = SoundcloudUserIE(dl)
156 result = ie.extract('https://soundcloud.com/the-concept-band/likes')
157 self.assertIsPlaylist(result)
158 self.assertEqual(result['id'], '9615865')
159 assertGreaterEqual(self, len(result['entries']), 1)
161 def test_soundcloud_playlist(self):
163 ie = SoundcloudPlaylistIE(dl)
164 result = ie.extract('http://api.soundcloud.com/playlists/4110309')
165 self.assertIsPlaylist(result)
166 self.assertEqual(result['id'], '4110309')
167 self.assertEqual(result['title'], 'TILT Brass - Bowery Poetry Club, August \'03 [Non-Site SCR 02]')
169 self, result['description'], r'.*?TILT Brass - Bowery Poetry Club')
170 self.assertEqual(len(result['entries']), 6)
172 def test_livestream_event(self):
174 ie = LivestreamIE(dl)
175 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
176 self.assertIsPlaylist(result)
177 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
178 assertGreaterEqual(self, len(result['entries']), 4)
180 def test_livestreamoriginal_folder(self):
182 ie = LivestreamOriginalIE(dl)
183 result = ie.extract('https://www.livestream.com/newplay/folder?dirId=a07bf706-d0e4-4e75-a747-b021d84f2fd3')
184 self.assertIsPlaylist(result)
185 self.assertEqual(result['id'], 'a07bf706-d0e4-4e75-a747-b021d84f2fd3')
186 assertGreaterEqual(self, len(result['entries']), 28)
188 def test_nhl_videocenter(self):
190 ie = NHLVideocenterIE(dl)
191 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
192 self.assertIsPlaylist(result)
193 self.assertEqual(result['id'], '999')
194 self.assertEqual(result['title'], 'Highlights')
195 self.assertEqual(len(result['entries']), 12)
197 def test_bambuser_channel(self):
199 ie = BambuserChannelIE(dl)
200 result = ie.extract('http://bambuser.com/channel/pixelversity')
201 self.assertIsPlaylist(result)
202 self.assertEqual(result['title'], 'pixelversity')
203 assertGreaterEqual(self, len(result['entries']), 60)
205 def test_bandcamp_album(self):
207 ie = BandcampAlbumIE(dl)
208 result = ie.extract('http://nightbringer.bandcamp.com/album/hierophany-of-the-open-grave')
209 self.assertIsPlaylist(result)
210 self.assertEqual(result['title'], 'Hierophany of the Open Grave')
211 assertGreaterEqual(self, len(result['entries']), 9)
213 def test_smotri_community(self):
215 ie = SmotriCommunityIE(dl)
216 result = ie.extract('http://smotri.com/community/video/kommuna')
217 self.assertIsPlaylist(result)
218 self.assertEqual(result['id'], 'kommuna')
219 self.assertEqual(result['title'], 'КПРФ')
220 assertGreaterEqual(self, len(result['entries']), 4)
222 def test_smotri_user(self):
224 ie = SmotriUserIE(dl)
225 result = ie.extract('http://smotri.com/user/inspector')
226 self.assertIsPlaylist(result)
227 self.assertEqual(result['id'], 'inspector')
228 self.assertEqual(result['title'], 'Inspector')
229 assertGreaterEqual(self, len(result['entries']), 9)
231 def test_AcademicEarthCourse(self):
233 ie = AcademicEarthCourseIE(dl)
234 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
235 self.assertIsPlaylist(result)
236 self.assertEqual(result['id'], 'laws-of-nature')
237 self.assertEqual(result['title'], 'Laws of Nature')
238 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.")
239 self.assertEqual(len(result['entries']), 4)
241 def test_ivi_compilation(self):
243 ie = IviCompilationIE(dl)
244 result = ie.extract('http://www.ivi.ru/watch/dvoe_iz_lartsa')
245 self.assertIsPlaylist(result)
246 self.assertEqual(result['id'], 'dvoe_iz_lartsa')
247 self.assertEqual(result['title'], 'Двое из ларца (2006 - 2008)')
248 assertGreaterEqual(self, len(result['entries']), 24)
250 def test_ivi_compilation_season(self):
252 ie = IviCompilationIE(dl)
253 result = ie.extract('http://www.ivi.ru/watch/dvoe_iz_lartsa/season1')
254 self.assertIsPlaylist(result)
255 self.assertEqual(result['id'], 'dvoe_iz_lartsa/season1')
256 self.assertEqual(result['title'], 'Двое из ларца (2006 - 2008) 1 сезон')
257 assertGreaterEqual(self, len(result['entries']), 12)
259 def test_imdb_list(self):
262 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
263 self.assertIsPlaylist(result)
264 self.assertEqual(result['id'], 'JFs9NWw6XI0')
265 self.assertEqual(result['title'], 'March 23, 2012 Releases')
266 self.assertEqual(len(result['entries']), 7)
268 def test_khanacademy_topic(self):
270 ie = KhanAcademyIE(dl)
271 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
272 self.assertIsPlaylist(result)
273 self.assertEqual(result['id'], 'cryptography')
274 self.assertEqual(result['title'], 'Journey into cryptography')
275 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
276 assertGreaterEqual(self, len(result['entries']), 3)
278 def test_EveryonesMixtape(self):
280 ie = EveryonesMixtapeIE(dl)
281 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
282 self.assertIsPlaylist(result)
283 self.assertEqual(result['id'], 'm7m0jJAbMQi')
284 self.assertEqual(result['title'], 'Driving')
285 self.assertEqual(len(result['entries']), 24)
287 def test_rutube_channel(self):
289 ie = RutubeChannelIE(dl)
290 result = ie.extract('http://rutube.ru/tags/video/1800/')
291 self.assertIsPlaylist(result)
292 self.assertEqual(result['id'], '1800')
293 assertGreaterEqual(self, len(result['entries']), 68)
295 def test_rutube_person(self):
297 ie = RutubePersonIE(dl)
298 result = ie.extract('http://rutube.ru/video/person/313878/')
299 self.assertIsPlaylist(result)
300 self.assertEqual(result['id'], '313878')
301 assertGreaterEqual(self, len(result['entries']), 37)
303 def test_multiple_brightcove_videos(self):
304 # https://github.com/rg3/youtube-dl/issues/2283
307 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
308 self.assertIsPlaylist(result)
309 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
310 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
311 self.assertEqual(len(result['entries']), 3)
313 def test_GoogleSearch(self):
315 ie = GoogleSearchIE(dl)
316 result = ie.extract('gvsearch15:python language')
317 self.assertIsPlaylist(result)
318 self.assertEqual(result['id'], 'python language')
319 self.assertEqual(result['title'], 'python language')
320 self.assertEqual(len(result['entries']), 15)
322 def test_generic_rss_feed(self):
325 result = ie.extract('http://phihag.de/2014/youtube-dl/rss.xml')
326 self.assertIsPlaylist(result)
327 self.assertEqual(result['id'], 'http://phihag.de/2014/youtube-dl/rss.xml')
328 self.assertEqual(result['title'], 'Zero Punctuation')
329 self.assertTrue(len(result['entries']) > 10)
331 def test_ted_playlist(self):
334 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
335 self.assertIsPlaylist(result)
336 self.assertEqual(result['id'], '10')
337 self.assertEqual(result['title'], 'Who are the hackers?')
338 assertGreaterEqual(self, len(result['entries']), 6)
340 def test_toypics_user(self):
342 ie = ToypicsUserIE(dl)
343 result = ie.extract('http://videos.toypics.net/Mikey')
344 self.assertIsPlaylist(result)
345 self.assertEqual(result['id'], 'Mikey')
346 assertGreaterEqual(self, len(result['entries']), 17)
348 def test_xtube_user(self):
351 result = ie.extract('http://www.xtube.com/community/profile.php?user=greenshowers')
352 self.assertIsPlaylist(result)
353 self.assertEqual(result['id'], 'greenshowers')
354 assertGreaterEqual(self, len(result['entries']), 155)
356 def test_InstagramUser(self):
358 ie = InstagramUserIE(dl)
359 result = ie.extract('http://instagram.com/porsche')
360 self.assertIsPlaylist(result)
361 self.assertEqual(result['id'], 'porsche')
362 assertGreaterEqual(self, len(result['entries']), 2)
364 e for e in result['entries']
365 if e['id'] == '614605558512799803_462752227')
366 dl.add_default_extra_info(test_video, ie, '(irrelevant URL)')
367 dl.process_video_result(test_video, download=False)
369 'id': '614605558512799803_462752227',
371 'title': '#Porsche Intelligent Performance.',
372 'thumbnail': 're:^https?://.*\.jpg',
373 'uploader': 'Porsche',
374 'uploader_id': 'porsche',
375 'timestamp': 1387486713,
376 'upload_date': '20131219',
378 expect_info_dict(self, EXPECTED, test_video)
380 def test_CSpan_playlist(self):
384 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall')
385 self.assertIsPlaylist(result)
386 self.assertEqual(result['id'], '342759')
388 result['title'], 'General Motors Ignition Switch Recall')
389 whole_duration = sum(e['duration'] for e in result['entries'])
390 self.assertEqual(whole_duration, 14855)
392 def test_aol_playlist(self):
396 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316')
397 self.assertIsPlaylist(result)
398 self.assertEqual(result['id'], '152147')
400 result['title'], 'Brace Yourself - Today\'s Weirdest News')
401 assertGreaterEqual(self, len(result['entries']), 10)
403 def test_TeacherTubeUser(self):
405 ie = TeacherTubeUserIE(dl)
406 result = ie.extract('http://www.teachertube.com/user/profile/rbhagwati2')
407 self.assertIsPlaylist(result)
408 self.assertEqual(result['id'], 'rbhagwati2')
409 assertGreaterEqual(self, len(result['entries']), 179)
411 def test_GameOne_playlist(self):
413 ie = GameOnePlaylistIE(dl)
414 result = ie.extract('http://www.gameone.de/tv')
415 self.assertIsPlaylist(result)
416 self.assertEqual(result['title'], 'GameOne')
417 assertGreaterEqual(self, len(result['entries']), 294)
419 if __name__ == '__main__':