]>
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 FakeYDL
15 from youtube_dl
. extractor
import (
16 AcademicEarthCourseIE
,
17 DailymotionPlaylistIE
,
39 class TestPlaylists ( unittest
. TestCase
):
40 def assertIsPlaylist ( self
, info
):
41 """Make sure the info has '_type' set to 'playlist'"""
42 self
. assertEqual ( info
[ '_type' ], 'playlist' )
44 def test_dailymotion_playlist ( self
):
46 ie
= DailymotionPlaylistIE ( dl
)
47 result
= ie
. extract ( 'http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q' )
48 self
. assertIsPlaylist ( result
)
49 self
. assertEqual ( result
[ 'title' ], 'SPORT' )
50 self
. assertTrue ( len ( result
[ 'entries' ]) > 20 )
52 def test_dailymotion_user ( self
):
54 ie
= DailymotionUserIE ( dl
)
55 result
= ie
. extract ( 'http://www.dailymotion.com/user/generation-quoi/' )
56 self
. assertIsPlaylist ( result
)
57 self
. assertEqual ( result
[ 'title' ], 'Génération Quoi' )
58 self
. assertTrue ( len ( result
[ 'entries' ]) >= 26 )
60 def test_vimeo_channel ( self
):
62 ie
= VimeoChannelIE ( dl
)
63 result
= ie
. extract ( 'http://vimeo.com/channels/tributes' )
64 self
. assertIsPlaylist ( result
)
65 self
. assertEqual ( result
[ 'title' ], 'Vimeo Tributes' )
66 self
. assertTrue ( len ( result
[ 'entries' ]) > 24 )
68 def test_vimeo_user ( self
):
71 result
= ie
. extract ( 'http://vimeo.com/nkistudio/videos' )
72 self
. assertIsPlaylist ( result
)
73 self
. assertEqual ( result
[ 'title' ], 'Nki' )
74 self
. assertTrue ( len ( result
[ 'entries' ]) > 65 )
76 def test_vimeo_album ( self
):
79 result
= ie
. extract ( 'http://vimeo.com/album/2632481' )
80 self
. assertIsPlaylist ( result
)
81 self
. assertEqual ( result
[ 'title' ], 'Staff Favorites: November 2013' )
82 self
. assertTrue ( len ( result
[ 'entries' ]) > 12 )
84 def test_vimeo_groups ( self
):
86 ie
= VimeoGroupsIE ( dl
)
87 result
= ie
. extract ( 'http://vimeo.com/groups/rolexawards' )
88 self
. assertIsPlaylist ( result
)
89 self
. assertEqual ( result
[ 'title' ], 'Rolex Awards for Enterprise' )
90 self
. assertTrue ( len ( result
[ 'entries' ]) > 72 )
92 def test_ustream_channel ( self
):
94 ie
= UstreamChannelIE ( dl
)
95 result
= ie
. extract ( 'http://www.ustream.tv/channel/young-americans-for-liberty' )
96 self
. assertIsPlaylist ( result
)
97 self
. assertEqual ( result
[ 'id' ], '5124905' )
98 self
. assertTrue ( len ( result
[ 'entries' ]) >= 11 )
100 def test_soundcloud_set ( self
):
102 ie
= SoundcloudSetIE ( dl
)
103 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep' )
104 self
. assertIsPlaylist ( result
)
105 self
. assertEqual ( result
[ 'title' ], 'The Royal Concept EP' )
106 self
. assertTrue ( len ( result
[ 'entries' ]) >= 6 )
108 def test_soundcloud_user ( self
):
110 ie
= SoundcloudUserIE ( dl
)
111 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band' )
112 self
. assertIsPlaylist ( result
)
113 self
. assertEqual ( result
[ 'id' ], '9615865' )
114 self
. assertTrue ( len ( result
[ 'entries' ]) >= 12 )
116 def test_livestream_event ( self
):
118 ie
= LivestreamIE ( dl
)
119 result
= ie
. extract ( 'http://new.livestream.com/tedx/cityenglish' )
120 self
. assertIsPlaylist ( result
)
121 self
. assertEqual ( result
[ 'title' ], 'TEDCity2.0 (English)' )
122 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
124 def test_nhl_videocenter ( self
):
126 ie
= NHLVideocenterIE ( dl
)
127 result
= ie
. extract ( 'http://video.canucks.nhl.com/videocenter/console?catid=999' )
128 self
. assertIsPlaylist ( result
)
129 self
. assertEqual ( result
[ 'id' ], '999' )
130 self
. assertEqual ( result
[ 'title' ], 'Highlights' )
131 self
. assertEqual ( len ( result
[ 'entries' ]), 12 )
133 def test_bambuser_channel ( self
):
135 ie
= BambuserChannelIE ( dl
)
136 result
= ie
. extract ( 'http://bambuser.com/channel/pixelversity' )
137 self
. assertIsPlaylist ( result
)
138 self
. assertEqual ( result
[ 'title' ], 'pixelversity' )
139 self
. assertTrue ( len ( result
[ 'entries' ]) >= 60 )
141 def test_bandcamp_album ( self
):
143 ie
= BandcampAlbumIE ( dl
)
144 result
= ie
. extract ( 'http://mpallante.bandcamp.com/album/nightmare-night-ep' )
145 self
. assertIsPlaylist ( result
)
146 self
. assertEqual ( result
[ 'title' ], 'Nightmare Night EP' )
147 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
149 def test_smotri_community ( self
):
151 ie
= SmotriCommunityIE ( dl
)
152 result
= ie
. extract ( 'http://smotri.com/community/video/kommuna' )
153 self
. assertIsPlaylist ( result
)
154 self
. assertEqual ( result
[ 'id' ], 'kommuna' )
155 self
. assertEqual ( result
[ 'title' ], 'КПРФ' )
156 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
158 def test_smotri_user ( self
):
160 ie
= SmotriUserIE ( dl
)
161 result
= ie
. extract ( 'http://smotri.com/user/inspector' )
162 self
. assertIsPlaylist ( result
)
163 self
. assertEqual ( result
[ 'id' ], 'inspector' )
164 self
. assertEqual ( result
[ 'title' ], 'Inspector' )
165 self
. assertTrue ( len ( result
[ 'entries' ]) >= 9 )
167 def test_AcademicEarthCourse ( self
):
169 ie
= AcademicEarthCourseIE ( dl
)
170 result
= ie
. extract ( 'http://academicearth.org/courses/building-dynamic-websites/' )
171 self
. assertIsPlaylist ( result
)
172 self
. assertEqual ( result
[ 'id' ], 'building-dynamic-websites' )
173 self
. assertEqual ( result
[ 'title' ], 'Building Dynamic Websites' )
174 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." )
175 self
. assertEqual ( len ( result
[ 'entries' ]), 10 )
177 def test_ivi_compilation ( self
):
179 ie
= IviCompilationIE ( dl
)
180 result
= ie
. extract ( 'http://www.ivi.ru/watch/dezhurnyi_angel' )
181 self
. assertIsPlaylist ( result
)
182 self
. assertEqual ( result
[ 'id' ], 'dezhurnyi_angel' )
183 self
. assertEqual ( result
[ 'title' ], 'Дежурный ангел (2010 - 2012)' )
184 self
. assertTrue ( len ( result
[ 'entries' ]) >= 36 )
186 def test_ivi_compilation_season ( self
):
188 ie
= IviCompilationIE ( dl
)
189 result
= ie
. extract ( 'http://www.ivi.ru/watch/dezhurnyi_angel/season2' )
190 self
. assertIsPlaylist ( result
)
191 self
. assertEqual ( result
[ 'id' ], 'dezhurnyi_angel/season2' )
192 self
. assertEqual ( result
[ 'title' ], 'Дежурный ангел (2010 - 2012) 2 сезон' )
193 self
. assertTrue ( len ( result
[ 'entries' ]) >= 20 )
195 def test_imdb_list ( self
):
198 result
= ie
. extract ( 'http://www.imdb.com/list/sMjedvGDd8U' )
199 self
. assertIsPlaylist ( result
)
200 self
. assertEqual ( result
[ 'id' ], 'sMjedvGDd8U' )
201 self
. assertEqual ( result
[ 'title' ], 'Animated and Family Films' )
202 self
. assertTrue ( len ( result
[ 'entries' ]) >= 48 )
204 def test_khanacademy_topic ( self
):
206 ie
= KhanAcademyIE ( dl
)
207 result
= ie
. extract ( 'https://www.khanacademy.org/math/applied-math/cryptography' )
208 self
. assertIsPlaylist ( result
)
209 self
. assertEqual ( result
[ 'id' ], 'cryptography' )
210 self
. assertEqual ( result
[ 'title' ], 'Journey into cryptography' )
211 self
. assertEqual ( result
[ 'description' ], 'How have humans protected their secret messages through history? What has changed today?' )
212 self
. assertTrue ( len ( result
[ 'entries' ]) >= 3 )
214 def test_EveryonesMixtape ( self
):
216 ie
= EveryonesMixtapeIE ( dl
)
217 result
= ie
. extract ( 'http://everyonesmixtape.com/#/mix/m7m0jJAbMQi' )
218 self
. assertIsPlaylist ( result
)
219 self
. assertEqual ( result
[ 'id' ], 'm7m0jJAbMQi' )
220 self
. assertEqual ( result
[ 'title' ], 'Driving' )
221 self
. assertEqual ( len ( result
[ 'entries' ]), 24 )
224 if __name__
== '__main__' :