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_vine_user(self):
93 result = ie.extract('https://vine.co/Visa')
94 self.assertIsPlaylist(result)
95 assertGreaterEqual(self, len(result['entries']), 47)
97 def test_ustream_channel(self):
99 ie = UstreamChannelIE(dl)
100 result = ie.extract('http://www.ustream.tv/channel/channeljapan')
101 self.assertIsPlaylist(result)
102 self.assertEqual(result['id'], '10874166')
103 assertGreaterEqual(self, len(result['entries']), 54)
105 def test_soundcloud_set(self):
107 ie = SoundcloudSetIE(dl)
108 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
109 self.assertIsPlaylist(result)
110 self.assertEqual(result['title'], 'The Royal Concept EP')
111 assertGreaterEqual(self, len(result['entries']), 6)
113 def test_soundcloud_user(self):
115 ie = SoundcloudUserIE(dl)
116 result = ie.extract('https://soundcloud.com/the-concept-band')
117 self.assertIsPlaylist(result)
118 self.assertEqual(result['id'], '9615865')
119 assertGreaterEqual(self, len(result['entries']), 12)
121 def test_soundcloud_likes(self):
123 ie = SoundcloudUserIE(dl)
124 result = ie.extract('https://soundcloud.com/the-concept-band/likes')
125 self.assertIsPlaylist(result)
126 self.assertEqual(result['id'], '9615865')
127 assertGreaterEqual(self, len(result['entries']), 1)
129 def test_soundcloud_playlist(self):
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]')
137 self, result['description'], r'.*?TILT Brass - Bowery Poetry Club')
138 self.assertEqual(len(result['entries']), 6)
140 def test_livestream_event(self):
142 ie = LivestreamIE(dl)
143 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
144 self.assertIsPlaylist(result)
145 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
146 assertGreaterEqual(self, len(result['entries']), 4)
148 def test_livestreamoriginal_folder(self):
150 ie = LivestreamOriginalIE(dl)
151 result = ie.extract('https://www.livestream.com/newplay/folder?dirId=a07bf706-d0e4-4e75-a747-b021d84f2fd3')
152 self.assertIsPlaylist(result)
153 self.assertEqual(result['id'], 'a07bf706-d0e4-4e75-a747-b021d84f2fd3')
154 assertGreaterEqual(self, len(result['entries']), 28)
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 assertGreaterEqual(self, len(result['entries']), 60)
173 def test_bandcamp_album(self):
175 ie = BandcampAlbumIE(dl)
176 result = ie.extract('http://nightbringer.bandcamp.com/album/hierophany-of-the-open-grave')
177 self.assertIsPlaylist(result)
178 self.assertEqual(result['title'], 'Hierophany of the Open Grave')
179 assertGreaterEqual(self, len(result['entries']), 9)
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 assertGreaterEqual(self, 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 assertGreaterEqual(self, 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/dvoe_iz_lartsa')
213 self.assertIsPlaylist(result)
214 self.assertEqual(result['id'], 'dvoe_iz_lartsa')
215 self.assertEqual(result['title'], 'Двое из ларца (2006 - 2008)')
216 assertGreaterEqual(self, len(result['entries']), 24)
218 def test_ivi_compilation_season(self):
220 ie = IviCompilationIE(dl)
221 result = ie.extract('http://www.ivi.ru/watch/dvoe_iz_lartsa/season1')
222 self.assertIsPlaylist(result)
223 self.assertEqual(result['id'], 'dvoe_iz_lartsa/season1')
224 self.assertEqual(result['title'], 'Двое из ларца (2006 - 2008) 1 сезон')
225 assertGreaterEqual(self, len(result['entries']), 12)
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 assertGreaterEqual(self, 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/1800/')
259 self.assertIsPlaylist(result)
260 self.assertEqual(result['id'], '1800')
261 assertGreaterEqual(self, len(result['entries']), 68)
263 def test_rutube_person(self):
265 ie = RutubePersonIE(dl)
266 result = ie.extract('http://rutube.ru/video/person/313878/')
267 self.assertIsPlaylist(result)
268 self.assertEqual(result['id'], '313878')
269 assertGreaterEqual(self, len(result['entries']), 37)
271 def test_multiple_brightcove_videos(self):
272 # https://github.com/rg3/youtube-dl/issues/2283
275 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
276 self.assertIsPlaylist(result)
277 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
278 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
279 self.assertEqual(len(result['entries']), 3)
281 def test_ted_playlist(self):
284 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
285 self.assertIsPlaylist(result)
286 self.assertEqual(result['id'], '10')
287 self.assertEqual(result['title'], 'Who are the hackers?')
288 assertGreaterEqual(self, len(result['entries']), 6)
290 def test_toypics_user(self):
292 ie = ToypicsUserIE(dl)
293 result = ie.extract('http://videos.toypics.net/Mikey')
294 self.assertIsPlaylist(result)
295 self.assertEqual(result['id'], 'Mikey')
296 assertGreaterEqual(self, len(result['entries']), 17)
298 def test_xtube_user(self):
301 result = ie.extract('http://www.xtube.com/community/profile.php?user=greenshowers')
302 self.assertIsPlaylist(result)
303 self.assertEqual(result['id'], 'greenshowers')
304 assertGreaterEqual(self, len(result['entries']), 155)
306 def test_InstagramUser(self):
308 ie = InstagramUserIE(dl)
309 result = ie.extract('http://instagram.com/porsche')
310 self.assertIsPlaylist(result)
311 self.assertEqual(result['id'], 'porsche')
312 assertGreaterEqual(self, len(result['entries']), 2)
314 e for e in result['entries']
315 if e['id'] == '614605558512799803_462752227')
316 dl.add_default_extra_info(test_video, ie, '(irrelevant URL)')
317 dl.process_video_result(test_video, download=False)
319 'id': '614605558512799803_462752227',
321 'title': '#Porsche Intelligent Performance.',
322 'thumbnail': 're:^https?://.*\.jpg',
323 'uploader': 'Porsche',
324 'uploader_id': 'porsche',
325 'timestamp': 1387486713,
326 'upload_date': '20131219',
328 expect_info_dict(self, EXPECTED, test_video)
330 def test_CSpan_playlist(self):
334 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall')
335 self.assertIsPlaylist(result)
336 self.assertEqual(result['id'], '342759')
338 result['title'], 'General Motors Ignition Switch Recall')
339 whole_duration = sum(e['duration'] for e in result['entries'])
340 self.assertEqual(whole_duration, 14855)
342 def test_aol_playlist(self):
346 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316')
347 self.assertIsPlaylist(result)
348 self.assertEqual(result['id'], '152147')
350 result['title'], 'Brace Yourself - Today\'s Weirdest News')
351 assertGreaterEqual(self, len(result['entries']), 10)
353 def test_TeacherTubeUser(self):
355 ie = TeacherTubeUserIE(dl)
356 result = ie.extract('http://www.teachertube.com/user/profile/rbhagwati2')
357 self.assertIsPlaylist(result)
358 self.assertEqual(result['id'], 'rbhagwati2')
359 assertGreaterEqual(self, len(result['entries']), 179)
362 if __name__ == '__main__':