4 from __future__ import unicode_literals
6 # Allow direct execution
10 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
12 from test.helper import (
18 from youtube_dl.extractor import (
19 AcademicEarthCourseIE,
20 DailymotionPlaylistIE,
31 TeacherTubeClassroomIE,
55 class TestPlaylists(unittest.TestCase):
56 def assertIsPlaylist(self, info):
57 """Make sure the info has '_type' set to 'playlist'"""
58 self.assertEqual(info['_type'], 'playlist')
60 def test_dailymotion_playlist(self):
62 ie = DailymotionPlaylistIE(dl)
63 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
64 self.assertIsPlaylist(result)
65 self.assertEqual(result['title'], 'SPORT')
66 self.assertTrue(len(result['entries']) > 20)
68 def test_dailymotion_user(self):
70 ie = DailymotionUserIE(dl)
71 result = ie.extract('https://www.dailymotion.com/user/nqtv')
72 self.assertIsPlaylist(result)
73 self.assertEqual(result['title'], 'Rémi Gaillard')
74 self.assertTrue(len(result['entries']) >= 100)
76 def test_vimeo_channel(self):
78 ie = VimeoChannelIE(dl)
79 result = ie.extract('http://vimeo.com/channels/tributes')
80 self.assertIsPlaylist(result)
81 self.assertEqual(result['title'], 'Vimeo Tributes')
82 self.assertTrue(len(result['entries']) > 24)
84 def test_vimeo_user(self):
87 result = ie.extract('http://vimeo.com/nkistudio/videos')
88 self.assertIsPlaylist(result)
89 self.assertEqual(result['title'], 'Nki')
90 self.assertTrue(len(result['entries']) > 65)
92 def test_vimeo_album(self):
95 result = ie.extract('http://vimeo.com/album/2632481')
96 self.assertIsPlaylist(result)
97 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
98 self.assertTrue(len(result['entries']) > 12)
100 def test_vimeo_groups(self):
102 ie = VimeoGroupsIE(dl)
103 result = ie.extract('http://vimeo.com/groups/rolexawards')
104 self.assertIsPlaylist(result)
105 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
106 self.assertTrue(len(result['entries']) > 72)
108 def test_vine_user(self):
111 result = ie.extract('https://vine.co/Visa')
112 self.assertIsPlaylist(result)
113 self.assertTrue(len(result['entries']) >= 50)
115 def test_ustream_channel(self):
117 ie = UstreamChannelIE(dl)
118 result = ie.extract('http://www.ustream.tv/channel/channeljapan')
119 self.assertIsPlaylist(result)
120 self.assertEqual(result['id'], '10874166')
121 self.assertTrue(len(result['entries']) >= 54)
123 def test_soundcloud_set(self):
125 ie = SoundcloudSetIE(dl)
126 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
127 self.assertIsPlaylist(result)
128 self.assertEqual(result['title'], 'The Royal Concept EP')
129 self.assertTrue(len(result['entries']) >= 6)
131 def test_soundcloud_user(self):
133 ie = SoundcloudUserIE(dl)
134 result = ie.extract('https://soundcloud.com/the-concept-band')
135 self.assertIsPlaylist(result)
136 self.assertEqual(result['id'], '9615865')
137 self.assertTrue(len(result['entries']) >= 12)
139 def test_soundcloud_playlist(self):
141 ie = SoundcloudPlaylistIE(dl)
142 result = ie.extract('http://api.soundcloud.com/playlists/4110309')
143 self.assertIsPlaylist(result)
144 self.assertEqual(result['id'], '4110309')
145 self.assertEqual(result['title'], 'TILT Brass - Bowery Poetry Club, August \'03 [Non-Site SCR 02]')
147 self, result['description'], r'TILT Brass - Bowery Poetry Club')
148 self.assertEqual(len(result['entries']), 6)
150 def test_livestream_event(self):
152 ie = LivestreamIE(dl)
153 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
154 self.assertIsPlaylist(result)
155 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
156 self.assertTrue(len(result['entries']) >= 4)
158 def test_nhl_videocenter(self):
160 ie = NHLVideocenterIE(dl)
161 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
162 self.assertIsPlaylist(result)
163 self.assertEqual(result['id'], '999')
164 self.assertEqual(result['title'], 'Highlights')
165 self.assertEqual(len(result['entries']), 12)
167 def test_bambuser_channel(self):
169 ie = BambuserChannelIE(dl)
170 result = ie.extract('http://bambuser.com/channel/pixelversity')
171 self.assertIsPlaylist(result)
172 self.assertEqual(result['title'], 'pixelversity')
173 self.assertTrue(len(result['entries']) >= 60)
175 def test_bandcamp_album(self):
177 ie = BandcampAlbumIE(dl)
178 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
179 self.assertIsPlaylist(result)
180 self.assertEqual(result['title'], 'Nightmare Night EP')
181 self.assertTrue(len(result['entries']) >= 4)
183 def test_smotri_community(self):
185 ie = SmotriCommunityIE(dl)
186 result = ie.extract('http://smotri.com/community/video/kommuna')
187 self.assertIsPlaylist(result)
188 self.assertEqual(result['id'], 'kommuna')
189 self.assertEqual(result['title'], 'КПРФ')
190 self.assertTrue(len(result['entries']) >= 4)
192 def test_smotri_user(self):
194 ie = SmotriUserIE(dl)
195 result = ie.extract('http://smotri.com/user/inspector')
196 self.assertIsPlaylist(result)
197 self.assertEqual(result['id'], 'inspector')
198 self.assertEqual(result['title'], 'Inspector')
199 self.assertTrue(len(result['entries']) >= 9)
201 def test_AcademicEarthCourse(self):
203 ie = AcademicEarthCourseIE(dl)
204 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
205 self.assertIsPlaylist(result)
206 self.assertEqual(result['id'], 'laws-of-nature')
207 self.assertEqual(result['title'], 'Laws of Nature')
208 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.")
209 self.assertEqual(len(result['entries']), 4)
211 def test_ivi_compilation(self):
213 ie = IviCompilationIE(dl)
214 result = ie.extract('http://www.ivi.ru/watch/dvoe_iz_lartsa')
215 self.assertIsPlaylist(result)
216 self.assertEqual(result['id'], 'dvoe_iz_lartsa')
217 self.assertEqual(result['title'], 'Двое из ларца (2006 - 2008)')
218 self.assertTrue(len(result['entries']) >= 24)
220 def test_ivi_compilation_season(self):
222 ie = IviCompilationIE(dl)
223 result = ie.extract('http://www.ivi.ru/watch/dvoe_iz_lartsa/season1')
224 self.assertIsPlaylist(result)
225 self.assertEqual(result['id'], 'dvoe_iz_lartsa/season1')
226 self.assertEqual(result['title'], 'Двое из ларца (2006 - 2008) 1 сезон')
227 self.assertTrue(len(result['entries']) >= 12)
229 def test_imdb_list(self):
232 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
233 self.assertIsPlaylist(result)
234 self.assertEqual(result['id'], 'JFs9NWw6XI0')
235 self.assertEqual(result['title'], 'March 23, 2012 Releases')
236 self.assertEqual(len(result['entries']), 7)
238 def test_khanacademy_topic(self):
240 ie = KhanAcademyIE(dl)
241 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
242 self.assertIsPlaylist(result)
243 self.assertEqual(result['id'], 'cryptography')
244 self.assertEqual(result['title'], 'Journey into cryptography')
245 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
246 self.assertTrue(len(result['entries']) >= 3)
248 def test_EveryonesMixtape(self):
250 ie = EveryonesMixtapeIE(dl)
251 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
252 self.assertIsPlaylist(result)
253 self.assertEqual(result['id'], 'm7m0jJAbMQi')
254 self.assertEqual(result['title'], 'Driving')
255 self.assertEqual(len(result['entries']), 24)
257 def test_rutube_channel(self):
259 ie = RutubeChannelIE(dl)
260 result = ie.extract('http://rutube.ru/tags/video/1800/')
261 self.assertIsPlaylist(result)
262 self.assertEqual(result['id'], '1800')
263 self.assertTrue(len(result['entries']) >= 68)
265 def test_rutube_person(self):
267 ie = RutubePersonIE(dl)
268 result = ie.extract('http://rutube.ru/video/person/313878/')
269 self.assertIsPlaylist(result)
270 self.assertEqual(result['id'], '313878')
271 self.assertTrue(len(result['entries']) >= 37)
273 def test_multiple_brightcove_videos(self):
274 # https://github.com/rg3/youtube-dl/issues/2283
277 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
278 self.assertIsPlaylist(result)
279 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
280 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
281 self.assertEqual(len(result['entries']), 3)
283 def test_GoogleSearch(self):
285 ie = GoogleSearchIE(dl)
286 result = ie.extract('gvsearch15:python language')
287 self.assertIsPlaylist(result)
288 self.assertEqual(result['id'], 'python language')
289 self.assertEqual(result['title'], 'python language')
290 self.assertEqual(len(result['entries']), 15)
292 def test_generic_rss_feed(self):
295 result = ie.extract('http://phihag.de/2014/youtube-dl/rss.xml')
296 self.assertIsPlaylist(result)
297 self.assertEqual(result['id'], 'http://phihag.de/2014/youtube-dl/rss.xml')
298 self.assertEqual(result['title'], 'Zero Punctuation')
299 self.assertTrue(len(result['entries']) > 10)
301 def test_ted_playlist(self):
304 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
305 self.assertIsPlaylist(result)
306 self.assertEqual(result['id'], '10')
307 self.assertEqual(result['title'], 'Who are the hackers?')
308 self.assertTrue(len(result['entries']) >= 6)
310 def test_toypics_user(self):
312 ie = ToypicsUserIE(dl)
313 result = ie.extract('http://videos.toypics.net/Mikey')
314 self.assertIsPlaylist(result)
315 self.assertEqual(result['id'], 'Mikey')
316 self.assertTrue(len(result['entries']) >= 17)
318 def test_xtube_user(self):
321 result = ie.extract('http://www.xtube.com/community/profile.php?user=greenshowers')
322 self.assertIsPlaylist(result)
323 self.assertEqual(result['id'], 'greenshowers')
324 self.assertTrue(len(result['entries']) >= 155)
326 def test_InstagramUser(self):
328 ie = InstagramUserIE(dl)
329 result = ie.extract('http://instagram.com/porsche')
330 self.assertIsPlaylist(result)
331 self.assertEqual(result['id'], 'porsche')
332 self.assertTrue(len(result['entries']) >= 2)
334 e for e in result['entries']
335 if e['id'] == '614605558512799803_462752227')
336 dl.add_default_extra_info(test_video, ie, '(irrelevant URL)')
337 dl.process_video_result(test_video, download=False)
339 'id': '614605558512799803_462752227',
341 'title': '#Porsche Intelligent Performance.',
342 'thumbnail': 're:^https?://.*\.jpg',
343 'uploader': 'Porsche',
344 'uploader_id': 'porsche',
345 'timestamp': 1387486713,
346 'upload_date': '20131219',
348 expect_info_dict(self, EXPECTED, test_video)
350 def test_CSpan_playlist(self):
354 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall')
355 self.assertIsPlaylist(result)
356 self.assertEqual(result['id'], '342759')
358 result['title'], 'General Motors Ignition Switch Recall')
359 whole_duration = sum(e['duration'] for e in result['entries'])
360 self.assertEqual(whole_duration, 14855)
362 def test_aol_playlist(self):
366 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316')
367 self.assertIsPlaylist(result)
368 self.assertEqual(result['id'], '152147')
370 result['title'], 'Brace Yourself - Today\'s Weirdest News')
371 self.assertTrue(len(result['entries']) >= 10)
373 def test_TeacherTubeClassroom(self):
375 ie = TeacherTubeClassroomIE(dl)
376 result = ie.extract('http://www.teachertube.com/view_classroom.php?user=rbhagwati2')
377 self.assertIsPlaylist(result)
378 self.assertEqual(result['id'], 'rbhagwati2')
379 self.assertTrue(len(result['entries']) >= 20)
381 if __name__ == '__main__':