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 FakeYDL
15 from youtube_dl.extractor import (
16 AcademicEarthCourseIE,
17 DailymotionPlaylistIE,
44 class TestPlaylists(unittest.TestCase):
45 def assertIsPlaylist(self, info):
46 """Make sure the info has '_type' set to 'playlist'"""
47 self.assertEqual(info['_type'], 'playlist')
49 def test_dailymotion_playlist(self):
51 ie = DailymotionPlaylistIE(dl)
52 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
53 self.assertIsPlaylist(result)
54 self.assertEqual(result['title'], 'SPORT')
55 self.assertTrue(len(result['entries']) > 20)
57 def test_dailymotion_user(self):
59 ie = DailymotionUserIE(dl)
60 result = ie.extract('https://www.dailymotion.com/user/nqtv')
61 self.assertIsPlaylist(result)
62 self.assertEqual(result['title'], 'Rémi Gaillard')
63 self.assertTrue(len(result['entries']) >= 100)
65 def test_vimeo_channel(self):
67 ie = VimeoChannelIE(dl)
68 result = ie.extract('http://vimeo.com/channels/tributes')
69 self.assertIsPlaylist(result)
70 self.assertEqual(result['title'], 'Vimeo Tributes')
71 self.assertTrue(len(result['entries']) > 24)
73 def test_vimeo_user(self):
76 result = ie.extract('http://vimeo.com/nkistudio/videos')
77 self.assertIsPlaylist(result)
78 self.assertEqual(result['title'], 'Nki')
79 self.assertTrue(len(result['entries']) > 65)
81 def test_vimeo_album(self):
84 result = ie.extract('http://vimeo.com/album/2632481')
85 self.assertIsPlaylist(result)
86 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
87 self.assertTrue(len(result['entries']) > 12)
89 def test_vimeo_groups(self):
91 ie = VimeoGroupsIE(dl)
92 result = ie.extract('http://vimeo.com/groups/rolexawards')
93 self.assertIsPlaylist(result)
94 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
95 self.assertTrue(len(result['entries']) > 72)
97 def test_ustream_channel(self):
99 ie = UstreamChannelIE(dl)
100 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
101 self.assertIsPlaylist(result)
102 self.assertEqual(result['id'], '5124905')
103 self.assertTrue(len(result['entries']) >= 6)
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 self.assertTrue(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 self.assertTrue(len(result['entries']) >= 12)
121 def test_livestream_event(self):
123 ie = LivestreamIE(dl)
124 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
125 self.assertIsPlaylist(result)
126 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
127 self.assertTrue(len(result['entries']) >= 4)
129 def test_nhl_videocenter(self):
131 ie = NHLVideocenterIE(dl)
132 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
133 self.assertIsPlaylist(result)
134 self.assertEqual(result['id'], '999')
135 self.assertEqual(result['title'], 'Highlights')
136 self.assertEqual(len(result['entries']), 12)
138 def test_bambuser_channel(self):
140 ie = BambuserChannelIE(dl)
141 result = ie.extract('http://bambuser.com/channel/pixelversity')
142 self.assertIsPlaylist(result)
143 self.assertEqual(result['title'], 'pixelversity')
144 self.assertTrue(len(result['entries']) >= 60)
146 def test_bandcamp_album(self):
148 ie = BandcampAlbumIE(dl)
149 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
150 self.assertIsPlaylist(result)
151 self.assertEqual(result['title'], 'Nightmare Night EP')
152 self.assertTrue(len(result['entries']) >= 4)
154 def test_smotri_community(self):
156 ie = SmotriCommunityIE(dl)
157 result = ie.extract('http://smotri.com/community/video/kommuna')
158 self.assertIsPlaylist(result)
159 self.assertEqual(result['id'], 'kommuna')
160 self.assertEqual(result['title'], 'КПРФ')
161 self.assertTrue(len(result['entries']) >= 4)
163 def test_smotri_user(self):
165 ie = SmotriUserIE(dl)
166 result = ie.extract('http://smotri.com/user/inspector')
167 self.assertIsPlaylist(result)
168 self.assertEqual(result['id'], 'inspector')
169 self.assertEqual(result['title'], 'Inspector')
170 self.assertTrue(len(result['entries']) >= 9)
172 def test_AcademicEarthCourse(self):
174 ie = AcademicEarthCourseIE(dl)
175 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
176 self.assertIsPlaylist(result)
177 self.assertEqual(result['id'], 'laws-of-nature')
178 self.assertEqual(result['title'], 'Laws of Nature')
179 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.")
180 self.assertEqual(len(result['entries']), 4)
182 def test_ivi_compilation(self):
184 ie = IviCompilationIE(dl)
185 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
186 self.assertIsPlaylist(result)
187 self.assertEqual(result['id'], 'dezhurnyi_angel')
188 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
189 self.assertTrue(len(result['entries']) >= 36)
191 def test_ivi_compilation_season(self):
193 ie = IviCompilationIE(dl)
194 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
195 self.assertIsPlaylist(result)
196 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
197 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
198 self.assertTrue(len(result['entries']) >= 20)
200 def test_imdb_list(self):
203 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
204 self.assertIsPlaylist(result)
205 self.assertEqual(result['id'], 'JFs9NWw6XI0')
206 self.assertEqual(result['title'], 'March 23, 2012 Releases')
207 self.assertEqual(len(result['entries']), 7)
209 def test_khanacademy_topic(self):
211 ie = KhanAcademyIE(dl)
212 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
213 self.assertIsPlaylist(result)
214 self.assertEqual(result['id'], 'cryptography')
215 self.assertEqual(result['title'], 'Journey into cryptography')
216 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
217 self.assertTrue(len(result['entries']) >= 3)
219 def test_EveryonesMixtape(self):
221 ie = EveryonesMixtapeIE(dl)
222 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
223 self.assertIsPlaylist(result)
224 self.assertEqual(result['id'], 'm7m0jJAbMQi')
225 self.assertEqual(result['title'], 'Driving')
226 self.assertEqual(len(result['entries']), 24)
228 def test_rutube_channel(self):
230 ie = RutubeChannelIE(dl)
231 result = ie.extract('http://rutube.ru/tags/video/1409')
232 self.assertIsPlaylist(result)
233 self.assertEqual(result['id'], '1409')
234 self.assertTrue(len(result['entries']) >= 34)
236 def test_multiple_brightcove_videos(self):
237 # https://github.com/rg3/youtube-dl/issues/2283
240 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
241 self.assertIsPlaylist(result)
242 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
243 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
244 self.assertEqual(len(result['entries']), 3)
246 def test_GoogleSearch(self):
248 ie = GoogleSearchIE(dl)
249 result = ie.extract('gvsearch15:python language')
250 self.assertIsPlaylist(result)
251 self.assertEqual(result['id'], 'python language')
252 self.assertEqual(result['title'], 'python language')
253 self.assertEqual(len(result['entries']), 15)
255 def test_generic_rss_feed(self):
258 result = ie.extract('http://phihag.de/2014/youtube-dl/rss.xml')
259 self.assertIsPlaylist(result)
260 self.assertEqual(result['id'], 'http://phihag.de/2014/youtube-dl/rss.xml')
261 self.assertEqual(result['title'], 'Zero Punctuation')
262 self.assertTrue(len(result['entries']) > 10)
264 def test_ted_playlist(self):
267 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
268 self.assertIsPlaylist(result)
269 self.assertEqual(result['id'], '10')
270 self.assertEqual(result['title'], 'Who are the hackers?')
271 self.assertTrue(len(result['entries']) >= 6)
273 def test_toypics_user(self):
275 ie = ToypicsUserIE(dl)
276 result = ie.extract('http://videos.toypics.net/Mikey')
277 self.assertIsPlaylist(result)
278 self.assertEqual(result['id'], 'Mikey')
279 self.assertTrue(len(result['entries']) >= 17)
281 if __name__ == '__main__':