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,
49 class TestPlaylists(unittest.TestCase):
50 def assertIsPlaylist(self, info):
51 """Make sure the info has '_type' set to 'playlist'"""
52 self.assertEqual(info['_type'], 'playlist')
54 def test_dailymotion_playlist(self):
56 ie = DailymotionPlaylistIE(dl)
57 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
58 self.assertIsPlaylist(result)
59 self.assertEqual(result['title'], 'SPORT')
60 self.assertTrue(len(result['entries']) > 20)
62 def test_dailymotion_user(self):
64 ie = DailymotionUserIE(dl)
65 result = ie.extract('https://www.dailymotion.com/user/nqtv')
66 self.assertIsPlaylist(result)
67 self.assertEqual(result['title'], 'Rémi Gaillard')
68 self.assertTrue(len(result['entries']) >= 100)
70 def test_vimeo_channel(self):
72 ie = VimeoChannelIE(dl)
73 result = ie.extract('http://vimeo.com/channels/tributes')
74 self.assertIsPlaylist(result)
75 self.assertEqual(result['title'], 'Vimeo Tributes')
76 self.assertTrue(len(result['entries']) > 24)
78 def test_vimeo_user(self):
81 result = ie.extract('http://vimeo.com/nkistudio/videos')
82 self.assertIsPlaylist(result)
83 self.assertEqual(result['title'], 'Nki')
84 self.assertTrue(len(result['entries']) > 65)
86 def test_vimeo_album(self):
89 result = ie.extract('http://vimeo.com/album/2632481')
90 self.assertIsPlaylist(result)
91 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
92 self.assertTrue(len(result['entries']) > 12)
94 def test_vimeo_groups(self):
96 ie = VimeoGroupsIE(dl)
97 result = ie.extract('http://vimeo.com/groups/rolexawards')
98 self.assertIsPlaylist(result)
99 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
100 self.assertTrue(len(result['entries']) > 72)
102 def test_ustream_channel(self):
104 ie = UstreamChannelIE(dl)
105 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
106 self.assertIsPlaylist(result)
107 self.assertEqual(result['id'], '5124905')
108 self.assertTrue(len(result['entries']) >= 6)
110 def test_soundcloud_set(self):
112 ie = SoundcloudSetIE(dl)
113 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
114 self.assertIsPlaylist(result)
115 self.assertEqual(result['title'], 'The Royal Concept EP')
116 self.assertTrue(len(result['entries']) >= 6)
118 def test_soundcloud_user(self):
120 ie = SoundcloudUserIE(dl)
121 result = ie.extract('https://soundcloud.com/the-concept-band')
122 self.assertIsPlaylist(result)
123 self.assertEqual(result['id'], '9615865')
124 self.assertTrue(len(result['entries']) >= 12)
126 def test_livestream_event(self):
128 ie = LivestreamIE(dl)
129 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
130 self.assertIsPlaylist(result)
131 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
132 self.assertTrue(len(result['entries']) >= 4)
134 def test_nhl_videocenter(self):
136 ie = NHLVideocenterIE(dl)
137 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
138 self.assertIsPlaylist(result)
139 self.assertEqual(result['id'], '999')
140 self.assertEqual(result['title'], 'Highlights')
141 self.assertEqual(len(result['entries']), 12)
143 def test_bambuser_channel(self):
145 ie = BambuserChannelIE(dl)
146 result = ie.extract('http://bambuser.com/channel/pixelversity')
147 self.assertIsPlaylist(result)
148 self.assertEqual(result['title'], 'pixelversity')
149 self.assertTrue(len(result['entries']) >= 60)
151 def test_bandcamp_album(self):
153 ie = BandcampAlbumIE(dl)
154 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
155 self.assertIsPlaylist(result)
156 self.assertEqual(result['title'], 'Nightmare Night EP')
157 self.assertTrue(len(result['entries']) >= 4)
159 def test_smotri_community(self):
161 ie = SmotriCommunityIE(dl)
162 result = ie.extract('http://smotri.com/community/video/kommuna')
163 self.assertIsPlaylist(result)
164 self.assertEqual(result['id'], 'kommuna')
165 self.assertEqual(result['title'], 'КПРФ')
166 self.assertTrue(len(result['entries']) >= 4)
168 def test_smotri_user(self):
170 ie = SmotriUserIE(dl)
171 result = ie.extract('http://smotri.com/user/inspector')
172 self.assertIsPlaylist(result)
173 self.assertEqual(result['id'], 'inspector')
174 self.assertEqual(result['title'], 'Inspector')
175 self.assertTrue(len(result['entries']) >= 9)
177 def test_AcademicEarthCourse(self):
179 ie = AcademicEarthCourseIE(dl)
180 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
181 self.assertIsPlaylist(result)
182 self.assertEqual(result['id'], 'laws-of-nature')
183 self.assertEqual(result['title'], 'Laws of Nature')
184 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.")
185 self.assertEqual(len(result['entries']), 4)
187 def test_ivi_compilation(self):
189 ie = IviCompilationIE(dl)
190 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
191 self.assertIsPlaylist(result)
192 self.assertEqual(result['id'], 'dezhurnyi_angel')
193 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
194 self.assertTrue(len(result['entries']) >= 36)
196 def test_ivi_compilation_season(self):
198 ie = IviCompilationIE(dl)
199 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
200 self.assertIsPlaylist(result)
201 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
202 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
203 self.assertTrue(len(result['entries']) >= 20)
205 def test_imdb_list(self):
208 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
209 self.assertIsPlaylist(result)
210 self.assertEqual(result['id'], 'JFs9NWw6XI0')
211 self.assertEqual(result['title'], 'March 23, 2012 Releases')
212 self.assertEqual(len(result['entries']), 7)
214 def test_khanacademy_topic(self):
216 ie = KhanAcademyIE(dl)
217 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
218 self.assertIsPlaylist(result)
219 self.assertEqual(result['id'], 'cryptography')
220 self.assertEqual(result['title'], 'Journey into cryptography')
221 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
222 self.assertTrue(len(result['entries']) >= 3)
224 def test_EveryonesMixtape(self):
226 ie = EveryonesMixtapeIE(dl)
227 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
228 self.assertIsPlaylist(result)
229 self.assertEqual(result['id'], 'm7m0jJAbMQi')
230 self.assertEqual(result['title'], 'Driving')
231 self.assertEqual(len(result['entries']), 24)
233 def test_rutube_channel(self):
235 ie = RutubeChannelIE(dl)
236 result = ie.extract('http://rutube.ru/tags/video/1409')
237 self.assertIsPlaylist(result)
238 self.assertEqual(result['id'], '1409')
239 self.assertTrue(len(result['entries']) >= 34)
241 def test_multiple_brightcove_videos(self):
242 # https://github.com/rg3/youtube-dl/issues/2283
245 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
246 self.assertIsPlaylist(result)
247 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
248 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
249 self.assertEqual(len(result['entries']), 3)
251 def test_GoogleSearch(self):
253 ie = GoogleSearchIE(dl)
254 result = ie.extract('gvsearch15:python language')
255 self.assertIsPlaylist(result)
256 self.assertEqual(result['id'], 'python language')
257 self.assertEqual(result['title'], 'python language')
258 self.assertEqual(len(result['entries']), 15)
260 def test_generic_rss_feed(self):
263 result = ie.extract('http://phihag.de/2014/youtube-dl/rss.xml')
264 self.assertIsPlaylist(result)
265 self.assertEqual(result['id'], 'http://phihag.de/2014/youtube-dl/rss.xml')
266 self.assertEqual(result['title'], 'Zero Punctuation')
267 self.assertTrue(len(result['entries']) > 10)
269 def test_ted_playlist(self):
272 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
273 self.assertIsPlaylist(result)
274 self.assertEqual(result['id'], '10')
275 self.assertEqual(result['title'], 'Who are the hackers?')
276 self.assertTrue(len(result['entries']) >= 6)
278 def test_toypics_user(self):
280 ie = ToypicsUserIE(dl)
281 result = ie.extract('http://videos.toypics.net/Mikey')
282 self.assertIsPlaylist(result)
283 self.assertEqual(result['id'], 'Mikey')
284 self.assertTrue(len(result['entries']) >= 17)
286 def test_xtube_user(self):
289 result = ie.extract('http://www.xtube.com/community/profile.php?user=greenshowers')
290 self.assertIsPlaylist(result)
291 self.assertEqual(result['id'], 'greenshowers')
292 self.assertTrue(len(result['entries']) >= 155)
294 def test_InstagramUser(self):
296 ie = InstagramUserIE(dl)
297 result = ie.extract('http://instagram.com/porsche')
298 self.assertIsPlaylist(result)
299 self.assertEqual(result['id'], 'porsche')
300 self.assertTrue(len(result['entries']) >= 2)
302 e for e in result['entries']
303 if e['id'] == '614605558512799803_462752227')
304 dl.add_default_extra_info(test_video, ie, '(irrelevant URL)')
305 dl.process_video_result(test_video, download=False)
307 'id': '614605558512799803_462752227',
309 'title': '#Porsche Intelligent Performance.',
310 'thumbnail': 're:^https?://.*\.jpg',
311 'uploader': 'Porsche',
312 'uploader_id': 'porsche',
313 'timestamp': 1387486713,
314 'upload_date': '20131219',
316 expect_info_dict(self, EXPECTED, test_video)
318 def test_CSpan_playlist(self):
322 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall')
323 self.assertIsPlaylist(result)
324 self.assertEqual(result['id'], '342759')
326 result['title'], 'General Motors Ignition Switch Recall')
327 whole_duration = sum(e['duration'] for e in result['entries'])
328 self.assertEqual(whole_duration, 14855)
331 if __name__ == '__main__':