]>
Raphaël G. Git Repositories - youtubedl/blob - test/test_playlists.py
1a38a667b1391ab744fa88e91d79e4eea742bbf6
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 (
18 from youtube_dl
. extractor
import (
19 AcademicEarthCourseIE
,
20 DailymotionPlaylistIE
,
56 class TestPlaylists ( unittest
. TestCase
):
57 def assertIsPlaylist ( self
, info
):
58 """Make sure the info has '_type' set to 'playlist'"""
59 self
. assertEqual ( info
[ '_type' ], 'playlist' )
61 def test_dailymotion_playlist ( self
):
63 ie
= DailymotionPlaylistIE ( dl
)
64 result
= ie
. extract ( 'http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q' )
65 self
. assertIsPlaylist ( result
)
66 self
. assertEqual ( result
[ 'title' ], 'SPORT' )
67 self
. assertTrue ( len ( result
[ 'entries' ]) > 20 )
69 def test_dailymotion_user ( self
):
71 ie
= DailymotionUserIE ( dl
)
72 result
= ie
. extract ( 'https://www.dailymotion.com/user/nqtv' )
73 self
. assertIsPlaylist ( result
)
74 self
. assertEqual ( result
[ 'title' ], 'Rémi Gaillard' )
75 self
. assertTrue ( len ( result
[ 'entries' ]) >= 100 )
77 def test_vimeo_channel ( self
):
79 ie
= VimeoChannelIE ( dl
)
80 result
= ie
. extract ( 'http://vimeo.com/channels/tributes' )
81 self
. assertIsPlaylist ( result
)
82 self
. assertEqual ( result
[ 'title' ], 'Vimeo Tributes' )
83 self
. assertTrue ( len ( result
[ 'entries' ]) > 24 )
85 def test_vimeo_user ( self
):
88 result
= ie
. extract ( 'http://vimeo.com/nkistudio/videos' )
89 self
. assertIsPlaylist ( result
)
90 self
. assertEqual ( result
[ 'title' ], 'Nki' )
91 self
. assertTrue ( len ( result
[ 'entries' ]) > 65 )
93 def test_vimeo_album ( self
):
96 result
= ie
. extract ( 'http://vimeo.com/album/2632481' )
97 self
. assertIsPlaylist ( result
)
98 self
. assertEqual ( result
[ 'title' ], 'Staff Favorites: November 2013' )
99 self
. assertTrue ( len ( result
[ 'entries' ]) > 12 )
101 def test_vimeo_groups ( self
):
103 ie
= VimeoGroupsIE ( dl
)
104 result
= ie
. extract ( 'http://vimeo.com/groups/rolexawards' )
105 self
. assertIsPlaylist ( result
)
106 self
. assertEqual ( result
[ 'title' ], 'Rolex Awards for Enterprise' )
107 self
. assertTrue ( len ( result
[ 'entries' ]) > 72 )
109 def test_vine_user ( self
):
112 result
= ie
. extract ( 'https://vine.co/Visa' )
113 self
. assertIsPlaylist ( result
)
114 self
. assertTrue ( len ( result
[ 'entries' ]) >= 47 )
116 def test_ustream_channel ( self
):
118 ie
= UstreamChannelIE ( dl
)
119 result
= ie
. extract ( 'http://www.ustream.tv/channel/channeljapan' )
120 self
. assertIsPlaylist ( result
)
121 self
. assertEqual ( result
[ 'id' ], '10874166' )
122 self
. assertTrue ( len ( result
[ 'entries' ]) >= 54 )
124 def test_soundcloud_set ( self
):
126 ie
= SoundcloudSetIE ( dl
)
127 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep' )
128 self
. assertIsPlaylist ( result
)
129 self
. assertEqual ( result
[ 'title' ], 'The Royal Concept EP' )
130 self
. assertTrue ( len ( result
[ 'entries' ]) >= 6 )
132 def test_soundcloud_user ( self
):
134 ie
= SoundcloudUserIE ( dl
)
135 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band' )
136 self
. assertIsPlaylist ( result
)
137 self
. assertEqual ( result
[ 'id' ], '9615865' )
138 self
. assertTrue ( len ( result
[ 'entries' ]) >= 12 )
140 def test_soundcloud_likes ( self
):
142 ie
= SoundcloudUserIE ( dl
)
143 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band/likes' )
144 self
. assertIsPlaylist ( result
)
145 self
. assertEqual ( result
[ 'id' ], '9615865' )
146 self
. assertTrue ( len ( result
[ 'entries' ]) >= 1 )
148 def test_soundcloud_playlist ( self
):
150 ie
= SoundcloudPlaylistIE ( dl
)
151 result
= ie
. extract ( 'http://api.soundcloud.com/playlists/4110309' )
152 self
. assertIsPlaylist ( result
)
153 self
. assertEqual ( result
[ 'id' ], '4110309' )
154 self
. assertEqual ( result
[ 'title' ], 'TILT Brass - Bowery Poetry Club, August \' 03 [Non-Site SCR 02]' )
156 self
, result
[ 'description' ], r
'TILT Brass - Bowery Poetry Club' )
157 self
. assertEqual ( len ( result
[ 'entries' ]), 6 )
159 def test_livestream_event ( self
):
161 ie
= LivestreamIE ( dl
)
162 result
= ie
. extract ( 'http://new.livestream.com/tedx/cityenglish' )
163 self
. assertIsPlaylist ( result
)
164 self
. assertEqual ( result
[ 'title' ], 'TEDCity2.0 (English)' )
165 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
167 def test_livestreamoriginal_folder ( self
):
169 ie
= LivestreamOriginalIE ( dl
)
170 result
= ie
. extract ( 'https://www.livestream.com/newplay/folder?dirId=a07bf706-d0e4-4e75-a747-b021d84f2fd3' )
171 self
. assertIsPlaylist ( result
)
172 self
. assertEqual ( result
[ 'id' ], 'a07bf706-d0e4-4e75-a747-b021d84f2fd3' )
173 self
. assertTrue ( len ( result
[ 'entries' ]) >= 28 )
175 def test_nhl_videocenter ( self
):
177 ie
= NHLVideocenterIE ( dl
)
178 result
= ie
. extract ( 'http://video.canucks.nhl.com/videocenter/console?catid=999' )
179 self
. assertIsPlaylist ( result
)
180 self
. assertEqual ( result
[ 'id' ], '999' )
181 self
. assertEqual ( result
[ 'title' ], 'Highlights' )
182 self
. assertEqual ( len ( result
[ 'entries' ]), 12 )
184 def test_bambuser_channel ( self
):
186 ie
= BambuserChannelIE ( dl
)
187 result
= ie
. extract ( 'http://bambuser.com/channel/pixelversity' )
188 self
. assertIsPlaylist ( result
)
189 self
. assertEqual ( result
[ 'title' ], 'pixelversity' )
190 self
. assertTrue ( len ( result
[ 'entries' ]) >= 60 )
192 def test_bandcamp_album ( self
):
194 ie
= BandcampAlbumIE ( dl
)
195 result
= ie
. extract ( 'http://mpallante.bandcamp.com/album/nightmare-night-ep' )
196 self
. assertIsPlaylist ( result
)
197 self
. assertEqual ( result
[ 'title' ], 'Nightmare Night EP' )
198 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
200 def test_smotri_community ( self
):
202 ie
= SmotriCommunityIE ( dl
)
203 result
= ie
. extract ( 'http://smotri.com/community/video/kommuna' )
204 self
. assertIsPlaylist ( result
)
205 self
. assertEqual ( result
[ 'id' ], 'kommuna' )
206 self
. assertEqual ( result
[ 'title' ], 'КПРФ' )
207 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
209 def test_smotri_user ( self
):
211 ie
= SmotriUserIE ( dl
)
212 result
= ie
. extract ( 'http://smotri.com/user/inspector' )
213 self
. assertIsPlaylist ( result
)
214 self
. assertEqual ( result
[ 'id' ], 'inspector' )
215 self
. assertEqual ( result
[ 'title' ], 'Inspector' )
216 self
. assertTrue ( len ( result
[ 'entries' ]) >= 9 )
218 def test_AcademicEarthCourse ( self
):
220 ie
= AcademicEarthCourseIE ( dl
)
221 result
= ie
. extract ( 'http://academicearth.org/playlists/laws-of-nature/' )
222 self
. assertIsPlaylist ( result
)
223 self
. assertEqual ( result
[ 'id' ], 'laws-of-nature' )
224 self
. assertEqual ( result
[ 'title' ], 'Laws of Nature' )
225 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.")
226 self
. assertEqual ( len ( result
[ 'entries' ]), 4 )
228 def test_ivi_compilation ( self
):
230 ie
= IviCompilationIE ( dl
)
231 result
= ie
. extract ( 'http://www.ivi.ru/watch/dvoe_iz_lartsa' )
232 self
. assertIsPlaylist ( result
)
233 self
. assertEqual ( result
[ 'id' ], 'dvoe_iz_lartsa' )
234 self
. assertEqual ( result
[ 'title' ], 'Двое из ларца (2006 - 2008)' )
235 self
. assertTrue ( len ( result
[ 'entries' ]) >= 24 )
237 def test_ivi_compilation_season ( self
):
239 ie
= IviCompilationIE ( dl
)
240 result
= ie
. extract ( 'http://www.ivi.ru/watch/dvoe_iz_lartsa/season1' )
241 self
. assertIsPlaylist ( result
)
242 self
. assertEqual ( result
[ 'id' ], 'dvoe_iz_lartsa/season1' )
243 self
. assertEqual ( result
[ 'title' ], 'Двое из ларца (2006 - 2008) 1 сезон' )
244 self
. assertTrue ( len ( result
[ 'entries' ]) >= 12 )
246 def test_imdb_list ( self
):
249 result
= ie
. extract ( 'http://www.imdb.com/list/JFs9NWw6XI0' )
250 self
. assertIsPlaylist ( result
)
251 self
. assertEqual ( result
[ 'id' ], 'JFs9NWw6XI0' )
252 self
. assertEqual ( result
[ 'title' ], 'March 23, 2012 Releases' )
253 self
. assertEqual ( len ( result
[ 'entries' ]), 7 )
255 def test_khanacademy_topic ( self
):
257 ie
= KhanAcademyIE ( dl
)
258 result
= ie
. extract ( 'https://www.khanacademy.org/math/applied-math/cryptography' )
259 self
. assertIsPlaylist ( result
)
260 self
. assertEqual ( result
[ 'id' ], 'cryptography' )
261 self
. assertEqual ( result
[ 'title' ], 'Journey into cryptography' )
262 self
. assertEqual ( result
[ 'description' ], 'How have humans protected their secret messages through history? What has changed today?' )
263 self
. assertTrue ( len ( result
[ 'entries' ]) >= 3 )
265 def test_EveryonesMixtape ( self
):
267 ie
= EveryonesMixtapeIE ( dl
)
268 result
= ie
. extract ( 'http://everyonesmixtape.com/#/mix/m7m0jJAbMQi' )
269 self
. assertIsPlaylist ( result
)
270 self
. assertEqual ( result
[ 'id' ], 'm7m0jJAbMQi' )
271 self
. assertEqual ( result
[ 'title' ], 'Driving' )
272 self
. assertEqual ( len ( result
[ 'entries' ]), 24 )
274 def test_rutube_channel ( self
):
276 ie
= RutubeChannelIE ( dl
)
277 result
= ie
. extract ( 'http://rutube.ru/tags/video/1800/' )
278 self
. assertIsPlaylist ( result
)
279 self
. assertEqual ( result
[ 'id' ], '1800' )
280 self
. assertTrue ( len ( result
[ 'entries' ]) >= 68 )
282 def test_rutube_person ( self
):
284 ie
= RutubePersonIE ( dl
)
285 result
= ie
. extract ( 'http://rutube.ru/video/person/313878/' )
286 self
. assertIsPlaylist ( result
)
287 self
. assertEqual ( result
[ 'id' ], '313878' )
288 self
. assertTrue ( len ( result
[ 'entries' ]) >= 37 )
290 def test_multiple_brightcove_videos ( self
):
291 # https://github.com/rg3/youtube-dl/issues/2283
294 result
= ie
. extract ( 'http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html' )
295 self
. assertIsPlaylist ( result
)
296 self
. assertEqual ( result
[ 'id' ], 'always-never-nuclear-command-and-control' )
297 self
. assertEqual ( result
[ 'title' ], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker' )
298 self
. assertEqual ( len ( result
[ 'entries' ]), 3 )
300 def test_GoogleSearch ( self
):
302 ie
= GoogleSearchIE ( dl
)
303 result
= ie
. extract ( 'gvsearch15:python language' )
304 self
. assertIsPlaylist ( result
)
305 self
. assertEqual ( result
[ 'id' ], 'python language' )
306 self
. assertEqual ( result
[ 'title' ], 'python language' )
307 self
. assertEqual ( len ( result
[ 'entries' ]), 15 )
309 def test_generic_rss_feed ( self
):
312 result
= ie
. extract ( 'http://phihag.de/2014/youtube-dl/rss.xml' )
313 self
. assertIsPlaylist ( result
)
314 self
. assertEqual ( result
[ 'id' ], 'http://phihag.de/2014/youtube-dl/rss.xml' )
315 self
. assertEqual ( result
[ 'title' ], 'Zero Punctuation' )
316 self
. assertTrue ( len ( result
[ 'entries' ]) > 10 )
318 def test_ted_playlist ( self
):
321 result
= ie
. extract ( 'http://www.ted.com/playlists/who_are_the_hackers' )
322 self
. assertIsPlaylist ( result
)
323 self
. assertEqual ( result
[ 'id' ], '10' )
324 self
. assertEqual ( result
[ 'title' ], 'Who are the hackers?' )
325 self
. assertTrue ( len ( result
[ 'entries' ]) >= 6 )
327 def test_toypics_user ( self
):
329 ie
= ToypicsUserIE ( dl
)
330 result
= ie
. extract ( 'http://videos.toypics.net/Mikey' )
331 self
. assertIsPlaylist ( result
)
332 self
. assertEqual ( result
[ 'id' ], 'Mikey' )
333 self
. assertTrue ( len ( result
[ 'entries' ]) >= 17 )
335 def test_xtube_user ( self
):
338 result
= ie
. extract ( 'http://www.xtube.com/community/profile.php?user=greenshowers' )
339 self
. assertIsPlaylist ( result
)
340 self
. assertEqual ( result
[ 'id' ], 'greenshowers' )
341 self
. assertTrue ( len ( result
[ 'entries' ]) >= 155 )
343 def test_InstagramUser ( self
):
345 ie
= InstagramUserIE ( dl
)
346 result
= ie
. extract ( 'http://instagram.com/porsche' )
347 self
. assertIsPlaylist ( result
)
348 self
. assertEqual ( result
[ 'id' ], 'porsche' )
349 self
. assertTrue ( len ( result
[ 'entries' ]) >= 2 )
351 e
for e
in result
[ 'entries' ]
352 if e
[ 'id' ] == '614605558512799803_462752227' )
353 dl
. add_default_extra_info ( test_video
, ie
, '(irrelevant URL)' )
354 dl
. process_video_result ( test_video
, download
= False )
356 'id' : '614605558512799803_462752227' ,
358 'title' : '#Porsche Intelligent Performance.' ,
359 'thumbnail' : 're:^https?://.*\.jpg' ,
360 'uploader' : 'Porsche' ,
361 'uploader_id' : 'porsche' ,
362 'timestamp' : 1387486713 ,
363 'upload_date' : '20131219' ,
365 expect_info_dict ( self
, EXPECTED
, test_video
)
367 def test_CSpan_playlist ( self
):
371 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall' )
372 self
. assertIsPlaylist ( result
)
373 self
. assertEqual ( result
[ 'id' ], '342759' )
375 result
[ 'title' ], 'General Motors Ignition Switch Recall' )
376 whole_duration
= sum ( e
[ 'duration' ] for e
in result
[ 'entries' ])
377 self
. assertEqual ( whole_duration
, 14855 )
379 def test_aol_playlist ( self
):
383 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316' )
384 self
. assertIsPlaylist ( result
)
385 self
. assertEqual ( result
[ 'id' ], '152147' )
387 result
[ 'title' ], 'Brace Yourself - Today \' s Weirdest News' )
388 self
. assertTrue ( len ( result
[ 'entries' ]) >= 10 )
390 def test_TeacherTubeUser ( self
):
392 ie
= TeacherTubeUserIE ( dl
)
393 result
= ie
. extract ( 'http://www.teachertube.com/user/profile/rbhagwati2' )
394 self
. assertIsPlaylist ( result
)
395 self
. assertEqual ( result
[ 'id' ], 'rbhagwati2' )
396 self
. assertTrue ( len ( result
[ 'entries' ]) >= 179 )
398 if __name__
== '__main__' :