]>
Raphaël G. Git Repositories - youtubedl/blob - test/test_playlists.py
5 # Allow direct execution
9 sys
. path
. insert ( 0 , os
. path
. dirname ( os
. path
. dirname ( os
. path
. abspath ( __file__
))))
11 from test
. helper
import FakeYDL
14 from youtube_dl
. extractor
import (
15 AcademicEarthCourseIE
,
16 DailymotionPlaylistIE
,
35 class TestPlaylists ( unittest
. TestCase
):
36 def assertIsPlaylist ( self
, info
):
37 """Make sure the info has '_type' set to 'playlist'"""
38 self
. assertEqual ( info
[ '_type' ], 'playlist' )
40 def test_dailymotion_playlist ( self
):
42 ie
= DailymotionPlaylistIE ( dl
)
43 result
= ie
. extract ( 'http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q' )
44 self
. assertIsPlaylist ( result
)
45 self
. assertEqual ( result
[ 'title' ], u
'SPORT' )
46 self
. assertTrue ( len ( result
[ 'entries' ]) > 20 )
48 def test_dailymotion_user ( self
):
50 ie
= DailymotionUserIE ( dl
)
51 result
= ie
. extract ( 'http://www.dailymotion.com/user/generation-quoi/' )
52 self
. assertIsPlaylist ( result
)
53 self
. assertEqual ( result
[ 'title' ], u
'Génération Quoi' )
54 self
. assertTrue ( len ( result
[ 'entries' ]) >= 26 )
56 def test_vimeo_channel ( self
):
58 ie
= VimeoChannelIE ( dl
)
59 result
= ie
. extract ( 'http://vimeo.com/channels/tributes' )
60 self
. assertIsPlaylist ( result
)
61 self
. assertEqual ( result
[ 'title' ], u
'Vimeo Tributes' )
62 self
. assertTrue ( len ( result
[ 'entries' ]) > 24 )
64 def test_vimeo_user ( self
):
67 result
= ie
. extract ( 'http://vimeo.com/nkistudio/videos' )
68 self
. assertIsPlaylist ( result
)
69 self
. assertEqual ( result
[ 'title' ], u
'Nki' )
70 self
. assertTrue ( len ( result
[ 'entries' ]) > 65 )
72 def test_vimeo_album ( self
):
75 result
= ie
. extract ( 'http://vimeo.com/album/2632481' )
76 self
. assertIsPlaylist ( result
)
77 self
. assertEqual ( result
[ 'title' ], u
'Staff Favorites: November 2013' )
78 self
. assertTrue ( len ( result
[ 'entries' ]) > 12 )
80 def test_vimeo_groups ( self
):
82 ie
= VimeoGroupsIE ( dl
)
83 result
= ie
. extract ( 'http://vimeo.com/groups/rolexawards' )
84 self
. assertIsPlaylist ( result
)
85 self
. assertEqual ( result
[ 'title' ], u
'Rolex Awards for Enterprise' )
86 self
. assertTrue ( len ( result
[ 'entries' ]) > 72 )
88 def test_ustream_channel ( self
):
90 ie
= UstreamChannelIE ( dl
)
91 result
= ie
. extract ( 'http://www.ustream.tv/channel/young-americans-for-liberty' )
92 self
. assertIsPlaylist ( result
)
93 self
. assertEqual ( result
[ 'id' ], u
'5124905' )
94 self
. assertTrue ( len ( result
[ 'entries' ]) >= 11 )
96 def test_soundcloud_set ( self
):
98 ie
= SoundcloudSetIE ( dl
)
99 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep' )
100 self
. assertIsPlaylist ( result
)
101 self
. assertEqual ( result
[ 'title' ], u
'The Royal Concept EP' )
102 self
. assertTrue ( len ( result
[ 'entries' ]) >= 6 )
104 def test_soundcloud_user ( self
):
106 ie
= SoundcloudUserIE ( dl
)
107 result
= ie
. extract ( 'https://soundcloud.com/the-concept-band' )
108 self
. assertIsPlaylist ( result
)
109 self
. assertEqual ( result
[ 'id' ], u
'9615865' )
110 self
. assertTrue ( len ( result
[ 'entries' ]) >= 12 )
112 def test_livestream_event ( self
):
114 ie
= LivestreamIE ( dl
)
115 result
= ie
. extract ( 'http://new.livestream.com/tedx/cityenglish' )
116 self
. assertIsPlaylist ( result
)
117 self
. assertEqual ( result
[ 'title' ], u
'TEDCity2.0 (English)' )
118 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
120 def test_nhl_videocenter ( self
):
122 ie
= NHLVideocenterIE ( dl
)
123 result
= ie
. extract ( 'http://video.canucks.nhl.com/videocenter/console?catid=999' )
124 self
. assertIsPlaylist ( result
)
125 self
. assertEqual ( result
[ 'id' ], u
'999' )
126 self
. assertEqual ( result
[ 'title' ], u
'Highlights' )
127 self
. assertEqual ( len ( result
[ 'entries' ]), 12 )
129 def test_bambuser_channel ( self
):
131 ie
= BambuserChannelIE ( dl
)
132 result
= ie
. extract ( 'http://bambuser.com/channel/pixelversity' )
133 self
. assertIsPlaylist ( result
)
134 self
. assertEqual ( result
[ 'title' ], u
'pixelversity' )
135 self
. assertTrue ( len ( result
[ 'entries' ]) >= 60 )
137 def test_bandcamp_album ( self
):
139 ie
= BandcampAlbumIE ( dl
)
140 result
= ie
. extract ( 'http://mpallante.bandcamp.com/album/nightmare-night-ep' )
141 self
. assertIsPlaylist ( result
)
142 self
. assertEqual ( result
[ 'title' ], u
'Nightmare Night EP' )
143 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
145 def test_smotri_community ( self
):
147 ie
= SmotriCommunityIE ( dl
)
148 result
= ie
. extract ( 'http://smotri.com/community/video/kommuna' )
149 self
. assertIsPlaylist ( result
)
150 self
. assertEqual ( result
[ 'id' ], u
'kommuna' )
151 self
. assertEqual ( result
[ 'title' ], u
'КПРФ' )
152 self
. assertTrue ( len ( result
[ 'entries' ]) >= 4 )
154 def test_smotri_user ( self
):
156 ie
= SmotriUserIE ( dl
)
157 result
= ie
. extract ( 'http://smotri.com/user/inspector' )
158 self
. assertIsPlaylist ( result
)
159 self
. assertEqual ( result
[ 'id' ], u
'inspector' )
160 self
. assertEqual ( result
[ 'title' ], u
'Inspector' )
161 self
. assertTrue ( len ( result
[ 'entries' ]) >= 9 )
163 def test_AcademicEarthCourse ( self
):
165 ie
= AcademicEarthCourseIE ( dl
)
166 result
= ie
. extract ( u
'http://academicearth.org/courses/building-dynamic-websites/' )
167 self
. assertIsPlaylist ( result
)
168 self
. assertEqual ( result
[ 'id' ], u
'building-dynamic-websites' )
169 self
. assertEqual ( result
[ 'title' ], u
'Building Dynamic Websites' )
170 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." )
171 self
. assertEqual ( len ( result
[ 'entries' ]), 10 )
173 def test_ivi_compilation ( self
):
175 ie
= IviCompilationIE ( dl
)
176 result
= ie
. extract ( 'http://www.ivi.ru/watch/dezhurnyi_angel' )
177 self
. assertIsPlaylist ( result
)
178 self
. assertEqual ( result
[ 'id' ], u
'dezhurnyi_angel' )
179 self
. assertEqual ( result
[ 'title' ], u
'Дежурный ангел (2010 - 2012)' )
180 self
. assertTrue ( len ( result
[ 'entries' ]) >= 36 )
182 def test_ivi_compilation_season ( self
):
184 ie
= IviCompilationIE ( dl
)
185 result
= ie
. extract ( 'http://www.ivi.ru/watch/dezhurnyi_angel/season2' )
186 self
. assertIsPlaylist ( result
)
187 self
. assertEqual ( result
[ 'id' ], u
'dezhurnyi_angel/season2' )
188 self
. assertEqual ( result
[ 'title' ], u
'Дежурный ангел (2010 - 2012) 2 сезон' )
189 self
. assertTrue ( len ( result
[ 'entries' ]) >= 20 )
192 if __name__
== '__main__' :