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,
38 class TestPlaylists(unittest.TestCase):
39 def assertIsPlaylist(self, info):
40 """Make sure the info has '_type' set to 'playlist'"""
41 self.assertEqual(info['_type'], 'playlist')
43 def test_dailymotion_playlist(self):
45 ie = DailymotionPlaylistIE(dl)
46 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
47 self.assertIsPlaylist(result)
48 self.assertEqual(result['title'], 'SPORT')
49 self.assertTrue(len(result['entries']) > 20)
51 def test_dailymotion_user(self):
53 ie = DailymotionUserIE(dl)
54 result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
55 self.assertIsPlaylist(result)
56 self.assertEqual(result['title'], 'Génération Quoi')
57 self.assertTrue(len(result['entries']) >= 26)
59 def test_vimeo_channel(self):
61 ie = VimeoChannelIE(dl)
62 result = ie.extract('http://vimeo.com/channels/tributes')
63 self.assertIsPlaylist(result)
64 self.assertEqual(result['title'], 'Vimeo Tributes')
65 self.assertTrue(len(result['entries']) > 24)
67 def test_vimeo_user(self):
70 result = ie.extract('http://vimeo.com/nkistudio/videos')
71 self.assertIsPlaylist(result)
72 self.assertEqual(result['title'], 'Nki')
73 self.assertTrue(len(result['entries']) > 65)
75 def test_vimeo_album(self):
78 result = ie.extract('http://vimeo.com/album/2632481')
79 self.assertIsPlaylist(result)
80 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
81 self.assertTrue(len(result['entries']) > 12)
83 def test_vimeo_groups(self):
85 ie = VimeoGroupsIE(dl)
86 result = ie.extract('http://vimeo.com/groups/rolexawards')
87 self.assertIsPlaylist(result)
88 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
89 self.assertTrue(len(result['entries']) > 72)
91 def test_ustream_channel(self):
93 ie = UstreamChannelIE(dl)
94 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
95 self.assertIsPlaylist(result)
96 self.assertEqual(result['id'], '5124905')
97 self.assertTrue(len(result['entries']) >= 11)
99 def test_soundcloud_set(self):
101 ie = SoundcloudSetIE(dl)
102 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
103 self.assertIsPlaylist(result)
104 self.assertEqual(result['title'], 'The Royal Concept EP')
105 self.assertTrue(len(result['entries']) >= 6)
107 def test_soundcloud_user(self):
109 ie = SoundcloudUserIE(dl)
110 result = ie.extract('https://soundcloud.com/the-concept-band')
111 self.assertIsPlaylist(result)
112 self.assertEqual(result['id'], '9615865')
113 self.assertTrue(len(result['entries']) >= 12)
115 def test_livestream_event(self):
117 ie = LivestreamIE(dl)
118 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
119 self.assertIsPlaylist(result)
120 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
121 self.assertTrue(len(result['entries']) >= 4)
123 def test_nhl_videocenter(self):
125 ie = NHLVideocenterIE(dl)
126 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
127 self.assertIsPlaylist(result)
128 self.assertEqual(result['id'], '999')
129 self.assertEqual(result['title'], 'Highlights')
130 self.assertEqual(len(result['entries']), 12)
132 def test_bambuser_channel(self):
134 ie = BambuserChannelIE(dl)
135 result = ie.extract('http://bambuser.com/channel/pixelversity')
136 self.assertIsPlaylist(result)
137 self.assertEqual(result['title'], 'pixelversity')
138 self.assertTrue(len(result['entries']) >= 60)
140 def test_bandcamp_album(self):
142 ie = BandcampAlbumIE(dl)
143 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
144 self.assertIsPlaylist(result)
145 self.assertEqual(result['title'], 'Nightmare Night EP')
146 self.assertTrue(len(result['entries']) >= 4)
148 def test_smotri_community(self):
150 ie = SmotriCommunityIE(dl)
151 result = ie.extract('http://smotri.com/community/video/kommuna')
152 self.assertIsPlaylist(result)
153 self.assertEqual(result['id'], 'kommuna')
154 self.assertEqual(result['title'], 'КПРФ')
155 self.assertTrue(len(result['entries']) >= 4)
157 def test_smotri_user(self):
159 ie = SmotriUserIE(dl)
160 result = ie.extract('http://smotri.com/user/inspector')
161 self.assertIsPlaylist(result)
162 self.assertEqual(result['id'], 'inspector')
163 self.assertEqual(result['title'], 'Inspector')
164 self.assertTrue(len(result['entries']) >= 9)
166 def test_AcademicEarthCourse(self):
168 ie = AcademicEarthCourseIE(dl)
169 result = ie.extract('http://academicearth.org/courses/building-dynamic-websites/')
170 self.assertIsPlaylist(result)
171 self.assertEqual(result['id'], 'building-dynamic-websites')
172 self.assertEqual(result['title'], 'Building Dynamic Websites')
173 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.")
174 self.assertEqual(len(result['entries']), 10)
176 def test_ivi_compilation(self):
178 ie = IviCompilationIE(dl)
179 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
180 self.assertIsPlaylist(result)
181 self.assertEqual(result['id'], 'dezhurnyi_angel')
182 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
183 self.assertTrue(len(result['entries']) >= 36)
185 def test_ivi_compilation_season(self):
187 ie = IviCompilationIE(dl)
188 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
189 self.assertIsPlaylist(result)
190 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
191 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
192 self.assertTrue(len(result['entries']) >= 20)
194 def test_imdb_list(self):
197 result = ie.extract('http://www.imdb.com/list/sMjedvGDd8U')
198 self.assertIsPlaylist(result)
199 self.assertEqual(result['id'], 'sMjedvGDd8U')
200 self.assertEqual(result['title'], 'Animated and Family Films')
201 self.assertTrue(len(result['entries']) >= 48)
203 def test_khanacademy_topic(self):
205 ie = KhanAcademyIE(dl)
206 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
207 self.assertIsPlaylist(result)
208 self.assertEqual(result['id'], 'cryptography')
209 self.assertEqual(result['title'], 'Journey into cryptography')
210 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
211 self.assertTrue(len(result['entries']) >= 3)
214 if __name__ == '__main__':