]>
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
,
31 TeacherTubeClassroomIE
,
54 class TestPlaylists ( unittest
. TestCase
):
55 def assertIsPlaylist ( self
, info
):
56 """Make sure the info has '_type' set to 'playlist'"""
57 self
. assertEqual ( info
[ '_type' ], 'playlist' )
59 def test_dailymotion_playlist ( self
):
61 ie
= DailymotionPlaylistIE ( dl
)
62 result
= ie
. extract ( 'http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q' )
63 self
. assertIsPlaylist ( result
)
64 self
. assertEqual ( result
[ 'title' ], 'SPORT' )
65 self
. assertTrue ( len ( result
[ 'entries' ]) > 20 )
67 def test_dailymotion_user ( self
):
69 ie
= DailymotionUserIE ( dl
)
70 result
= ie
. extract ( 'https://www.dailymotion.com/user/nqtv' )
71 self
. assertIsPlaylist ( result
)
72 self
. assertEqual ( result
[ 'title' ], 'Rémi Gaillard' )
73 self
. assertTrue ( len ( result
[ 'entries' ]) >= 100 )
75 def test_vimeo_channel ( self
):
77 ie
= VimeoChannelIE ( dl
)
78 result
= ie
. extract ( 'http://vimeo.com/channels/tributes' )
79 self
. assertIsPlaylist ( result
)
80 self
. assertEqual ( result
[ 'title' ], 'Vimeo Tributes' )
81 self
. assertTrue ( len ( result
[ 'entries' ]) > 24 )
83 def test_vimeo_user ( self
):
86 result
= ie
. extract ( 'http://vimeo.com/nkistudio/videos' )
87 self
. assertIsPlaylist ( result
)
88 self
. assertEqual ( result
[ 'title' ], 'Nki' )
89 self
. assertTrue ( len ( result
[ 'entries' ]) > 65 )
91 def test_vimeo_album ( self
):
94 result
= ie
. extract ( 'http://vimeo.com/album/2632481' )
95 self
. assertIsPlaylist ( result
)
96 self
. assertEqual ( result
[ 'title' ], 'Staff Favorites: November 2013' )
97 self
. assertTrue ( len ( result
[ 'entries' ]) > 12 )
99 def test_vimeo_groups ( self
):
101 ie
= VimeoGroupsIE ( dl
)
102 result
= ie
. extract ( 'http://vimeo.com/groups/rolexawards' )
103 self
. assertIsPlaylist ( result
)
104 self
. assertEqual ( result
[ 'title' ], 'Rolex Awards for Enterprise' )
105 self
. assertTrue ( len ( result
[ 'entries' ]) > 72 )
107 def test_vine_user ( self
):
110 result
= ie
. extract ( 'https://vine.co/Visa' )
111 self
. assertIsPlaylist ( result
)
112 self
. assertTrue ( len ( result
[ 'entries' ]) >= 50 )
114 def test_ustream_channel ( self
):
116 ie
= UstreamChannelIE ( dl
)
117 result
= ie
. extract ( 'http://www.ustream.tv/channel/young-americans-for-liberty' )
118 self
. assertIsPlaylist ( result
)
119 self
. assertEqual ( result
[ 'id' ], '5124905' )
120 self
. assertTrue ( len ( result
[ 'entries' ]) >= 6 )
122 def test_soundcloud_set ( self
):
124 ie
= SoundcloudSetIE ( dl
)
125 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep' )
126 self
. assertIsPlaylist ( result
)
127 self
. assertEqual ( result
[ 'title' ], 'The Royal Concept EP' )
128 self
. assertTrue ( len ( result
[ 'entries' ]) >= 6 )
130 def test_soundcloud_user ( self
):
132 ie
= SoundcloudUserIE ( dl
)
133 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band' )
134 self
. assertIsPlaylist ( result
)
135 self
. assertEqual ( result
[ 'id' ], '9615865' )
136 self
. assertTrue ( len ( result
[ 'entries' ]) >= 12 )
138 def test_soundcloud_playlist ( self
):
140 ie
= SoundcloudPlaylistIE ( dl
)
141 result
= ie
. extract ( 'http://api.soundcloud.com/playlists/4110309' )
142 self
. assertIsPlaylist ( result
)
143 self
. assertEqual ( result
[ 'id' ], '4110309' )
144 self
. assertEqual ( result
[ 'title' ], 'TILT Brass - Bowery Poetry Club, August \' 03 [Non-Site SCR 02]' )
146 self
, result
[ 'description' ], r
'TILT Brass - Bowery Poetry Club' )
147 self
. assertEqual ( len ( result
[ 'entries' ]), 6 )
149 def test_livestream_event ( self
):
151 ie
= LivestreamIE ( dl
)
152 result
= ie
. extract ( 'http://new.livestream.com/tedx/cityenglish' )
153 self
. assertIsPlaylist ( result
)
154 self
. assertEqual ( result
[ 'title' ], 'TEDCity2.0 (English)' )
155 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
157 def test_nhl_videocenter ( self
):
159 ie
= NHLVideocenterIE ( dl
)
160 result
= ie
. extract ( 'http://video.canucks.nhl.com/videocenter/console?catid=999' )
161 self
. assertIsPlaylist ( result
)
162 self
. assertEqual ( result
[ 'id' ], '999' )
163 self
. assertEqual ( result
[ 'title' ], 'Highlights' )
164 self
. assertEqual ( len ( result
[ 'entries' ]), 12 )
166 def test_bambuser_channel ( self
):
168 ie
= BambuserChannelIE ( dl
)
169 result
= ie
. extract ( 'http://bambuser.com/channel/pixelversity' )
170 self
. assertIsPlaylist ( result
)
171 self
. assertEqual ( result
[ 'title' ], 'pixelversity' )
172 self
. assertTrue ( len ( result
[ 'entries' ]) >= 60 )
174 def test_bandcamp_album ( self
):
176 ie
= BandcampAlbumIE ( dl
)
177 result
= ie
. extract ( 'http://mpallante.bandcamp.com/album/nightmare-night-ep' )
178 self
. assertIsPlaylist ( result
)
179 self
. assertEqual ( result
[ 'title' ], 'Nightmare Night EP' )
180 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
182 def test_smotri_community ( self
):
184 ie
= SmotriCommunityIE ( dl
)
185 result
= ie
. extract ( 'http://smotri.com/community/video/kommuna' )
186 self
. assertIsPlaylist ( result
)
187 self
. assertEqual ( result
[ 'id' ], 'kommuna' )
188 self
. assertEqual ( result
[ 'title' ], 'КПРФ' )
189 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
191 def test_smotri_user ( self
):
193 ie
= SmotriUserIE ( dl
)
194 result
= ie
. extract ( 'http://smotri.com/user/inspector' )
195 self
. assertIsPlaylist ( result
)
196 self
. assertEqual ( result
[ 'id' ], 'inspector' )
197 self
. assertEqual ( result
[ 'title' ], 'Inspector' )
198 self
. assertTrue ( len ( result
[ 'entries' ]) >= 9 )
200 def test_AcademicEarthCourse ( self
):
202 ie
= AcademicEarthCourseIE ( dl
)
203 result
= ie
. extract ( 'http://academicearth.org/playlists/laws-of-nature/' )
204 self
. assertIsPlaylist ( result
)
205 self
. assertEqual ( result
[ 'id' ], 'laws-of-nature' )
206 self
. assertEqual ( result
[ 'title' ], 'Laws of Nature' )
207 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.")
208 self
. assertEqual ( len ( result
[ 'entries' ]), 4 )
210 def test_ivi_compilation ( self
):
212 ie
= IviCompilationIE ( dl
)
213 result
= ie
. extract ( 'http://www.ivi.ru/watch/dvoe_iz_lartsa' )
214 self
. assertIsPlaylist ( result
)
215 self
. assertEqual ( result
[ 'id' ], 'dvoe_iz_lartsa' )
216 self
. assertEqual ( result
[ 'title' ], 'Двое из ларца (2006 - 2008)' )
217 self
. assertTrue ( len ( result
[ 'entries' ]) >= 24 )
219 def test_ivi_compilation_season ( self
):
221 ie
= IviCompilationIE ( dl
)
222 result
= ie
. extract ( 'http://www.ivi.ru/watch/dvoe_iz_lartsa/season1' )
223 self
. assertIsPlaylist ( result
)
224 self
. assertEqual ( result
[ 'id' ], 'dvoe_iz_lartsa/season1' )
225 self
. assertEqual ( result
[ 'title' ], 'Двое из ларца (2006 - 2008) 1 сезон' )
226 self
. assertTrue ( len ( result
[ 'entries' ]) >= 12 )
228 def test_imdb_list ( self
):
231 result
= ie
. extract ( 'http://www.imdb.com/list/JFs9NWw6XI0' )
232 self
. assertIsPlaylist ( result
)
233 self
. assertEqual ( result
[ 'id' ], 'JFs9NWw6XI0' )
234 self
. assertEqual ( result
[ 'title' ], 'March 23, 2012 Releases' )
235 self
. assertEqual ( len ( result
[ 'entries' ]), 7 )
237 def test_khanacademy_topic ( self
):
239 ie
= KhanAcademyIE ( dl
)
240 result
= ie
. extract ( 'https://www.khanacademy.org/math/applied-math/cryptography' )
241 self
. assertIsPlaylist ( result
)
242 self
. assertEqual ( result
[ 'id' ], 'cryptography' )
243 self
. assertEqual ( result
[ 'title' ], 'Journey into cryptography' )
244 self
. assertEqual ( result
[ 'description' ], 'How have humans protected their secret messages through history? What has changed today?' )
245 self
. assertTrue ( len ( result
[ 'entries' ]) >= 3 )
247 def test_EveryonesMixtape ( self
):
249 ie
= EveryonesMixtapeIE ( dl
)
250 result
= ie
. extract ( 'http://everyonesmixtape.com/#/mix/m7m0jJAbMQi' )
251 self
. assertIsPlaylist ( result
)
252 self
. assertEqual ( result
[ 'id' ], 'm7m0jJAbMQi' )
253 self
. assertEqual ( result
[ 'title' ], 'Driving' )
254 self
. assertEqual ( len ( result
[ 'entries' ]), 24 )
256 def test_rutube_channel ( self
):
258 ie
= RutubeChannelIE ( dl
)
259 result
= ie
. extract ( 'http://rutube.ru/tags/video/1409' )
260 self
. assertIsPlaylist ( result
)
261 self
. assertEqual ( result
[ 'id' ], '1409' )
262 self
. assertTrue ( len ( result
[ 'entries' ]) >= 34 )
264 def test_multiple_brightcove_videos ( self
):
265 # https://github.com/rg3/youtube-dl/issues/2283
268 result
= ie
. extract ( 'http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html' )
269 self
. assertIsPlaylist ( result
)
270 self
. assertEqual ( result
[ 'id' ], 'always-never-nuclear-command-and-control' )
271 self
. assertEqual ( result
[ 'title' ], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker' )
272 self
. assertEqual ( len ( result
[ 'entries' ]), 3 )
274 def test_GoogleSearch ( self
):
276 ie
= GoogleSearchIE ( dl
)
277 result
= ie
. extract ( 'gvsearch15:python language' )
278 self
. assertIsPlaylist ( result
)
279 self
. assertEqual ( result
[ 'id' ], 'python language' )
280 self
. assertEqual ( result
[ 'title' ], 'python language' )
281 self
. assertEqual ( len ( result
[ 'entries' ]), 15 )
283 def test_generic_rss_feed ( self
):
286 result
= ie
. extract ( 'http://phihag.de/2014/youtube-dl/rss.xml' )
287 self
. assertIsPlaylist ( result
)
288 self
. assertEqual ( result
[ 'id' ], 'http://phihag.de/2014/youtube-dl/rss.xml' )
289 self
. assertEqual ( result
[ 'title' ], 'Zero Punctuation' )
290 self
. assertTrue ( len ( result
[ 'entries' ]) > 10 )
292 def test_ted_playlist ( self
):
295 result
= ie
. extract ( 'http://www.ted.com/playlists/who_are_the_hackers' )
296 self
. assertIsPlaylist ( result
)
297 self
. assertEqual ( result
[ 'id' ], '10' )
298 self
. assertEqual ( result
[ 'title' ], 'Who are the hackers?' )
299 self
. assertTrue ( len ( result
[ 'entries' ]) >= 6 )
301 def test_toypics_user ( self
):
303 ie
= ToypicsUserIE ( dl
)
304 result
= ie
. extract ( 'http://videos.toypics.net/Mikey' )
305 self
. assertIsPlaylist ( result
)
306 self
. assertEqual ( result
[ 'id' ], 'Mikey' )
307 self
. assertTrue ( len ( result
[ 'entries' ]) >= 17 )
309 def test_xtube_user ( self
):
312 result
= ie
. extract ( 'http://www.xtube.com/community/profile.php?user=greenshowers' )
313 self
. assertIsPlaylist ( result
)
314 self
. assertEqual ( result
[ 'id' ], 'greenshowers' )
315 self
. assertTrue ( len ( result
[ 'entries' ]) >= 155 )
317 def test_InstagramUser ( self
):
319 ie
= InstagramUserIE ( dl
)
320 result
= ie
. extract ( 'http://instagram.com/porsche' )
321 self
. assertIsPlaylist ( result
)
322 self
. assertEqual ( result
[ 'id' ], 'porsche' )
323 self
. assertTrue ( len ( result
[ 'entries' ]) >= 2 )
325 e
for e
in result
[ 'entries' ]
326 if e
[ 'id' ] == '614605558512799803_462752227' )
327 dl
. add_default_extra_info ( test_video
, ie
, '(irrelevant URL)' )
328 dl
. process_video_result ( test_video
, download
= False )
330 'id' : '614605558512799803_462752227' ,
332 'title' : '#Porsche Intelligent Performance.' ,
333 'thumbnail' : 're:^https?://.*\.jpg' ,
334 'uploader' : 'Porsche' ,
335 'uploader_id' : 'porsche' ,
336 'timestamp' : 1387486713 ,
337 'upload_date' : '20131219' ,
339 expect_info_dict ( self
, EXPECTED
, test_video
)
341 def test_CSpan_playlist ( self
):
345 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall' )
346 self
. assertIsPlaylist ( result
)
347 self
. assertEqual ( result
[ 'id' ], '342759' )
349 result
[ 'title' ], 'General Motors Ignition Switch Recall' )
350 whole_duration
= sum ( e
[ 'duration' ] for e
in result
[ 'entries' ])
351 self
. assertEqual ( whole_duration
, 14855 )
353 def test_aol_playlist ( self
):
357 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316' )
358 self
. assertIsPlaylist ( result
)
359 self
. assertEqual ( result
[ 'id' ], '152147' )
361 result
[ 'title' ], 'Brace Yourself - Today \' s Weirdest News' )
362 self
. assertTrue ( len ( result
[ 'entries' ]) >= 10 )
364 def test_TeacherTubeClassroom ( self
):
366 ie
= TeacherTubeClassroomIE ( dl
)
367 result
= ie
. extract ( 'http://www.teachertube.com/view_classroom.php?user=rbhagwati2' )
368 self
. assertIsPlaylist ( result
)
369 self
. assertEqual ( result
[ 'id' ], 'rbhagwati2' )
370 self
. assertTrue ( len ( result
[ 'entries' ]) >= 20 )
372 if __name__
== '__main__' :