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