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 (
17 from youtube_dl.extractor import (
18 AcademicEarthCourseIE,
19 DailymotionPlaylistIE,
50 class TestPlaylists(unittest.TestCase):
51 def assertIsPlaylist(self, info):
52 """Make sure the info has '_type' set to 'playlist'"""
53 self.assertEqual(info['_type'], 'playlist')
55 def test_dailymotion_playlist(self):
57 ie = DailymotionPlaylistIE(dl)
58 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
59 self.assertIsPlaylist(result)
60 self.assertEqual(result['title'], 'SPORT')
61 self.assertTrue(len(result['entries']) > 20)
63 def test_dailymotion_user(self):
65 ie = DailymotionUserIE(dl)
66 result = ie.extract('https://www.dailymotion.com/user/nqtv')
67 self.assertIsPlaylist(result)
68 self.assertEqual(result['title'], 'Rémi Gaillard')
69 self.assertTrue(len(result['entries']) >= 100)
71 def test_vimeo_channel(self):
73 ie = VimeoChannelIE(dl)
74 result = ie.extract('http://vimeo.com/channels/tributes')
75 self.assertIsPlaylist(result)
76 self.assertEqual(result['title'], 'Vimeo Tributes')
77 self.assertTrue(len(result['entries']) > 24)
79 def test_vimeo_user(self):
82 result = ie.extract('http://vimeo.com/nkistudio/videos')
83 self.assertIsPlaylist(result)
84 self.assertEqual(result['title'], 'Nki')
85 self.assertTrue(len(result['entries']) > 65)
87 def test_vimeo_album(self):
90 result = ie.extract('http://vimeo.com/album/2632481')
91 self.assertIsPlaylist(result)
92 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
93 self.assertTrue(len(result['entries']) > 12)
95 def test_vimeo_groups(self):
97 ie = VimeoGroupsIE(dl)
98 result = ie.extract('http://vimeo.com/groups/rolexawards')
99 self.assertIsPlaylist(result)
100 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
101 self.assertTrue(len(result['entries']) > 72)
103 def test_ustream_channel(self):
105 ie = UstreamChannelIE(dl)
106 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
107 self.assertIsPlaylist(result)
108 self.assertEqual(result['id'], '5124905')
109 self.assertTrue(len(result['entries']) >= 6)
111 def test_soundcloud_set(self):
113 ie = SoundcloudSetIE(dl)
114 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
115 self.assertIsPlaylist(result)
116 self.assertEqual(result['title'], 'The Royal Concept EP')
117 self.assertTrue(len(result['entries']) >= 6)
119 def test_soundcloud_user(self):
121 ie = SoundcloudUserIE(dl)
122 result = ie.extract('https://soundcloud.com/the-concept-band')
123 self.assertIsPlaylist(result)
124 self.assertEqual(result['id'], '9615865')
125 self.assertTrue(len(result['entries']) >= 12)
127 def test_livestream_event(self):
129 ie = LivestreamIE(dl)
130 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
131 self.assertIsPlaylist(result)
132 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
133 self.assertTrue(len(result['entries']) >= 4)
135 def test_nhl_videocenter(self):
137 ie = NHLVideocenterIE(dl)
138 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
139 self.assertIsPlaylist(result)
140 self.assertEqual(result['id'], '999')
141 self.assertEqual(result['title'], 'Highlights')
142 self.assertEqual(len(result['entries']), 12)
144 def test_bambuser_channel(self):
146 ie = BambuserChannelIE(dl)
147 result = ie.extract('http://bambuser.com/channel/pixelversity')
148 self.assertIsPlaylist(result)
149 self.assertEqual(result['title'], 'pixelversity')
150 self.assertTrue(len(result['entries']) >= 60)
152 def test_bandcamp_album(self):
154 ie = BandcampAlbumIE(dl)
155 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
156 self.assertIsPlaylist(result)
157 self.assertEqual(result['title'], 'Nightmare Night EP')
158 self.assertTrue(len(result['entries']) >= 4)
160 def test_smotri_community(self):
162 ie = SmotriCommunityIE(dl)
163 result = ie.extract('http://smotri.com/community/video/kommuna')
164 self.assertIsPlaylist(result)
165 self.assertEqual(result['id'], 'kommuna')
166 self.assertEqual(result['title'], 'КПРФ')
167 self.assertTrue(len(result['entries']) >= 4)
169 def test_smotri_user(self):
171 ie = SmotriUserIE(dl)
172 result = ie.extract('http://smotri.com/user/inspector')
173 self.assertIsPlaylist(result)
174 self.assertEqual(result['id'], 'inspector')
175 self.assertEqual(result['title'], 'Inspector')
176 self.assertTrue(len(result['entries']) >= 9)
178 def test_AcademicEarthCourse(self):
180 ie = AcademicEarthCourseIE(dl)
181 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
182 self.assertIsPlaylist(result)
183 self.assertEqual(result['id'], 'laws-of-nature')
184 self.assertEqual(result['title'], 'Laws of Nature')
185 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.")
186 self.assertEqual(len(result['entries']), 4)
188 def test_ivi_compilation(self):
190 ie = IviCompilationIE(dl)
191 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
192 self.assertIsPlaylist(result)
193 self.assertEqual(result['id'], 'dezhurnyi_angel')
194 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
195 self.assertTrue(len(result['entries']) >= 36)
197 def test_ivi_compilation_season(self):
199 ie = IviCompilationIE(dl)
200 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
201 self.assertIsPlaylist(result)
202 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
203 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
204 self.assertTrue(len(result['entries']) >= 20)
206 def test_imdb_list(self):
209 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
210 self.assertIsPlaylist(result)
211 self.assertEqual(result['id'], 'JFs9NWw6XI0')
212 self.assertEqual(result['title'], 'March 23, 2012 Releases')
213 self.assertEqual(len(result['entries']), 7)
215 def test_khanacademy_topic(self):
217 ie = KhanAcademyIE(dl)
218 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
219 self.assertIsPlaylist(result)
220 self.assertEqual(result['id'], 'cryptography')
221 self.assertEqual(result['title'], 'Journey into cryptography')
222 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
223 self.assertTrue(len(result['entries']) >= 3)
225 def test_EveryonesMixtape(self):
227 ie = EveryonesMixtapeIE(dl)
228 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
229 self.assertIsPlaylist(result)
230 self.assertEqual(result['id'], 'm7m0jJAbMQi')
231 self.assertEqual(result['title'], 'Driving')
232 self.assertEqual(len(result['entries']), 24)
234 def test_rutube_channel(self):
236 ie = RutubeChannelIE(dl)
237 result = ie.extract('http://rutube.ru/tags/video/1409')
238 self.assertIsPlaylist(result)
239 self.assertEqual(result['id'], '1409')
240 self.assertTrue(len(result['entries']) >= 34)
242 def test_multiple_brightcove_videos(self):
243 # https://github.com/rg3/youtube-dl/issues/2283
246 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
247 self.assertIsPlaylist(result)
248 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
249 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
250 self.assertEqual(len(result['entries']), 3)
252 def test_GoogleSearch(self):
254 ie = GoogleSearchIE(dl)
255 result = ie.extract('gvsearch15:python language')
256 self.assertIsPlaylist(result)
257 self.assertEqual(result['id'], 'python language')
258 self.assertEqual(result['title'], 'python language')
259 self.assertEqual(len(result['entries']), 15)
261 def test_generic_rss_feed(self):
264 result = ie.extract('http://phihag.de/2014/youtube-dl/rss.xml')
265 self.assertIsPlaylist(result)
266 self.assertEqual(result['id'], 'http://phihag.de/2014/youtube-dl/rss.xml')
267 self.assertEqual(result['title'], 'Zero Punctuation')
268 self.assertTrue(len(result['entries']) > 10)
270 def test_ted_playlist(self):
273 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
274 self.assertIsPlaylist(result)
275 self.assertEqual(result['id'], '10')
276 self.assertEqual(result['title'], 'Who are the hackers?')
277 self.assertTrue(len(result['entries']) >= 6)
279 def test_toypics_user(self):
281 ie = ToypicsUserIE(dl)
282 result = ie.extract('http://videos.toypics.net/Mikey')
283 self.assertIsPlaylist(result)
284 self.assertEqual(result['id'], 'Mikey')
285 self.assertTrue(len(result['entries']) >= 17)
287 def test_xtube_user(self):
290 result = ie.extract('http://www.xtube.com/community/profile.php?user=greenshowers')
291 self.assertIsPlaylist(result)
292 self.assertEqual(result['id'], 'greenshowers')
293 self.assertTrue(len(result['entries']) >= 155)
295 def test_InstagramUser(self):
297 ie = InstagramUserIE(dl)
298 result = ie.extract('http://instagram.com/porsche')
299 self.assertIsPlaylist(result)
300 self.assertEqual(result['id'], 'porsche')
301 self.assertTrue(len(result['entries']) >= 2)
303 e for e in result['entries']
304 if e['id'] == '614605558512799803_462752227')
305 dl.add_default_extra_info(test_video, ie, '(irrelevant URL)')
306 dl.process_video_result(test_video, download=False)
308 'id': '614605558512799803_462752227',
310 'title': '#Porsche Intelligent Performance.',
311 'thumbnail': 're:^https?://.*\.jpg',
312 'uploader': 'Porsche',
313 'uploader_id': 'porsche',
314 'timestamp': 1387486713,
315 'upload_date': '20131219',
317 expect_info_dict(self, EXPECTED, test_video)
319 def test_CSpan_playlist(self):
323 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall')
324 self.assertIsPlaylist(result)
325 self.assertEqual(result['id'], '342759')
327 result['title'], 'General Motors Ignition Switch Recall')
328 whole_duration = sum(e['duration'] for e in result['entries'])
329 self.assertEqual(whole_duration, 14855)
331 def test_aol_playlist(self):
335 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316')
336 self.assertIsPlaylist(result)
337 self.assertEqual(result['id'], '152147')
339 result['title'], 'Brace Yourself - Today\'s Weirdest News')
340 self.assertTrue(len(result['entries']) >= 10)
342 if __name__ == '__main__':