]> Raphaël G. Git Repositories - youtubedl/blob - test/test_playlists.py
Merge tag 'upstream/2014.01.17.2'
[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 )
37
38
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')
43
44 def test_dailymotion_playlist(self):
45 dl = FakeYDL()
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)
51
52 def test_dailymotion_user(self):
53 dl = FakeYDL()
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)
59
60 def test_vimeo_channel(self):
61 dl = FakeYDL()
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)
67
68 def test_vimeo_user(self):
69 dl = FakeYDL()
70 ie = VimeoUserIE(dl)
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)
75
76 def test_vimeo_album(self):
77 dl = FakeYDL()
78 ie = VimeoAlbumIE(dl)
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)
83
84 def test_vimeo_groups(self):
85 dl = FakeYDL()
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)
91
92 def test_ustream_channel(self):
93 dl = FakeYDL()
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)
99
100 def test_soundcloud_set(self):
101 dl = FakeYDL()
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)
107
108 def test_soundcloud_user(self):
109 dl = FakeYDL()
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)
115
116 def test_livestream_event(self):
117 dl = FakeYDL()
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)
123
124 def test_nhl_videocenter(self):
125 dl = FakeYDL()
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)
132
133 def test_bambuser_channel(self):
134 dl = FakeYDL()
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)
140
141 def test_bandcamp_album(self):
142 dl = FakeYDL()
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)
148
149 def test_smotri_community(self):
150 dl = FakeYDL()
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)
157
158 def test_smotri_user(self):
159 dl = FakeYDL()
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)
166
167 def test_AcademicEarthCourse(self):
168 dl = FakeYDL()
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)
176
177 def test_ivi_compilation(self):
178 dl = FakeYDL()
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)
185
186 def test_ivi_compilation_season(self):
187 dl = FakeYDL()
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)
194
195 def test_imdb_list(self):
196 dl = FakeYDL()
197 ie = ImdbListIE(dl)
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)
203
204 def test_khanacademy_topic(self):
205 dl = FakeYDL()
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)
213
214 def test_EveryonesMixtape(self):
215 dl = FakeYDL()
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)
222
223
224 if __name__ == '__main__':
225 unittest.main()