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,
43 class TestPlaylists(unittest.TestCase):
44 def assertIsPlaylist(self, info):
45 """Make sure the info has '_type' set to 'playlist'"""
46 self.assertEqual(info['_type'], 'playlist')
48 def test_dailymotion_playlist(self):
50 ie = DailymotionPlaylistIE(dl)
51 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
52 self.assertIsPlaylist(result)
53 self.assertEqual(result['title'], 'SPORT')
54 self.assertTrue(len(result['entries']) > 20)
56 def test_dailymotion_user(self):
58 ie = DailymotionUserIE(dl)
59 result = ie.extract('https://www.dailymotion.com/user/nqtv')
60 self.assertIsPlaylist(result)
61 self.assertEqual(result['title'], 'Rémi Gaillard')
62 self.assertTrue(len(result['entries']) >= 100)
64 def test_vimeo_channel(self):
66 ie = VimeoChannelIE(dl)
67 result = ie.extract('http://vimeo.com/channels/tributes')
68 self.assertIsPlaylist(result)
69 self.assertEqual(result['title'], 'Vimeo Tributes')
70 self.assertTrue(len(result['entries']) > 24)
72 def test_vimeo_user(self):
75 result = ie.extract('http://vimeo.com/nkistudio/videos')
76 self.assertIsPlaylist(result)
77 self.assertEqual(result['title'], 'Nki')
78 self.assertTrue(len(result['entries']) > 65)
80 def test_vimeo_album(self):
83 result = ie.extract('http://vimeo.com/album/2632481')
84 self.assertIsPlaylist(result)
85 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
86 self.assertTrue(len(result['entries']) > 12)
88 def test_vimeo_groups(self):
90 ie = VimeoGroupsIE(dl)
91 result = ie.extract('http://vimeo.com/groups/rolexawards')
92 self.assertIsPlaylist(result)
93 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
94 self.assertTrue(len(result['entries']) > 72)
96 def test_ustream_channel(self):
98 ie = UstreamChannelIE(dl)
99 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
100 self.assertIsPlaylist(result)
101 self.assertEqual(result['id'], '5124905')
102 self.assertTrue(len(result['entries']) >= 6)
104 def test_soundcloud_set(self):
106 ie = SoundcloudSetIE(dl)
107 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
108 self.assertIsPlaylist(result)
109 self.assertEqual(result['title'], 'The Royal Concept EP')
110 self.assertTrue(len(result['entries']) >= 6)
112 def test_soundcloud_user(self):
114 ie = SoundcloudUserIE(dl)
115 result = ie.extract('https://soundcloud.com/the-concept-band')
116 self.assertIsPlaylist(result)
117 self.assertEqual(result['id'], '9615865')
118 self.assertTrue(len(result['entries']) >= 12)
120 def test_livestream_event(self):
122 ie = LivestreamIE(dl)
123 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
124 self.assertIsPlaylist(result)
125 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
126 self.assertTrue(len(result['entries']) >= 4)
128 def test_nhl_videocenter(self):
130 ie = NHLVideocenterIE(dl)
131 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
132 self.assertIsPlaylist(result)
133 self.assertEqual(result['id'], '999')
134 self.assertEqual(result['title'], 'Highlights')
135 self.assertEqual(len(result['entries']), 12)
137 def test_bambuser_channel(self):
139 ie = BambuserChannelIE(dl)
140 result = ie.extract('http://bambuser.com/channel/pixelversity')
141 self.assertIsPlaylist(result)
142 self.assertEqual(result['title'], 'pixelversity')
143 self.assertTrue(len(result['entries']) >= 60)
145 def test_bandcamp_album(self):
147 ie = BandcampAlbumIE(dl)
148 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
149 self.assertIsPlaylist(result)
150 self.assertEqual(result['title'], 'Nightmare Night EP')
151 self.assertTrue(len(result['entries']) >= 4)
153 def test_smotri_community(self):
155 ie = SmotriCommunityIE(dl)
156 result = ie.extract('http://smotri.com/community/video/kommuna')
157 self.assertIsPlaylist(result)
158 self.assertEqual(result['id'], 'kommuna')
159 self.assertEqual(result['title'], 'КПРФ')
160 self.assertTrue(len(result['entries']) >= 4)
162 def test_smotri_user(self):
164 ie = SmotriUserIE(dl)
165 result = ie.extract('http://smotri.com/user/inspector')
166 self.assertIsPlaylist(result)
167 self.assertEqual(result['id'], 'inspector')
168 self.assertEqual(result['title'], 'Inspector')
169 self.assertTrue(len(result['entries']) >= 9)
171 def test_AcademicEarthCourse(self):
173 ie = AcademicEarthCourseIE(dl)
174 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
175 self.assertIsPlaylist(result)
176 self.assertEqual(result['id'], 'laws-of-nature')
177 self.assertEqual(result['title'], 'Laws of Nature')
178 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.")
179 self.assertEqual(len(result['entries']), 4)
181 def test_ivi_compilation(self):
183 ie = IviCompilationIE(dl)
184 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
185 self.assertIsPlaylist(result)
186 self.assertEqual(result['id'], 'dezhurnyi_angel')
187 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
188 self.assertTrue(len(result['entries']) >= 36)
190 def test_ivi_compilation_season(self):
192 ie = IviCompilationIE(dl)
193 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
194 self.assertIsPlaylist(result)
195 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
196 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
197 self.assertTrue(len(result['entries']) >= 20)
199 def test_imdb_list(self):
202 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
203 self.assertIsPlaylist(result)
204 self.assertEqual(result['id'], 'JFs9NWw6XI0')
205 self.assertEqual(result['title'], 'March 23, 2012 Releases')
206 self.assertEqual(len(result['entries']), 7)
208 def test_khanacademy_topic(self):
210 ie = KhanAcademyIE(dl)
211 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
212 self.assertIsPlaylist(result)
213 self.assertEqual(result['id'], 'cryptography')
214 self.assertEqual(result['title'], 'Journey into cryptography')
215 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
216 self.assertTrue(len(result['entries']) >= 3)
218 def test_EveryonesMixtape(self):
220 ie = EveryonesMixtapeIE(dl)
221 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
222 self.assertIsPlaylist(result)
223 self.assertEqual(result['id'], 'm7m0jJAbMQi')
224 self.assertEqual(result['title'], 'Driving')
225 self.assertEqual(len(result['entries']), 24)
227 def test_rutube_channel(self):
229 ie = RutubeChannelIE(dl)
230 result = ie.extract('http://rutube.ru/tags/video/1409')
231 self.assertIsPlaylist(result)
232 self.assertEqual(result['id'], '1409')
233 self.assertTrue(len(result['entries']) >= 34)
235 def test_multiple_brightcove_videos(self):
236 # https://github.com/rg3/youtube-dl/issues/2283
239 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
240 self.assertIsPlaylist(result)
241 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
242 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
243 self.assertEqual(len(result['entries']), 3)
245 def test_GoogleSearch(self):
247 ie = GoogleSearchIE(dl)
248 result = ie.extract('gvsearch15:python language')
249 self.assertIsPlaylist(result)
250 self.assertEqual(result['id'], 'python language')
251 self.assertEqual(result['title'], 'python language')
252 self.assertEqual(len(result['entries']), 15)
254 def test_generic_rss_feed(self):
257 result = ie.extract('http://phihag.de/2014/youtube-dl/rss.xml')
258 self.assertIsPlaylist(result)
259 self.assertEqual(result['id'], 'http://phihag.de/2014/youtube-dl/rss.xml')
260 self.assertEqual(result['title'], 'Zero Punctuation')
261 self.assertTrue(len(result['entries']) > 10)
263 def test_ted_playlist(self):
266 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
267 self.assertIsPlaylist(result)
268 self.assertEqual(result['id'], '10')
269 self.assertEqual(result['title'], 'Who are the hackers?')
270 self.assertTrue(len(result['entries']) >= 6)
272 if __name__ == '__main__':