]>
Raphaël G. Git Repositories - youtubedl/blob - test/test_playlists.py
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' ]) >= 50 )
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_playlist ( self
):
142 ie
= SoundcloudPlaylistIE ( dl
)
143 result
= ie
. extract ( 'http://api.soundcloud.com/playlists/4110309' )
144 self
. assertIsPlaylist ( result
)
145 self
. assertEqual ( result
[ 'id' ], '4110309' )
146 self
. assertEqual ( result
[ 'title' ], 'TILT Brass - Bowery Poetry Club, August \' 03 [Non-Site SCR 02]' )
148 self
, result
[ 'description' ], r
'TILT Brass - Bowery Poetry Club' )
149 self
. assertEqual ( len ( result
[ 'entries' ]), 6 )
151 def test_livestream_event ( self
):
153 ie
= LivestreamIE ( dl
)
154 result
= ie
. extract ( 'http://new.livestream.com/tedx/cityenglish' )
155 self
. assertIsPlaylist ( result
)
156 self
. assertEqual ( result
[ 'title' ], 'TEDCity2.0 (English)' )
157 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
159 def test_livestreamoriginal_folder ( self
):
161 ie
= LivestreamOriginalIE ( dl
)
162 result
= ie
. extract ( 'https://www.livestream.com/newplay/folder?dirId=a07bf706-d0e4-4e75-a747-b021d84f2fd3' )
163 self
. assertIsPlaylist ( result
)
164 self
. assertEqual ( result
[ 'id' ], 'a07bf706-d0e4-4e75-a747-b021d84f2fd3' )
165 self
. assertTrue ( len ( result
[ 'entries' ]) >= 28 )
167 def test_nhl_videocenter ( self
):
169 ie
= NHLVideocenterIE ( dl
)
170 result
= ie
. extract ( 'http://video.canucks.nhl.com/videocenter/console?catid=999' )
171 self
. assertIsPlaylist ( result
)
172 self
. assertEqual ( result
[ 'id' ], '999' )
173 self
. assertEqual ( result
[ 'title' ], 'Highlights' )
174 self
. assertEqual ( len ( result
[ 'entries' ]), 12 )
176 def test_bambuser_channel ( self
):
178 ie
= BambuserChannelIE ( dl
)
179 result
= ie
. extract ( 'http://bambuser.com/channel/pixelversity' )
180 self
. assertIsPlaylist ( result
)
181 self
. assertEqual ( result
[ 'title' ], 'pixelversity' )
182 self
. assertTrue ( len ( result
[ 'entries' ]) >= 60 )
184 def test_bandcamp_album ( self
):
186 ie
= BandcampAlbumIE ( dl
)
187 result
= ie
. extract ( 'http://mpallante.bandcamp.com/album/nightmare-night-ep' )
188 self
. assertIsPlaylist ( result
)
189 self
. assertEqual ( result
[ 'title' ], 'Nightmare Night EP' )
190 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
192 def test_smotri_community ( self
):
194 ie
= SmotriCommunityIE ( dl
)
195 result
= ie
. extract ( 'http://smotri.com/community/video/kommuna' )
196 self
. assertIsPlaylist ( result
)
197 self
. assertEqual ( result
[ 'id' ], 'kommuna' )
198 self
. assertEqual ( result
[ 'title' ], 'КПРФ' )
199 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
201 def test_smotri_user ( self
):
203 ie
= SmotriUserIE ( dl
)
204 result
= ie
. extract ( 'http://smotri.com/user/inspector' )
205 self
. assertIsPlaylist ( result
)
206 self
. assertEqual ( result
[ 'id' ], 'inspector' )
207 self
. assertEqual ( result
[ 'title' ], 'Inspector' )
208 self
. assertTrue ( len ( result
[ 'entries' ]) >= 9 )
210 def test_AcademicEarthCourse ( self
):
212 ie
= AcademicEarthCourseIE ( dl
)
213 result
= ie
. extract ( 'http://academicearth.org/playlists/laws-of-nature/' )
214 self
. assertIsPlaylist ( result
)
215 self
. assertEqual ( result
[ 'id' ], 'laws-of-nature' )
216 self
. assertEqual ( result
[ 'title' ], 'Laws of Nature' )
217 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.")
218 self
. assertEqual ( len ( result
[ 'entries' ]), 4 )
220 def test_ivi_compilation ( self
):
222 ie
= IviCompilationIE ( dl
)
223 result
= ie
. extract ( 'http://www.ivi.ru/watch/dvoe_iz_lartsa' )
224 self
. assertIsPlaylist ( result
)
225 self
. assertEqual ( result
[ 'id' ], 'dvoe_iz_lartsa' )
226 self
. assertEqual ( result
[ 'title' ], 'Двое из ларца (2006 - 2008)' )
227 self
. assertTrue ( len ( result
[ 'entries' ]) >= 24 )
229 def test_ivi_compilation_season ( self
):
231 ie
= IviCompilationIE ( dl
)
232 result
= ie
. extract ( 'http://www.ivi.ru/watch/dvoe_iz_lartsa/season1' )
233 self
. assertIsPlaylist ( result
)
234 self
. assertEqual ( result
[ 'id' ], 'dvoe_iz_lartsa/season1' )
235 self
. assertEqual ( result
[ 'title' ], 'Двое из ларца (2006 - 2008) 1 сезон' )
236 self
. assertTrue ( len ( result
[ 'entries' ]) >= 12 )
238 def test_imdb_list ( self
):
241 result
= ie
. extract ( 'http://www.imdb.com/list/JFs9NWw6XI0' )
242 self
. assertIsPlaylist ( result
)
243 self
. assertEqual ( result
[ 'id' ], 'JFs9NWw6XI0' )
244 self
. assertEqual ( result
[ 'title' ], 'March 23, 2012 Releases' )
245 self
. assertEqual ( len ( result
[ 'entries' ]), 7 )
247 def test_khanacademy_topic ( self
):
249 ie
= KhanAcademyIE ( dl
)
250 result
= ie
. extract ( 'https://www.khanacademy.org/math/applied-math/cryptography' )
251 self
. assertIsPlaylist ( result
)
252 self
. assertEqual ( result
[ 'id' ], 'cryptography' )
253 self
. assertEqual ( result
[ 'title' ], 'Journey into cryptography' )
254 self
. assertEqual ( result
[ 'description' ], 'How have humans protected their secret messages through history? What has changed today?' )
255 self
. assertTrue ( len ( result
[ 'entries' ]) >= 3 )
257 def test_EveryonesMixtape ( self
):
259 ie
= EveryonesMixtapeIE ( dl
)
260 result
= ie
. extract ( 'http://everyonesmixtape.com/#/mix/m7m0jJAbMQi' )
261 self
. assertIsPlaylist ( result
)
262 self
. assertEqual ( result
[ 'id' ], 'm7m0jJAbMQi' )
263 self
. assertEqual ( result
[ 'title' ], 'Driving' )
264 self
. assertEqual ( len ( result
[ 'entries' ]), 24 )
266 def test_rutube_channel ( self
):
268 ie
= RutubeChannelIE ( dl
)
269 result
= ie
. extract ( 'http://rutube.ru/tags/video/1800/' )
270 self
. assertIsPlaylist ( result
)
271 self
. assertEqual ( result
[ 'id' ], '1800' )
272 self
. assertTrue ( len ( result
[ 'entries' ]) >= 68 )
274 def test_rutube_person ( self
):
276 ie
= RutubePersonIE ( dl
)
277 result
= ie
. extract ( 'http://rutube.ru/video/person/313878/' )
278 self
. assertIsPlaylist ( result
)
279 self
. assertEqual ( result
[ 'id' ], '313878' )
280 self
. assertTrue ( len ( result
[ 'entries' ]) >= 37 )
282 def test_multiple_brightcove_videos ( self
):
283 # https://github.com/rg3/youtube-dl/issues/2283
286 result
= ie
. extract ( 'http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html' )
287 self
. assertIsPlaylist ( result
)
288 self
. assertEqual ( result
[ 'id' ], 'always-never-nuclear-command-and-control' )
289 self
. assertEqual ( result
[ 'title' ], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker' )
290 self
. assertEqual ( len ( result
[ 'entries' ]), 3 )
292 def test_GoogleSearch ( self
):
294 ie
= GoogleSearchIE ( dl
)
295 result
= ie
. extract ( 'gvsearch15:python language' )
296 self
. assertIsPlaylist ( result
)
297 self
. assertEqual ( result
[ 'id' ], 'python language' )
298 self
. assertEqual ( result
[ 'title' ], 'python language' )
299 self
. assertEqual ( len ( result
[ 'entries' ]), 15 )
301 def test_generic_rss_feed ( self
):
304 result
= ie
. extract ( 'http://phihag.de/2014/youtube-dl/rss.xml' )
305 self
. assertIsPlaylist ( result
)
306 self
. assertEqual ( result
[ 'id' ], 'http://phihag.de/2014/youtube-dl/rss.xml' )
307 self
. assertEqual ( result
[ 'title' ], 'Zero Punctuation' )
308 self
. assertTrue ( len ( result
[ 'entries' ]) > 10 )
310 def test_ted_playlist ( self
):
313 result
= ie
. extract ( 'http://www.ted.com/playlists/who_are_the_hackers' )
314 self
. assertIsPlaylist ( result
)
315 self
. assertEqual ( result
[ 'id' ], '10' )
316 self
. assertEqual ( result
[ 'title' ], 'Who are the hackers?' )
317 self
. assertTrue ( len ( result
[ 'entries' ]) >= 6 )
319 def test_toypics_user ( self
):
321 ie
= ToypicsUserIE ( dl
)
322 result
= ie
. extract ( 'http://videos.toypics.net/Mikey' )
323 self
. assertIsPlaylist ( result
)
324 self
. assertEqual ( result
[ 'id' ], 'Mikey' )
325 self
. assertTrue ( len ( result
[ 'entries' ]) >= 17 )
327 def test_xtube_user ( self
):
330 result
= ie
. extract ( 'http://www.xtube.com/community/profile.php?user=greenshowers' )
331 self
. assertIsPlaylist ( result
)
332 self
. assertEqual ( result
[ 'id' ], 'greenshowers' )
333 self
. assertTrue ( len ( result
[ 'entries' ]) >= 155 )
335 def test_InstagramUser ( self
):
337 ie
= InstagramUserIE ( dl
)
338 result
= ie
. extract ( 'http://instagram.com/porsche' )
339 self
. assertIsPlaylist ( result
)
340 self
. assertEqual ( result
[ 'id' ], 'porsche' )
341 self
. assertTrue ( len ( result
[ 'entries' ]) >= 2 )
343 e
for e
in result
[ 'entries' ]
344 if e
[ 'id' ] == '614605558512799803_462752227' )
345 dl
. add_default_extra_info ( test_video
, ie
, '(irrelevant URL)' )
346 dl
. process_video_result ( test_video
, download
= False )
348 'id' : '614605558512799803_462752227' ,
350 'title' : '#Porsche Intelligent Performance.' ,
351 'thumbnail' : 're:^https?://.*\.jpg' ,
352 'uploader' : 'Porsche' ,
353 'uploader_id' : 'porsche' ,
354 'timestamp' : 1387486713 ,
355 'upload_date' : '20131219' ,
357 expect_info_dict ( self
, EXPECTED
, test_video
)
359 def test_CSpan_playlist ( self
):
363 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall' )
364 self
. assertIsPlaylist ( result
)
365 self
. assertEqual ( result
[ 'id' ], '342759' )
367 result
[ 'title' ], 'General Motors Ignition Switch Recall' )
368 whole_duration
= sum ( e
[ 'duration' ] for e
in result
[ 'entries' ])
369 self
. assertEqual ( whole_duration
, 14855 )
371 def test_aol_playlist ( self
):
375 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316' )
376 self
. assertIsPlaylist ( result
)
377 self
. assertEqual ( result
[ 'id' ], '152147' )
379 result
[ 'title' ], 'Brace Yourself - Today \' s Weirdest News' )
380 self
. assertTrue ( len ( result
[ 'entries' ]) >= 10 )
382 def test_TeacherTubeUser ( self
):
384 ie
= TeacherTubeUserIE ( dl
)
385 result
= ie
. extract ( 'http://www.teachertube.com/user/profile/rbhagwati2' )
386 self
. assertIsPlaylist ( result
)
387 self
. assertEqual ( result
[ 'id' ], 'rbhagwati2' )
388 self
. assertTrue ( len ( result
[ 'entries' ]) >= 179 )
390 if __name__
== '__main__' :