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,
53 class TestPlaylists(unittest.TestCase):
54 def assertIsPlaylist(self, info):
55 """Make sure the info has '_type' set to 'playlist'"""
56 self.assertEqual(info['_type'], 'playlist')
58 def test_dailymotion_playlist(self):
60 ie = DailymotionPlaylistIE(dl)
61 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
62 self.assertIsPlaylist(result)
63 self.assertEqual(result['title'], 'SPORT')
64 self.assertTrue(len(result['entries']) > 20)
66 def test_dailymotion_user(self):
68 ie = DailymotionUserIE(dl)
69 result = ie.extract('https://www.dailymotion.com/user/nqtv')
70 self.assertIsPlaylist(result)
71 self.assertEqual(result['title'], 'Rémi Gaillard')
72 self.assertTrue(len(result['entries']) >= 100)
74 def test_vimeo_channel(self):
76 ie = VimeoChannelIE(dl)
77 result = ie.extract('http://vimeo.com/channels/tributes')
78 self.assertIsPlaylist(result)
79 self.assertEqual(result['title'], 'Vimeo Tributes')
80 self.assertTrue(len(result['entries']) > 24)
82 def test_vimeo_user(self):
85 result = ie.extract('http://vimeo.com/nkistudio/videos')
86 self.assertIsPlaylist(result)
87 self.assertEqual(result['title'], 'Nki')
88 self.assertTrue(len(result['entries']) > 65)
90 def test_vimeo_album(self):
93 result = ie.extract('http://vimeo.com/album/2632481')
94 self.assertIsPlaylist(result)
95 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
96 self.assertTrue(len(result['entries']) > 12)
98 def test_vimeo_groups(self):
100 ie = VimeoGroupsIE(dl)
101 result = ie.extract('http://vimeo.com/groups/rolexawards')
102 self.assertIsPlaylist(result)
103 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
104 self.assertTrue(len(result['entries']) > 72)
106 def test_vine_user(self):
109 result = ie.extract('https://vine.co/Visa')
110 self.assertIsPlaylist(result)
111 self.assertTrue(len(result['entries']) >= 50)
113 def test_ustream_channel(self):
115 ie = UstreamChannelIE(dl)
116 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
117 self.assertIsPlaylist(result)
118 self.assertEqual(result['id'], '5124905')
119 self.assertTrue(len(result['entries']) >= 6)
121 def test_soundcloud_set(self):
123 ie = SoundcloudSetIE(dl)
124 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
125 self.assertIsPlaylist(result)
126 self.assertEqual(result['title'], 'The Royal Concept EP')
127 self.assertTrue(len(result['entries']) >= 6)
129 def test_soundcloud_user(self):
131 ie = SoundcloudUserIE(dl)
132 result = ie.extract('https://soundcloud.com/the-concept-band')
133 self.assertIsPlaylist(result)
134 self.assertEqual(result['id'], '9615865')
135 self.assertTrue(len(result['entries']) >= 12)
137 def test_soundcloud_playlist(self):
139 ie = SoundcloudPlaylistIE(dl)
140 result = ie.extract('http://api.soundcloud.com/playlists/4110309')
141 self.assertIsPlaylist(result)
142 self.assertEqual(result['id'], '4110309')
143 self.assertEqual(result['title'], 'TILT Brass - Bowery Poetry Club, August \'03 [Non-Site SCR 02]')
145 self, result['description'], r'TILT Brass - Bowery Poetry Club')
146 self.assertEqual(len(result['entries']), 6)
148 def test_livestream_event(self):
150 ie = LivestreamIE(dl)
151 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
152 self.assertIsPlaylist(result)
153 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
154 self.assertTrue(len(result['entries']) >= 4)
156 def test_nhl_videocenter(self):
158 ie = NHLVideocenterIE(dl)
159 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
160 self.assertIsPlaylist(result)
161 self.assertEqual(result['id'], '999')
162 self.assertEqual(result['title'], 'Highlights')
163 self.assertEqual(len(result['entries']), 12)
165 def test_bambuser_channel(self):
167 ie = BambuserChannelIE(dl)
168 result = ie.extract('http://bambuser.com/channel/pixelversity')
169 self.assertIsPlaylist(result)
170 self.assertEqual(result['title'], 'pixelversity')
171 self.assertTrue(len(result['entries']) >= 60)
173 def test_bandcamp_album(self):
175 ie = BandcampAlbumIE(dl)
176 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
177 self.assertIsPlaylist(result)
178 self.assertEqual(result['title'], 'Nightmare Night EP')
179 self.assertTrue(len(result['entries']) >= 4)
181 def test_smotri_community(self):
183 ie = SmotriCommunityIE(dl)
184 result = ie.extract('http://smotri.com/community/video/kommuna')
185 self.assertIsPlaylist(result)
186 self.assertEqual(result['id'], 'kommuna')
187 self.assertEqual(result['title'], 'КПРФ')
188 self.assertTrue(len(result['entries']) >= 4)
190 def test_smotri_user(self):
192 ie = SmotriUserIE(dl)
193 result = ie.extract('http://smotri.com/user/inspector')
194 self.assertIsPlaylist(result)
195 self.assertEqual(result['id'], 'inspector')
196 self.assertEqual(result['title'], 'Inspector')
197 self.assertTrue(len(result['entries']) >= 9)
199 def test_AcademicEarthCourse(self):
201 ie = AcademicEarthCourseIE(dl)
202 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
203 self.assertIsPlaylist(result)
204 self.assertEqual(result['id'], 'laws-of-nature')
205 self.assertEqual(result['title'], 'Laws of Nature')
206 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.")
207 self.assertEqual(len(result['entries']), 4)
209 def test_ivi_compilation(self):
211 ie = IviCompilationIE(dl)
212 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
213 self.assertIsPlaylist(result)
214 self.assertEqual(result['id'], 'dezhurnyi_angel')
215 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
216 self.assertTrue(len(result['entries']) >= 23)
218 def test_ivi_compilation_season(self):
220 ie = IviCompilationIE(dl)
221 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
222 self.assertIsPlaylist(result)
223 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
224 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
225 self.assertTrue(len(result['entries']) >= 7)
227 def test_imdb_list(self):
230 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
231 self.assertIsPlaylist(result)
232 self.assertEqual(result['id'], 'JFs9NWw6XI0')
233 self.assertEqual(result['title'], 'March 23, 2012 Releases')
234 self.assertEqual(len(result['entries']), 7)
236 def test_khanacademy_topic(self):
238 ie = KhanAcademyIE(dl)
239 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
240 self.assertIsPlaylist(result)
241 self.assertEqual(result['id'], 'cryptography')
242 self.assertEqual(result['title'], 'Journey into cryptography')
243 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
244 self.assertTrue(len(result['entries']) >= 3)
246 def test_EveryonesMixtape(self):
248 ie = EveryonesMixtapeIE(dl)
249 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
250 self.assertIsPlaylist(result)
251 self.assertEqual(result['id'], 'm7m0jJAbMQi')
252 self.assertEqual(result['title'], 'Driving')
253 self.assertEqual(len(result['entries']), 24)
255 def test_rutube_channel(self):
257 ie = RutubeChannelIE(dl)
258 result = ie.extract('http://rutube.ru/tags/video/1409')
259 self.assertIsPlaylist(result)
260 self.assertEqual(result['id'], '1409')
261 self.assertTrue(len(result['entries']) >= 34)
263 def test_multiple_brightcove_videos(self):
264 # https://github.com/rg3/youtube-dl/issues/2283
267 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
268 self.assertIsPlaylist(result)
269 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
270 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
271 self.assertEqual(len(result['entries']), 3)
273 def test_GoogleSearch(self):
275 ie = GoogleSearchIE(dl)
276 result = ie.extract('gvsearch15:python language')
277 self.assertIsPlaylist(result)
278 self.assertEqual(result['id'], 'python language')
279 self.assertEqual(result['title'], 'python language')
280 self.assertEqual(len(result['entries']), 15)
282 def test_generic_rss_feed(self):
285 result = ie.extract('http://phihag.de/2014/youtube-dl/rss.xml')
286 self.assertIsPlaylist(result)
287 self.assertEqual(result['id'], 'http://phihag.de/2014/youtube-dl/rss.xml')
288 self.assertEqual(result['title'], 'Zero Punctuation')
289 self.assertTrue(len(result['entries']) > 10)
291 def test_ted_playlist(self):
294 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
295 self.assertIsPlaylist(result)
296 self.assertEqual(result['id'], '10')
297 self.assertEqual(result['title'], 'Who are the hackers?')
298 self.assertTrue(len(result['entries']) >= 6)
300 def test_toypics_user(self):
302 ie = ToypicsUserIE(dl)
303 result = ie.extract('http://videos.toypics.net/Mikey')
304 self.assertIsPlaylist(result)
305 self.assertEqual(result['id'], 'Mikey')
306 self.assertTrue(len(result['entries']) >= 17)
308 def test_xtube_user(self):
311 result = ie.extract('http://www.xtube.com/community/profile.php?user=greenshowers')
312 self.assertIsPlaylist(result)
313 self.assertEqual(result['id'], 'greenshowers')
314 self.assertTrue(len(result['entries']) >= 155)
316 def test_InstagramUser(self):
318 ie = InstagramUserIE(dl)
319 result = ie.extract('http://instagram.com/porsche')
320 self.assertIsPlaylist(result)
321 self.assertEqual(result['id'], 'porsche')
322 self.assertTrue(len(result['entries']) >= 2)
324 e for e in result['entries']
325 if e['id'] == '614605558512799803_462752227')
326 dl.add_default_extra_info(test_video, ie, '(irrelevant URL)')
327 dl.process_video_result(test_video, download=False)
329 'id': '614605558512799803_462752227',
331 'title': '#Porsche Intelligent Performance.',
332 'thumbnail': 're:^https?://.*\.jpg',
333 'uploader': 'Porsche',
334 'uploader_id': 'porsche',
335 'timestamp': 1387486713,
336 'upload_date': '20131219',
338 expect_info_dict(self, EXPECTED, test_video)
340 def test_CSpan_playlist(self):
344 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall')
345 self.assertIsPlaylist(result)
346 self.assertEqual(result['id'], '342759')
348 result['title'], 'General Motors Ignition Switch Recall')
349 whole_duration = sum(e['duration'] for e in result['entries'])
350 self.assertEqual(whole_duration, 14855)
352 def test_aol_playlist(self):
356 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316')
357 self.assertIsPlaylist(result)
358 self.assertEqual(result['id'], '152147')
360 result['title'], 'Brace Yourself - Today\'s Weirdest News')
361 self.assertTrue(len(result['entries']) >= 10)
363 if __name__ == '__main__':