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,
40 class TestPlaylists(unittest.TestCase):
41 def assertIsPlaylist(self, info):
42 """Make sure the info has '_type' set to 'playlist'"""
43 self.assertEqual(info['_type'], 'playlist')
45 def test_dailymotion_playlist(self):
47 ie = DailymotionPlaylistIE(dl)
48 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
49 self.assertIsPlaylist(result)
50 self.assertEqual(result['title'], 'SPORT')
51 self.assertTrue(len(result['entries']) > 20)
53 def test_dailymotion_user(self):
55 ie = DailymotionUserIE(dl)
56 result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
57 self.assertIsPlaylist(result)
58 self.assertEqual(result['title'], 'Génération Quoi')
59 self.assertTrue(len(result['entries']) >= 26)
61 def test_vimeo_channel(self):
63 ie = VimeoChannelIE(dl)
64 result = ie.extract('http://vimeo.com/channels/tributes')
65 self.assertIsPlaylist(result)
66 self.assertEqual(result['title'], 'Vimeo Tributes')
67 self.assertTrue(len(result['entries']) > 24)
69 def test_vimeo_user(self):
72 result = ie.extract('http://vimeo.com/nkistudio/videos')
73 self.assertIsPlaylist(result)
74 self.assertEqual(result['title'], 'Nki')
75 self.assertTrue(len(result['entries']) > 65)
77 def test_vimeo_album(self):
80 result = ie.extract('http://vimeo.com/album/2632481')
81 self.assertIsPlaylist(result)
82 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
83 self.assertTrue(len(result['entries']) > 12)
85 def test_vimeo_groups(self):
87 ie = VimeoGroupsIE(dl)
88 result = ie.extract('http://vimeo.com/groups/rolexawards')
89 self.assertIsPlaylist(result)
90 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
91 self.assertTrue(len(result['entries']) > 72)
93 def test_ustream_channel(self):
95 ie = UstreamChannelIE(dl)
96 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
97 self.assertIsPlaylist(result)
98 self.assertEqual(result['id'], '5124905')
99 self.assertTrue(len(result['entries']) >= 11)
101 def test_soundcloud_set(self):
103 ie = SoundcloudSetIE(dl)
104 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
105 self.assertIsPlaylist(result)
106 self.assertEqual(result['title'], 'The Royal Concept EP')
107 self.assertTrue(len(result['entries']) >= 6)
109 def test_soundcloud_user(self):
111 ie = SoundcloudUserIE(dl)
112 result = ie.extract('https://soundcloud.com/the-concept-band')
113 self.assertIsPlaylist(result)
114 self.assertEqual(result['id'], '9615865')
115 self.assertTrue(len(result['entries']) >= 12)
117 def test_livestream_event(self):
119 ie = LivestreamIE(dl)
120 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
121 self.assertIsPlaylist(result)
122 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
123 self.assertTrue(len(result['entries']) >= 4)
125 def test_nhl_videocenter(self):
127 ie = NHLVideocenterIE(dl)
128 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
129 self.assertIsPlaylist(result)
130 self.assertEqual(result['id'], '999')
131 self.assertEqual(result['title'], 'Highlights')
132 self.assertEqual(len(result['entries']), 12)
134 def test_bambuser_channel(self):
136 ie = BambuserChannelIE(dl)
137 result = ie.extract('http://bambuser.com/channel/pixelversity')
138 self.assertIsPlaylist(result)
139 self.assertEqual(result['title'], 'pixelversity')
140 self.assertTrue(len(result['entries']) >= 60)
142 def test_bandcamp_album(self):
144 ie = BandcampAlbumIE(dl)
145 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
146 self.assertIsPlaylist(result)
147 self.assertEqual(result['title'], 'Nightmare Night EP')
148 self.assertTrue(len(result['entries']) >= 4)
150 def test_smotri_community(self):
152 ie = SmotriCommunityIE(dl)
153 result = ie.extract('http://smotri.com/community/video/kommuna')
154 self.assertIsPlaylist(result)
155 self.assertEqual(result['id'], 'kommuna')
156 self.assertEqual(result['title'], 'КПРФ')
157 self.assertTrue(len(result['entries']) >= 4)
159 def test_smotri_user(self):
161 ie = SmotriUserIE(dl)
162 result = ie.extract('http://smotri.com/user/inspector')
163 self.assertIsPlaylist(result)
164 self.assertEqual(result['id'], 'inspector')
165 self.assertEqual(result['title'], 'Inspector')
166 self.assertTrue(len(result['entries']) >= 9)
168 def test_AcademicEarthCourse(self):
170 ie = AcademicEarthCourseIE(dl)
171 result = ie.extract('http://academicearth.org/courses/building-dynamic-websites/')
172 self.assertIsPlaylist(result)
173 self.assertEqual(result['id'], 'building-dynamic-websites')
174 self.assertEqual(result['title'], 'Building Dynamic Websites')
175 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.")
176 self.assertEqual(len(result['entries']), 10)
178 def test_ivi_compilation(self):
180 ie = IviCompilationIE(dl)
181 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
182 self.assertIsPlaylist(result)
183 self.assertEqual(result['id'], 'dezhurnyi_angel')
184 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
185 self.assertTrue(len(result['entries']) >= 36)
187 def test_ivi_compilation_season(self):
189 ie = IviCompilationIE(dl)
190 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
191 self.assertIsPlaylist(result)
192 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
193 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
194 self.assertTrue(len(result['entries']) >= 20)
196 def test_imdb_list(self):
199 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
200 self.assertIsPlaylist(result)
201 self.assertEqual(result['id'], 'JFs9NWw6XI0')
202 self.assertEqual(result['title'], 'March 23, 2012 Releases')
203 self.assertEqual(len(result['entries']), 7)
205 def test_khanacademy_topic(self):
207 ie = KhanAcademyIE(dl)
208 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
209 self.assertIsPlaylist(result)
210 self.assertEqual(result['id'], 'cryptography')
211 self.assertEqual(result['title'], 'Journey into cryptography')
212 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
213 self.assertTrue(len(result['entries']) >= 3)
215 def test_EveryonesMixtape(self):
217 ie = EveryonesMixtapeIE(dl)
218 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
219 self.assertIsPlaylist(result)
220 self.assertEqual(result['id'], 'm7m0jJAbMQi')
221 self.assertEqual(result['title'], 'Driving')
222 self.assertEqual(len(result['entries']), 24)
224 def test_rutube_channel(self):
226 ie = RutubeChannelIE(dl)
227 result = ie.extract('http://rutube.ru/tags/video/1409')
228 self.assertIsPlaylist(result)
229 self.assertEqual(result['id'], '1409')
230 self.assertTrue(len(result['entries']) >= 34)
233 if __name__ == '__main__':