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