]>
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 (
19 from youtube_dl
. extractor
import (
20 AcademicEarthCourseIE
,
21 DailymotionPlaylistIE
,
57 class TestPlaylists ( unittest
. TestCase
):
58 def assertIsPlaylist ( self
, info
):
59 """Make sure the info has '_type' set to 'playlist'"""
60 self
. assertEqual ( info
[ '_type' ], 'playlist' )
62 def test_dailymotion_playlist ( self
):
64 ie
= DailymotionPlaylistIE ( dl
)
65 result
= ie
. extract ( 'http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q' )
66 self
. assertIsPlaylist ( result
)
67 self
. assertEqual ( result
[ 'title' ], 'SPORT' )
68 self
. assertTrue ( len ( result
[ 'entries' ]) > 20 )
70 def test_dailymotion_user ( self
):
72 ie
= DailymotionUserIE ( dl
)
73 result
= ie
. extract ( 'https://www.dailymotion.com/user/nqtv' )
74 self
. assertIsPlaylist ( result
)
75 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 100 )
76 self
. assertEqual ( result
[ 'title' ], 'Rémi Gaillard' )
78 def test_vimeo_channel ( self
):
80 ie
= VimeoChannelIE ( dl
)
81 result
= ie
. extract ( 'http://vimeo.com/channels/tributes' )
82 self
. assertIsPlaylist ( result
)
83 self
. assertEqual ( result
[ 'title' ], 'Vimeo Tributes' )
84 self
. assertTrue ( len ( result
[ 'entries' ]) > 24 )
86 def test_vimeo_user ( self
):
89 result
= ie
. extract ( 'http://vimeo.com/nkistudio/videos' )
90 self
. assertIsPlaylist ( result
)
91 self
. assertEqual ( result
[ 'title' ], 'Nki' )
92 self
. assertTrue ( len ( result
[ 'entries' ]) > 65 )
94 def test_vimeo_album ( self
):
97 result
= ie
. extract ( 'http://vimeo.com/album/2632481' )
98 self
. assertIsPlaylist ( result
)
99 self
. assertEqual ( result
[ 'title' ], 'Staff Favorites: November 2013' )
100 self
. assertTrue ( len ( result
[ 'entries' ]) > 12 )
102 def test_vimeo_groups ( self
):
104 ie
= VimeoGroupsIE ( dl
)
105 result
= ie
. extract ( 'http://vimeo.com/groups/rolexawards' )
106 self
. assertIsPlaylist ( result
)
107 self
. assertEqual ( result
[ 'title' ], 'Rolex Awards for Enterprise' )
108 self
. assertTrue ( len ( result
[ 'entries' ]) > 72 )
110 def test_vine_user ( self
):
113 result
= ie
. extract ( 'https://vine.co/Visa' )
114 self
. assertIsPlaylist ( result
)
115 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 47 )
117 def test_ustream_channel ( self
):
119 ie
= UstreamChannelIE ( dl
)
120 result
= ie
. extract ( 'http://www.ustream.tv/channel/channeljapan' )
121 self
. assertIsPlaylist ( result
)
122 self
. assertEqual ( result
[ 'id' ], '10874166' )
123 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 54 )
125 def test_soundcloud_set ( self
):
127 ie
= SoundcloudSetIE ( dl
)
128 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep' )
129 self
. assertIsPlaylist ( result
)
130 self
. assertEqual ( result
[ 'title' ], 'The Royal Concept EP' )
131 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 6 )
133 def test_soundcloud_user ( self
):
135 ie
= SoundcloudUserIE ( dl
)
136 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band' )
137 self
. assertIsPlaylist ( result
)
138 self
. assertEqual ( result
[ 'id' ], '9615865' )
139 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 12 )
141 def test_soundcloud_likes ( self
):
143 ie
= SoundcloudUserIE ( dl
)
144 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band/likes' )
145 self
. assertIsPlaylist ( result
)
146 self
. assertEqual ( result
[ 'id' ], '9615865' )
147 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 1 )
149 def test_soundcloud_playlist ( self
):
151 ie
= SoundcloudPlaylistIE ( dl
)
152 result
= ie
. extract ( 'http://api.soundcloud.com/playlists/4110309' )
153 self
. assertIsPlaylist ( result
)
154 self
. assertEqual ( result
[ 'id' ], '4110309' )
155 self
. assertEqual ( result
[ 'title' ], 'TILT Brass - Bowery Poetry Club, August \' 03 [Non-Site SCR 02]' )
157 self
, result
[ 'description' ], r
'.*?TILT Brass - Bowery Poetry Club' )
158 self
. assertEqual ( len ( result
[ 'entries' ]), 6 )
160 def test_livestream_event ( self
):
162 ie
= LivestreamIE ( dl
)
163 result
= ie
. extract ( 'http://new.livestream.com/tedx/cityenglish' )
164 self
. assertIsPlaylist ( result
)
165 self
. assertEqual ( result
[ 'title' ], 'TEDCity2.0 (English)' )
166 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 4 )
168 def test_livestreamoriginal_folder ( self
):
170 ie
= LivestreamOriginalIE ( dl
)
171 result
= ie
. extract ( 'https://www.livestream.com/newplay/folder?dirId=a07bf706-d0e4-4e75-a747-b021d84f2fd3' )
172 self
. assertIsPlaylist ( result
)
173 self
. assertEqual ( result
[ 'id' ], 'a07bf706-d0e4-4e75-a747-b021d84f2fd3' )
174 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 28 )
176 def test_nhl_videocenter ( self
):
178 ie
= NHLVideocenterIE ( dl
)
179 result
= ie
. extract ( 'http://video.canucks.nhl.com/videocenter/console?catid=999' )
180 self
. assertIsPlaylist ( result
)
181 self
. assertEqual ( result
[ 'id' ], '999' )
182 self
. assertEqual ( result
[ 'title' ], 'Highlights' )
183 self
. assertEqual ( len ( result
[ 'entries' ]), 12 )
185 def test_bambuser_channel ( self
):
187 ie
= BambuserChannelIE ( dl
)
188 result
= ie
. extract ( 'http://bambuser.com/channel/pixelversity' )
189 self
. assertIsPlaylist ( result
)
190 self
. assertEqual ( result
[ 'title' ], 'pixelversity' )
191 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 60 )
193 def test_bandcamp_album ( self
):
195 ie
= BandcampAlbumIE ( dl
)
196 result
= ie
. extract ( 'http://nightbringer.bandcamp.com/album/hierophany-of-the-open-grave' )
197 self
. assertIsPlaylist ( result
)
198 self
. assertEqual ( result
[ 'title' ], 'Hierophany of the Open Grave' )
199 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 9 )
201 def test_smotri_community ( self
):
203 ie
= SmotriCommunityIE ( dl
)
204 result
= ie
. extract ( 'http://smotri.com/community/video/kommuna' )
205 self
. assertIsPlaylist ( result
)
206 self
. assertEqual ( result
[ 'id' ], 'kommuna' )
207 self
. assertEqual ( result
[ 'title' ], 'КПРФ' )
208 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 4 )
210 def test_smotri_user ( self
):
212 ie
= SmotriUserIE ( dl
)
213 result
= ie
. extract ( 'http://smotri.com/user/inspector' )
214 self
. assertIsPlaylist ( result
)
215 self
. assertEqual ( result
[ 'id' ], 'inspector' )
216 self
. assertEqual ( result
[ 'title' ], 'Inspector' )
217 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 9 )
219 def test_AcademicEarthCourse ( self
):
221 ie
= AcademicEarthCourseIE ( dl
)
222 result
= ie
. extract ( 'http://academicearth.org/playlists/laws-of-nature/' )
223 self
. assertIsPlaylist ( result
)
224 self
. assertEqual ( result
[ 'id' ], 'laws-of-nature' )
225 self
. assertEqual ( result
[ 'title' ], 'Laws of Nature' )
226 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.")
227 self
. assertEqual ( len ( result
[ 'entries' ]), 4 )
229 def test_ivi_compilation ( self
):
231 ie
= IviCompilationIE ( dl
)
232 result
= ie
. extract ( 'http://www.ivi.ru/watch/dvoe_iz_lartsa' )
233 self
. assertIsPlaylist ( result
)
234 self
. assertEqual ( result
[ 'id' ], 'dvoe_iz_lartsa' )
235 self
. assertEqual ( result
[ 'title' ], 'Двое из ларца (2006 - 2008)' )
236 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 24 )
238 def test_ivi_compilation_season ( self
):
240 ie
= IviCompilationIE ( dl
)
241 result
= ie
. extract ( 'http://www.ivi.ru/watch/dvoe_iz_lartsa/season1' )
242 self
. assertIsPlaylist ( result
)
243 self
. assertEqual ( result
[ 'id' ], 'dvoe_iz_lartsa/season1' )
244 self
. assertEqual ( result
[ 'title' ], 'Двое из ларца (2006 - 2008) 1 сезон' )
245 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 12 )
247 def test_imdb_list ( self
):
250 result
= ie
. extract ( 'http://www.imdb.com/list/JFs9NWw6XI0' )
251 self
. assertIsPlaylist ( result
)
252 self
. assertEqual ( result
[ 'id' ], 'JFs9NWw6XI0' )
253 self
. assertEqual ( result
[ 'title' ], 'March 23, 2012 Releases' )
254 self
. assertEqual ( len ( result
[ 'entries' ]), 7 )
256 def test_khanacademy_topic ( self
):
258 ie
= KhanAcademyIE ( dl
)
259 result
= ie
. extract ( 'https://www.khanacademy.org/math/applied-math/cryptography' )
260 self
. assertIsPlaylist ( result
)
261 self
. assertEqual ( result
[ 'id' ], 'cryptography' )
262 self
. assertEqual ( result
[ 'title' ], 'Journey into cryptography' )
263 self
. assertEqual ( result
[ 'description' ], 'How have humans protected their secret messages through history? What has changed today?' )
264 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 3 )
266 def test_EveryonesMixtape ( self
):
268 ie
= EveryonesMixtapeIE ( dl
)
269 result
= ie
. extract ( 'http://everyonesmixtape.com/#/mix/m7m0jJAbMQi' )
270 self
. assertIsPlaylist ( result
)
271 self
. assertEqual ( result
[ 'id' ], 'm7m0jJAbMQi' )
272 self
. assertEqual ( result
[ 'title' ], 'Driving' )
273 self
. assertEqual ( len ( result
[ 'entries' ]), 24 )
275 def test_rutube_channel ( self
):
277 ie
= RutubeChannelIE ( dl
)
278 result
= ie
. extract ( 'http://rutube.ru/tags/video/1800/' )
279 self
. assertIsPlaylist ( result
)
280 self
. assertEqual ( result
[ 'id' ], '1800' )
281 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 68 )
283 def test_rutube_person ( self
):
285 ie
= RutubePersonIE ( dl
)
286 result
= ie
. extract ( 'http://rutube.ru/video/person/313878/' )
287 self
. assertIsPlaylist ( result
)
288 self
. assertEqual ( result
[ 'id' ], '313878' )
289 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 37 )
291 def test_multiple_brightcove_videos ( self
):
292 # https://github.com/rg3/youtube-dl/issues/2283
295 result
= ie
. extract ( 'http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html' )
296 self
. assertIsPlaylist ( result
)
297 self
. assertEqual ( result
[ 'id' ], 'always-never-nuclear-command-and-control' )
298 self
. assertEqual ( result
[ 'title' ], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker' )
299 self
. assertEqual ( len ( result
[ 'entries' ]), 3 )
301 def test_GoogleSearch ( self
):
303 ie
= GoogleSearchIE ( dl
)
304 result
= ie
. extract ( 'gvsearch15:python language' )
305 self
. assertIsPlaylist ( result
)
306 self
. assertEqual ( result
[ 'id' ], 'python language' )
307 self
. assertEqual ( result
[ 'title' ], 'python language' )
308 self
. assertEqual ( len ( result
[ 'entries' ]), 15 )
310 def test_generic_rss_feed ( self
):
313 result
= ie
. extract ( 'http://phihag.de/2014/youtube-dl/rss.xml' )
314 self
. assertIsPlaylist ( result
)
315 self
. assertEqual ( result
[ 'id' ], 'http://phihag.de/2014/youtube-dl/rss.xml' )
316 self
. assertEqual ( result
[ 'title' ], 'Zero Punctuation' )
317 self
. assertTrue ( len ( result
[ 'entries' ]) > 10 )
319 def test_ted_playlist ( self
):
322 result
= ie
. extract ( 'http://www.ted.com/playlists/who_are_the_hackers' )
323 self
. assertIsPlaylist ( result
)
324 self
. assertEqual ( result
[ 'id' ], '10' )
325 self
. assertEqual ( result
[ 'title' ], 'Who are the hackers?' )
326 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 6 )
328 def test_toypics_user ( self
):
330 ie
= ToypicsUserIE ( dl
)
331 result
= ie
. extract ( 'http://videos.toypics.net/Mikey' )
332 self
. assertIsPlaylist ( result
)
333 self
. assertEqual ( result
[ 'id' ], 'Mikey' )
334 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 17 )
336 def test_xtube_user ( self
):
339 result
= ie
. extract ( 'http://www.xtube.com/community/profile.php?user=greenshowers' )
340 self
. assertIsPlaylist ( result
)
341 self
. assertEqual ( result
[ 'id' ], 'greenshowers' )
342 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 155 )
344 def test_InstagramUser ( self
):
346 ie
= InstagramUserIE ( dl
)
347 result
= ie
. extract ( 'http://instagram.com/porsche' )
348 self
. assertIsPlaylist ( result
)
349 self
. assertEqual ( result
[ 'id' ], 'porsche' )
350 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 2 )
352 e
for e
in result
[ 'entries' ]
353 if e
[ 'id' ] == '614605558512799803_462752227' )
354 dl
. add_default_extra_info ( test_video
, ie
, '(irrelevant URL)' )
355 dl
. process_video_result ( test_video
, download
= False )
357 'id' : '614605558512799803_462752227' ,
359 'title' : '#Porsche Intelligent Performance.' ,
360 'thumbnail' : 're:^https?://.*\.jpg' ,
361 'uploader' : 'Porsche' ,
362 'uploader_id' : 'porsche' ,
363 'timestamp' : 1387486713 ,
364 'upload_date' : '20131219' ,
366 expect_info_dict ( self
, EXPECTED
, test_video
)
368 def test_CSpan_playlist ( self
):
372 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall' )
373 self
. assertIsPlaylist ( result
)
374 self
. assertEqual ( result
[ 'id' ], '342759' )
376 result
[ 'title' ], 'General Motors Ignition Switch Recall' )
377 whole_duration
= sum ( e
[ 'duration' ] for e
in result
[ 'entries' ])
378 self
. assertEqual ( whole_duration
, 14855 )
380 def test_aol_playlist ( self
):
384 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316' )
385 self
. assertIsPlaylist ( result
)
386 self
. assertEqual ( result
[ 'id' ], '152147' )
388 result
[ 'title' ], 'Brace Yourself - Today \' s Weirdest News' )
389 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 10 )
391 def test_TeacherTubeUser ( self
):
393 ie
= TeacherTubeUserIE ( dl
)
394 result
= ie
. extract ( 'http://www.teachertube.com/user/profile/rbhagwati2' )
395 self
. assertIsPlaylist ( result
)
396 self
. assertEqual ( result
[ 'id' ], 'rbhagwati2' )
397 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 179 )
399 if __name__
== '__main__' :