]>
jfr.im git - yt-dlp.git/blob - test/test_playlists.py
5 # Add new tests to the extractors themselves, like this:
7 # 'url': 'http://example.com/playlist/42',
8 # 'playlist_mincount': 99,
11 # 'title': 'Playlist number forty-two',
15 from __future__
import unicode_literals
17 # Allow direct execution
21 sys
. path
. insert ( 0 , os
. path
. dirname ( os
. path
. dirname ( os
. path
. abspath ( __file__
))))
23 from test
. helper
import (
30 from youtube_dl
. extractor
import (
31 AcademicEarthCourseIE
,
32 DailymotionPlaylistIE
,
68 class TestPlaylists ( unittest
. TestCase
):
69 def assertIsPlaylist ( self
, info
):
70 """Make sure the info has '_type' set to 'playlist'"""
71 self
. assertEqual ( info
[ '_type' ], 'playlist' )
73 def test_dailymotion_playlist ( self
):
75 ie
= DailymotionPlaylistIE ( dl
)
76 result
= ie
. extract ( 'http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q' )
77 self
. assertIsPlaylist ( result
)
78 self
. assertEqual ( result
[ 'title' ], 'SPORT' )
79 self
. assertTrue ( len ( result
[ 'entries' ]) > 20 )
81 def test_dailymotion_user ( self
):
83 ie
= DailymotionUserIE ( dl
)
84 result
= ie
. extract ( 'https://www.dailymotion.com/user/nqtv' )
85 self
. assertIsPlaylist ( result
)
86 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 100 )
87 self
. assertEqual ( result
[ 'title' ], 'Rémi Gaillard' )
89 def test_vimeo_channel ( self
):
91 ie
= VimeoChannelIE ( dl
)
92 result
= ie
. extract ( 'http://vimeo.com/channels/tributes' )
93 self
. assertIsPlaylist ( result
)
94 self
. assertEqual ( result
[ 'title' ], 'Vimeo Tributes' )
95 self
. assertTrue ( len ( result
[ 'entries' ]) > 24 )
97 def test_vimeo_user ( self
):
100 result
= ie
. extract ( 'http://vimeo.com/nkistudio/videos' )
101 self
. assertIsPlaylist ( result
)
102 self
. assertEqual ( result
[ 'title' ], 'Nki' )
103 self
. assertTrue ( len ( result
[ 'entries' ]) > 65 )
105 def test_vimeo_album ( self
):
107 ie
= VimeoAlbumIE ( dl
)
108 result
= ie
. extract ( 'http://vimeo.com/album/2632481' )
109 self
. assertIsPlaylist ( result
)
110 self
. assertEqual ( result
[ 'title' ], 'Staff Favorites: November 2013' )
111 self
. assertTrue ( len ( result
[ 'entries' ]) > 12 )
113 def test_vimeo_groups ( self
):
115 ie
= VimeoGroupsIE ( dl
)
116 result
= ie
. extract ( 'http://vimeo.com/groups/rolexawards' )
117 self
. assertIsPlaylist ( result
)
118 self
. assertEqual ( result
[ 'title' ], 'Rolex Awards for Enterprise' )
119 self
. assertTrue ( len ( result
[ 'entries' ]) > 72 )
121 def test_vine_user ( self
):
124 result
= ie
. extract ( 'https://vine.co/Visa' )
125 self
. assertIsPlaylist ( result
)
126 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 47 )
128 def test_ustream_channel ( self
):
130 ie
= UstreamChannelIE ( dl
)
131 result
= ie
. extract ( 'http://www.ustream.tv/channel/channeljapan' )
132 self
. assertIsPlaylist ( result
)
133 self
. assertEqual ( result
[ 'id' ], '10874166' )
134 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 54 )
136 def test_soundcloud_set ( self
):
138 ie
= SoundcloudSetIE ( dl
)
139 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep' )
140 self
. assertIsPlaylist ( result
)
141 self
. assertEqual ( result
[ 'title' ], 'The Royal Concept EP' )
142 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 6 )
144 def test_soundcloud_user ( self
):
146 ie
= SoundcloudUserIE ( dl
)
147 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band' )
148 self
. assertIsPlaylist ( result
)
149 self
. assertEqual ( result
[ 'id' ], '9615865' )
150 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 12 )
152 def test_soundcloud_likes ( self
):
154 ie
= SoundcloudUserIE ( dl
)
155 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band/likes' )
156 self
. assertIsPlaylist ( result
)
157 self
. assertEqual ( result
[ 'id' ], '9615865' )
158 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 1 )
160 def test_soundcloud_playlist ( self
):
162 ie
= SoundcloudPlaylistIE ( dl
)
163 result
= ie
. extract ( 'http://api.soundcloud.com/playlists/4110309' )
164 self
. assertIsPlaylist ( result
)
165 self
. assertEqual ( result
[ 'id' ], '4110309' )
166 self
. assertEqual ( result
[ 'title' ], 'TILT Brass - Bowery Poetry Club, August \' 03 [Non-Site SCR 02]' )
168 self
, result
[ 'description' ], r
'.*?TILT Brass - Bowery Poetry Club' )
169 self
. assertEqual ( len ( result
[ 'entries' ]), 6 )
171 def test_livestream_event ( self
):
173 ie
= LivestreamIE ( dl
)
174 result
= ie
. extract ( 'http://new.livestream.com/tedx/cityenglish' )
175 self
. assertIsPlaylist ( result
)
176 self
. assertEqual ( result
[ 'title' ], 'TEDCity2.0 (English)' )
177 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 4 )
179 def test_livestreamoriginal_folder ( self
):
181 ie
= LivestreamOriginalIE ( dl
)
182 result
= ie
. extract ( 'https://www.livestream.com/newplay/folder?dirId=a07bf706-d0e4-4e75-a747-b021d84f2fd3' )
183 self
. assertIsPlaylist ( result
)
184 self
. assertEqual ( result
[ 'id' ], 'a07bf706-d0e4-4e75-a747-b021d84f2fd3' )
185 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 28 )
187 def test_nhl_videocenter ( self
):
189 ie
= NHLVideocenterIE ( dl
)
190 result
= ie
. extract ( 'http://video.canucks.nhl.com/videocenter/console?catid=999' )
191 self
. assertIsPlaylist ( result
)
192 self
. assertEqual ( result
[ 'id' ], '999' )
193 self
. assertEqual ( result
[ 'title' ], 'Highlights' )
194 self
. assertEqual ( len ( result
[ 'entries' ]), 12 )
196 def test_bambuser_channel ( self
):
198 ie
= BambuserChannelIE ( dl
)
199 result
= ie
. extract ( 'http://bambuser.com/channel/pixelversity' )
200 self
. assertIsPlaylist ( result
)
201 self
. assertEqual ( result
[ 'title' ], 'pixelversity' )
202 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 60 )
204 def test_bandcamp_album ( self
):
206 ie
= BandcampAlbumIE ( dl
)
207 result
= ie
. extract ( 'http://nightbringer.bandcamp.com/album/hierophany-of-the-open-grave' )
208 self
. assertIsPlaylist ( result
)
209 self
. assertEqual ( result
[ 'title' ], 'Hierophany of the Open Grave' )
210 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 9 )
212 def test_smotri_community ( self
):
214 ie
= SmotriCommunityIE ( dl
)
215 result
= ie
. extract ( 'http://smotri.com/community/video/kommuna' )
216 self
. assertIsPlaylist ( result
)
217 self
. assertEqual ( result
[ 'id' ], 'kommuna' )
218 self
. assertEqual ( result
[ 'title' ], 'КПРФ' )
219 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 4 )
221 def test_smotri_user ( self
):
223 ie
= SmotriUserIE ( dl
)
224 result
= ie
. extract ( 'http://smotri.com/user/inspector' )
225 self
. assertIsPlaylist ( result
)
226 self
. assertEqual ( result
[ 'id' ], 'inspector' )
227 self
. assertEqual ( result
[ 'title' ], 'Inspector' )
228 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 9 )
230 def test_AcademicEarthCourse ( self
):
232 ie
= AcademicEarthCourseIE ( dl
)
233 result
= ie
. extract ( 'http://academicearth.org/playlists/laws-of-nature/' )
234 self
. assertIsPlaylist ( result
)
235 self
. assertEqual ( result
[ 'id' ], 'laws-of-nature' )
236 self
. assertEqual ( result
[ 'title' ], 'Laws of Nature' )
237 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.")
238 self
. assertEqual ( len ( result
[ 'entries' ]), 4 )
240 def test_ivi_compilation ( self
):
242 ie
= IviCompilationIE ( dl
)
243 result
= ie
. extract ( 'http://www.ivi.ru/watch/dvoe_iz_lartsa' )
244 self
. assertIsPlaylist ( result
)
245 self
. assertEqual ( result
[ 'id' ], 'dvoe_iz_lartsa' )
246 self
. assertEqual ( result
[ 'title' ], 'Двое из ларца (2006 - 2008)' )
247 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 24 )
249 def test_ivi_compilation_season ( self
):
251 ie
= IviCompilationIE ( dl
)
252 result
= ie
. extract ( 'http://www.ivi.ru/watch/dvoe_iz_lartsa/season1' )
253 self
. assertIsPlaylist ( result
)
254 self
. assertEqual ( result
[ 'id' ], 'dvoe_iz_lartsa/season1' )
255 self
. assertEqual ( result
[ 'title' ], 'Двое из ларца (2006 - 2008) 1 сезон' )
256 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 12 )
258 def test_imdb_list ( self
):
261 result
= ie
. extract ( 'http://www.imdb.com/list/JFs9NWw6XI0' )
262 self
. assertIsPlaylist ( result
)
263 self
. assertEqual ( result
[ 'id' ], 'JFs9NWw6XI0' )
264 self
. assertEqual ( result
[ 'title' ], 'March 23, 2012 Releases' )
265 self
. assertEqual ( len ( result
[ 'entries' ]), 7 )
267 def test_khanacademy_topic ( self
):
269 ie
= KhanAcademyIE ( dl
)
270 result
= ie
. extract ( 'https://www.khanacademy.org/math/applied-math/cryptography' )
271 self
. assertIsPlaylist ( result
)
272 self
. assertEqual ( result
[ 'id' ], 'cryptography' )
273 self
. assertEqual ( result
[ 'title' ], 'Journey into cryptography' )
274 self
. assertEqual ( result
[ 'description' ], 'How have humans protected their secret messages through history? What has changed today?' )
275 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 3 )
277 def test_EveryonesMixtape ( self
):
279 ie
= EveryonesMixtapeIE ( dl
)
280 result
= ie
. extract ( 'http://everyonesmixtape.com/#/mix/m7m0jJAbMQi' )
281 self
. assertIsPlaylist ( result
)
282 self
. assertEqual ( result
[ 'id' ], 'm7m0jJAbMQi' )
283 self
. assertEqual ( result
[ 'title' ], 'Driving' )
284 self
. assertEqual ( len ( result
[ 'entries' ]), 24 )
286 def test_rutube_channel ( self
):
288 ie
= RutubeChannelIE ( dl
)
289 result
= ie
. extract ( 'http://rutube.ru/tags/video/1800/' )
290 self
. assertIsPlaylist ( result
)
291 self
. assertEqual ( result
[ 'id' ], '1800' )
292 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 68 )
294 def test_rutube_person ( self
):
296 ie
= RutubePersonIE ( dl
)
297 result
= ie
. extract ( 'http://rutube.ru/video/person/313878/' )
298 self
. assertIsPlaylist ( result
)
299 self
. assertEqual ( result
[ 'id' ], '313878' )
300 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 37 )
302 def test_multiple_brightcove_videos ( self
):
303 # https://github.com/rg3/youtube-dl/issues/2283
306 result
= ie
. extract ( 'http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html' )
307 self
. assertIsPlaylist ( result
)
308 self
. assertEqual ( result
[ 'id' ], 'always-never-nuclear-command-and-control' )
309 self
. assertEqual ( result
[ 'title' ], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker' )
310 self
. assertEqual ( len ( result
[ 'entries' ]), 3 )
312 def test_GoogleSearch ( self
):
314 ie
= GoogleSearchIE ( dl
)
315 result
= ie
. extract ( 'gvsearch15:python language' )
316 self
. assertIsPlaylist ( result
)
317 self
. assertEqual ( result
[ 'id' ], 'python language' )
318 self
. assertEqual ( result
[ 'title' ], 'python language' )
319 self
. assertEqual ( len ( result
[ 'entries' ]), 15 )
321 def test_generic_rss_feed ( self
):
324 result
= ie
. extract ( 'http://phihag.de/2014/youtube-dl/rss.xml' )
325 self
. assertIsPlaylist ( result
)
326 self
. assertEqual ( result
[ 'id' ], 'http://phihag.de/2014/youtube-dl/rss.xml' )
327 self
. assertEqual ( result
[ 'title' ], 'Zero Punctuation' )
328 self
. assertTrue ( len ( result
[ 'entries' ]) > 10 )
330 def test_ted_playlist ( self
):
333 result
= ie
. extract ( 'http://www.ted.com/playlists/who_are_the_hackers' )
334 self
. assertIsPlaylist ( result
)
335 self
. assertEqual ( result
[ 'id' ], '10' )
336 self
. assertEqual ( result
[ 'title' ], 'Who are the hackers?' )
337 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 6 )
339 def test_toypics_user ( self
):
341 ie
= ToypicsUserIE ( dl
)
342 result
= ie
. extract ( 'http://videos.toypics.net/Mikey' )
343 self
. assertIsPlaylist ( result
)
344 self
. assertEqual ( result
[ 'id' ], 'Mikey' )
345 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 17 )
347 def test_xtube_user ( self
):
350 result
= ie
. extract ( 'http://www.xtube.com/community/profile.php?user=greenshowers' )
351 self
. assertIsPlaylist ( result
)
352 self
. assertEqual ( result
[ 'id' ], 'greenshowers' )
353 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 155 )
355 def test_InstagramUser ( self
):
357 ie
= InstagramUserIE ( dl
)
358 result
= ie
. extract ( 'http://instagram.com/porsche' )
359 self
. assertIsPlaylist ( result
)
360 self
. assertEqual ( result
[ 'id' ], 'porsche' )
361 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 2 )
363 e
for e
in result
[ 'entries' ]
364 if e
[ 'id' ] == '614605558512799803_462752227' )
365 dl
. add_default_extra_info ( test_video
, ie
, '(irrelevant URL)' )
366 dl
. process_video_result ( test_video
, download
= False )
368 'id' : '614605558512799803_462752227' ,
370 'title' : '#Porsche Intelligent Performance.' ,
371 'thumbnail' : 're:^https?://.*\.jpg' ,
372 'uploader' : 'Porsche' ,
373 'uploader_id' : 'porsche' ,
374 'timestamp' : 1387486713 ,
375 'upload_date' : '20131219' ,
377 expect_info_dict ( self
, EXPECTED
, test_video
)
379 def test_CSpan_playlist ( self
):
383 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall' )
384 self
. assertIsPlaylist ( result
)
385 self
. assertEqual ( result
[ 'id' ], '342759' )
387 result
[ 'title' ], 'General Motors Ignition Switch Recall' )
388 whole_duration
= sum ( e
[ 'duration' ] for e
in result
[ 'entries' ])
389 self
. assertEqual ( whole_duration
, 14855 )
391 def test_aol_playlist ( self
):
395 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316' )
396 self
. assertIsPlaylist ( result
)
397 self
. assertEqual ( result
[ 'id' ], '152147' )
399 result
[ 'title' ], 'Brace Yourself - Today \' s Weirdest News' )
400 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 10 )
402 def test_TeacherTubeUser ( self
):
404 ie
= TeacherTubeUserIE ( dl
)
405 result
= ie
. extract ( 'http://www.teachertube.com/user/profile/rbhagwati2' )
406 self
. assertIsPlaylist ( result
)
407 self
. assertEqual ( result
[ 'id' ], 'rbhagwati2' )
408 assertGreaterEqual ( self
, len ( result
[ 'entries' ]), 179 )
410 if __name__
== '__main__' :