]>
Raphaël G. Git Repositories - youtubedl/blob - test/test_playlists.py
1de9e8ec1ab1a9f636a8b3220d6614a663ba94b2
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 FakeYDL
15 from youtube_dl
. extractor
import (
16 AcademicEarthCourseIE
,
17 DailymotionPlaylistIE
,
42 class TestPlaylists ( unittest
. TestCase
):
43 def assertIsPlaylist ( self
, info
):
44 """Make sure the info has '_type' set to 'playlist'"""
45 self
. assertEqual ( info
[ '_type' ], 'playlist' )
47 def test_dailymotion_playlist ( self
):
49 ie
= DailymotionPlaylistIE ( dl
)
50 result
= ie
. extract ( 'http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q' )
51 self
. assertIsPlaylist ( result
)
52 self
. assertEqual ( result
[ 'title' ], 'SPORT' )
53 self
. assertTrue ( len ( result
[ 'entries' ]) > 20 )
55 def test_dailymotion_user ( self
):
57 ie
= DailymotionUserIE ( dl
)
58 result
= ie
. extract ( 'https://www.dailymotion.com/user/nqtv' )
59 self
. assertIsPlaylist ( result
)
60 self
. assertEqual ( result
[ 'title' ], 'Rémi Gaillard' )
61 self
. assertTrue ( len ( result
[ 'entries' ]) >= 100 )
63 def test_vimeo_channel ( self
):
65 ie
= VimeoChannelIE ( dl
)
66 result
= ie
. extract ( 'http://vimeo.com/channels/tributes' )
67 self
. assertIsPlaylist ( result
)
68 self
. assertEqual ( result
[ 'title' ], 'Vimeo Tributes' )
69 self
. assertTrue ( len ( result
[ 'entries' ]) > 24 )
71 def test_vimeo_user ( self
):
74 result
= ie
. extract ( 'http://vimeo.com/nkistudio/videos' )
75 self
. assertIsPlaylist ( result
)
76 self
. assertEqual ( result
[ 'title' ], 'Nki' )
77 self
. assertTrue ( len ( result
[ 'entries' ]) > 65 )
79 def test_vimeo_album ( self
):
82 result
= ie
. extract ( 'http://vimeo.com/album/2632481' )
83 self
. assertIsPlaylist ( result
)
84 self
. assertEqual ( result
[ 'title' ], 'Staff Favorites: November 2013' )
85 self
. assertTrue ( len ( result
[ 'entries' ]) > 12 )
87 def test_vimeo_groups ( self
):
89 ie
= VimeoGroupsIE ( dl
)
90 result
= ie
. extract ( 'http://vimeo.com/groups/rolexawards' )
91 self
. assertIsPlaylist ( result
)
92 self
. assertEqual ( result
[ 'title' ], 'Rolex Awards for Enterprise' )
93 self
. assertTrue ( len ( result
[ 'entries' ]) > 72 )
95 def test_ustream_channel ( self
):
97 ie
= UstreamChannelIE ( dl
)
98 result
= ie
. extract ( 'http://www.ustream.tv/channel/young-americans-for-liberty' )
99 self
. assertIsPlaylist ( result
)
100 self
. assertEqual ( result
[ 'id' ], '5124905' )
101 self
. assertTrue ( len ( result
[ 'entries' ]) >= 11 )
103 def test_soundcloud_set ( self
):
105 ie
= SoundcloudSetIE ( dl
)
106 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep' )
107 self
. assertIsPlaylist ( result
)
108 self
. assertEqual ( result
[ 'title' ], 'The Royal Concept EP' )
109 self
. assertTrue ( len ( result
[ 'entries' ]) >= 6 )
111 def test_soundcloud_user ( self
):
113 ie
= SoundcloudUserIE ( dl
)
114 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band' )
115 self
. assertIsPlaylist ( result
)
116 self
. assertEqual ( result
[ 'id' ], '9615865' )
117 self
. assertTrue ( len ( result
[ 'entries' ]) >= 12 )
119 def test_livestream_event ( self
):
121 ie
= LivestreamIE ( dl
)
122 result
= ie
. extract ( 'http://new.livestream.com/tedx/cityenglish' )
123 self
. assertIsPlaylist ( result
)
124 self
. assertEqual ( result
[ 'title' ], 'TEDCity2.0 (English)' )
125 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
127 def test_nhl_videocenter ( self
):
129 ie
= NHLVideocenterIE ( dl
)
130 result
= ie
. extract ( 'http://video.canucks.nhl.com/videocenter/console?catid=999' )
131 self
. assertIsPlaylist ( result
)
132 self
. assertEqual ( result
[ 'id' ], '999' )
133 self
. assertEqual ( result
[ 'title' ], 'Highlights' )
134 self
. assertEqual ( len ( result
[ 'entries' ]), 12 )
136 def test_bambuser_channel ( self
):
138 ie
= BambuserChannelIE ( dl
)
139 result
= ie
. extract ( 'http://bambuser.com/channel/pixelversity' )
140 self
. assertIsPlaylist ( result
)
141 self
. assertEqual ( result
[ 'title' ], 'pixelversity' )
142 self
. assertTrue ( len ( result
[ 'entries' ]) >= 60 )
144 def test_bandcamp_album ( self
):
146 ie
= BandcampAlbumIE ( dl
)
147 result
= ie
. extract ( 'http://mpallante.bandcamp.com/album/nightmare-night-ep' )
148 self
. assertIsPlaylist ( result
)
149 self
. assertEqual ( result
[ 'title' ], 'Nightmare Night EP' )
150 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
152 def test_smotri_community ( self
):
154 ie
= SmotriCommunityIE ( dl
)
155 result
= ie
. extract ( 'http://smotri.com/community/video/kommuna' )
156 self
. assertIsPlaylist ( result
)
157 self
. assertEqual ( result
[ 'id' ], 'kommuna' )
158 self
. assertEqual ( result
[ 'title' ], 'КПРФ' )
159 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
161 def test_smotri_user ( self
):
163 ie
= SmotriUserIE ( dl
)
164 result
= ie
. extract ( 'http://smotri.com/user/inspector' )
165 self
. assertIsPlaylist ( result
)
166 self
. assertEqual ( result
[ 'id' ], 'inspector' )
167 self
. assertEqual ( result
[ 'title' ], 'Inspector' )
168 self
. assertTrue ( len ( result
[ 'entries' ]) >= 9 )
170 def test_AcademicEarthCourse ( self
):
172 ie
= AcademicEarthCourseIE ( dl
)
173 result
= ie
. extract ( 'http://academicearth.org/courses/building-dynamic-websites/' )
174 self
. assertIsPlaylist ( result
)
175 self
. assertEqual ( result
[ 'id' ], 'building-dynamic-websites' )
176 self
. assertEqual ( result
[ 'title' ], 'Building Dynamic Websites' )
177 self
. assertEqual ( result
[ 'description' ], 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." )
178 self
. assertEqual ( len ( result
[ 'entries' ]), 10 )
180 def test_ivi_compilation ( self
):
182 ie
= IviCompilationIE ( dl
)
183 result
= ie
. extract ( 'http://www.ivi.ru/watch/dezhurnyi_angel' )
184 self
. assertIsPlaylist ( result
)
185 self
. assertEqual ( result
[ 'id' ], 'dezhurnyi_angel' )
186 self
. assertEqual ( result
[ 'title' ], 'Дежурный ангел (2010 - 2012)' )
187 self
. assertTrue ( len ( result
[ 'entries' ]) >= 36 )
189 def test_ivi_compilation_season ( self
):
191 ie
= IviCompilationIE ( dl
)
192 result
= ie
. extract ( 'http://www.ivi.ru/watch/dezhurnyi_angel/season2' )
193 self
. assertIsPlaylist ( result
)
194 self
. assertEqual ( result
[ 'id' ], 'dezhurnyi_angel/season2' )
195 self
. assertEqual ( result
[ 'title' ], 'Дежурный ангел (2010 - 2012) 2 сезон' )
196 self
. assertTrue ( len ( result
[ 'entries' ]) >= 20 )
198 def test_imdb_list ( self
):
201 result
= ie
. extract ( 'http://www.imdb.com/list/JFs9NWw6XI0' )
202 self
. assertIsPlaylist ( result
)
203 self
. assertEqual ( result
[ 'id' ], 'JFs9NWw6XI0' )
204 self
. assertEqual ( result
[ 'title' ], 'March 23, 2012 Releases' )
205 self
. assertEqual ( len ( result
[ 'entries' ]), 7 )
207 def test_khanacademy_topic ( self
):
209 ie
= KhanAcademyIE ( dl
)
210 result
= ie
. extract ( 'https://www.khanacademy.org/math/applied-math/cryptography' )
211 self
. assertIsPlaylist ( result
)
212 self
. assertEqual ( result
[ 'id' ], 'cryptography' )
213 self
. assertEqual ( result
[ 'title' ], 'Journey into cryptography' )
214 self
. assertEqual ( result
[ 'description' ], 'How have humans protected their secret messages through history? What has changed today?' )
215 self
. assertTrue ( len ( result
[ 'entries' ]) >= 3 )
217 def test_EveryonesMixtape ( self
):
219 ie
= EveryonesMixtapeIE ( dl
)
220 result
= ie
. extract ( 'http://everyonesmixtape.com/#/mix/m7m0jJAbMQi' )
221 self
. assertIsPlaylist ( result
)
222 self
. assertEqual ( result
[ 'id' ], 'm7m0jJAbMQi' )
223 self
. assertEqual ( result
[ 'title' ], 'Driving' )
224 self
. assertEqual ( len ( result
[ 'entries' ]), 24 )
226 def test_rutube_channel ( self
):
228 ie
= RutubeChannelIE ( dl
)
229 result
= ie
. extract ( 'http://rutube.ru/tags/video/1409' )
230 self
. assertIsPlaylist ( result
)
231 self
. assertEqual ( result
[ 'id' ], '1409' )
232 self
. assertTrue ( len ( result
[ 'entries' ]) >= 34 )
234 def test_multiple_brightcove_videos ( self
):
235 # https://github.com/rg3/youtube-dl/issues/2283
238 result
= ie
. extract ( 'http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html' )
239 self
. assertIsPlaylist ( result
)
240 self
. assertEqual ( result
[ 'id' ], 'always-never-nuclear-command-and-control' )
241 self
. assertEqual ( result
[ 'title' ], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker' )
242 self
. assertEqual ( len ( result
[ 'entries' ]), 3 )
244 def test_GoogleSearch ( self
):
246 ie
= GoogleSearchIE ( dl
)
247 result
= ie
. extract ( 'gvsearch15:python language' )
248 self
. assertIsPlaylist ( result
)
249 self
. assertEqual ( result
[ 'id' ], 'python language' )
250 self
. assertEqual ( result
[ 'title' ], 'python language' )
251 self
. assertTrue ( len ( result
[ 'entries' ]) == 15 )
253 if __name__
== '__main__' :