]> Raphaël G. Git Repositories - youtubedl/blob - test/test_playlists.py
1de9e8ec1ab1a9f636a8b3220d6614a663ba94b2
[youtubedl] / test / test_playlists.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3
4 from __future__ import unicode_literals
5
6 # Allow direct execution
7 import os
8 import sys
9 import unittest
10 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11
12 from test.helper import FakeYDL
13
14
15 from youtube_dl.extractor import (
16 AcademicEarthCourseIE,
17 DailymotionPlaylistIE,
18 DailymotionUserIE,
19 VimeoChannelIE,
20 VimeoUserIE,
21 VimeoAlbumIE,
22 VimeoGroupsIE,
23 UstreamChannelIE,
24 SoundcloudSetIE,
25 SoundcloudUserIE,
26 LivestreamIE,
27 NHLVideocenterIE,
28 BambuserChannelIE,
29 BandcampAlbumIE,
30 SmotriCommunityIE,
31 SmotriUserIE,
32 IviCompilationIE,
33 ImdbListIE,
34 KhanAcademyIE,
35 EveryonesMixtapeIE,
36 RutubeChannelIE,
37 GoogleSearchIE,
38 GenericIE,
39 )
40
41
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')
46
47 def test_dailymotion_playlist(self):
48 dl = FakeYDL()
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)
54
55 def test_dailymotion_user(self):
56 dl = FakeYDL()
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)
62
63 def test_vimeo_channel(self):
64 dl = FakeYDL()
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)
70
71 def test_vimeo_user(self):
72 dl = FakeYDL()
73 ie = VimeoUserIE(dl)
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)
78
79 def test_vimeo_album(self):
80 dl = FakeYDL()
81 ie = VimeoAlbumIE(dl)
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)
86
87 def test_vimeo_groups(self):
88 dl = FakeYDL()
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)
94
95 def test_ustream_channel(self):
96 dl = FakeYDL()
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)
102
103 def test_soundcloud_set(self):
104 dl = FakeYDL()
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)
110
111 def test_soundcloud_user(self):
112 dl = FakeYDL()
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)
118
119 def test_livestream_event(self):
120 dl = FakeYDL()
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)
126
127 def test_nhl_videocenter(self):
128 dl = FakeYDL()
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)
135
136 def test_bambuser_channel(self):
137 dl = FakeYDL()
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)
143
144 def test_bandcamp_album(self):
145 dl = FakeYDL()
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)
151
152 def test_smotri_community(self):
153 dl = FakeYDL()
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)
160
161 def test_smotri_user(self):
162 dl = FakeYDL()
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)
169
170 def test_AcademicEarthCourse(self):
171 dl = FakeYDL()
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)
179
180 def test_ivi_compilation(self):
181 dl = FakeYDL()
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)
188
189 def test_ivi_compilation_season(self):
190 dl = FakeYDL()
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)
197
198 def test_imdb_list(self):
199 dl = FakeYDL()
200 ie = ImdbListIE(dl)
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)
206
207 def test_khanacademy_topic(self):
208 dl = FakeYDL()
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)
216
217 def test_EveryonesMixtape(self):
218 dl = FakeYDL()
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)
225
226 def test_rutube_channel(self):
227 dl = FakeYDL()
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)
233
234 def test_multiple_brightcove_videos(self):
235 # https://github.com/rg3/youtube-dl/issues/2283
236 dl = FakeYDL()
237 ie = GenericIE(dl)
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)
243
244 def test_GoogleSearch(self):
245 dl = FakeYDL()
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)
252
253 if __name__ == '__main__':
254 unittest.main()