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,
41 class TestPlaylists(unittest.TestCase):
42 def assertIsPlaylist(self, info):
43 """Make sure the info has '_type' set to 'playlist'"""
44 self.assertEqual(info['_type'], 'playlist')
46 def test_dailymotion_playlist(self):
48 ie = DailymotionPlaylistIE(dl)
49 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
50 self.assertIsPlaylist(result)
51 self.assertEqual(result['title'], 'SPORT')
52 self.assertTrue(len(result['entries']) > 20)
54 def test_dailymotion_user(self):
56 ie = DailymotionUserIE(dl)
57 result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
58 self.assertIsPlaylist(result)
59 self.assertEqual(result['title'], 'Génération Quoi')
60 self.assertTrue(len(result['entries']) >= 26)
62 def test_vimeo_channel(self):
64 ie = VimeoChannelIE(dl)
65 result = ie.extract('http://vimeo.com/channels/tributes')
66 self.assertIsPlaylist(result)
67 self.assertEqual(result['title'], 'Vimeo Tributes')
68 self.assertTrue(len(result['entries']) > 24)
70 def test_vimeo_user(self):
73 result = ie.extract('http://vimeo.com/nkistudio/videos')
74 self.assertIsPlaylist(result)
75 self.assertEqual(result['title'], 'Nki')
76 self.assertTrue(len(result['entries']) > 65)
78 def test_vimeo_album(self):
81 result = ie.extract('http://vimeo.com/album/2632481')
82 self.assertIsPlaylist(result)
83 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
84 self.assertTrue(len(result['entries']) > 12)
86 def test_vimeo_groups(self):
88 ie = VimeoGroupsIE(dl)
89 result = ie.extract('http://vimeo.com/groups/rolexawards')
90 self.assertIsPlaylist(result)
91 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
92 self.assertTrue(len(result['entries']) > 72)
94 def test_ustream_channel(self):
96 ie = UstreamChannelIE(dl)
97 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
98 self.assertIsPlaylist(result)
99 self.assertEqual(result['id'], '5124905')
100 self.assertTrue(len(result['entries']) >= 11)
102 def test_soundcloud_set(self):
104 ie = SoundcloudSetIE(dl)
105 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
106 self.assertIsPlaylist(result)
107 self.assertEqual(result['title'], 'The Royal Concept EP')
108 self.assertTrue(len(result['entries']) >= 6)
110 def test_soundcloud_user(self):
112 ie = SoundcloudUserIE(dl)
113 result = ie.extract('https://soundcloud.com/the-concept-band')
114 self.assertIsPlaylist(result)
115 self.assertEqual(result['id'], '9615865')
116 self.assertTrue(len(result['entries']) >= 12)
118 def test_livestream_event(self):
120 ie = LivestreamIE(dl)
121 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
122 self.assertIsPlaylist(result)
123 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
124 self.assertTrue(len(result['entries']) >= 4)
126 def test_nhl_videocenter(self):
128 ie = NHLVideocenterIE(dl)
129 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
130 self.assertIsPlaylist(result)
131 self.assertEqual(result['id'], '999')
132 self.assertEqual(result['title'], 'Highlights')
133 self.assertEqual(len(result['entries']), 12)
135 def test_bambuser_channel(self):
137 ie = BambuserChannelIE(dl)
138 result = ie.extract('http://bambuser.com/channel/pixelversity')
139 self.assertIsPlaylist(result)
140 self.assertEqual(result['title'], 'pixelversity')
141 self.assertTrue(len(result['entries']) >= 60)
143 def test_bandcamp_album(self):
145 ie = BandcampAlbumIE(dl)
146 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
147 self.assertIsPlaylist(result)
148 self.assertEqual(result['title'], 'Nightmare Night EP')
149 self.assertTrue(len(result['entries']) >= 4)
151 def test_smotri_community(self):
153 ie = SmotriCommunityIE(dl)
154 result = ie.extract('http://smotri.com/community/video/kommuna')
155 self.assertIsPlaylist(result)
156 self.assertEqual(result['id'], 'kommuna')
157 self.assertEqual(result['title'], 'КПРФ')
158 self.assertTrue(len(result['entries']) >= 4)
160 def test_smotri_user(self):
162 ie = SmotriUserIE(dl)
163 result = ie.extract('http://smotri.com/user/inspector')
164 self.assertIsPlaylist(result)
165 self.assertEqual(result['id'], 'inspector')
166 self.assertEqual(result['title'], 'Inspector')
167 self.assertTrue(len(result['entries']) >= 9)
169 def test_AcademicEarthCourse(self):
171 ie = AcademicEarthCourseIE(dl)
172 result = ie.extract('http://academicearth.org/courses/building-dynamic-websites/')
173 self.assertIsPlaylist(result)
174 self.assertEqual(result['id'], 'building-dynamic-websites')
175 self.assertEqual(result['title'], 'Building Dynamic Websites')
176 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.")
177 self.assertEqual(len(result['entries']), 10)
179 def test_ivi_compilation(self):
181 ie = IviCompilationIE(dl)
182 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
183 self.assertIsPlaylist(result)
184 self.assertEqual(result['id'], 'dezhurnyi_angel')
185 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
186 self.assertTrue(len(result['entries']) >= 36)
188 def test_ivi_compilation_season(self):
190 ie = IviCompilationIE(dl)
191 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
192 self.assertIsPlaylist(result)
193 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
194 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
195 self.assertTrue(len(result['entries']) >= 20)
197 def test_imdb_list(self):
200 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
201 self.assertIsPlaylist(result)
202 self.assertEqual(result['id'], 'JFs9NWw6XI0')
203 self.assertEqual(result['title'], 'March 23, 2012 Releases')
204 self.assertEqual(len(result['entries']), 7)
206 def test_khanacademy_topic(self):
208 ie = KhanAcademyIE(dl)
209 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
210 self.assertIsPlaylist(result)
211 self.assertEqual(result['id'], 'cryptography')
212 self.assertEqual(result['title'], 'Journey into cryptography')
213 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
214 self.assertTrue(len(result['entries']) >= 3)
216 def test_EveryonesMixtape(self):
218 ie = EveryonesMixtapeIE(dl)
219 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
220 self.assertIsPlaylist(result)
221 self.assertEqual(result['id'], 'm7m0jJAbMQi')
222 self.assertEqual(result['title'], 'Driving')
223 self.assertEqual(len(result['entries']), 24)
225 def test_rutube_channel(self):
227 ie = RutubeChannelIE(dl)
228 result = ie.extract('http://rutube.ru/tags/video/1409')
229 self.assertIsPlaylist(result)
230 self.assertEqual(result['id'], '1409')
231 self.assertTrue(len(result['entries']) >= 34)
233 def test_multiple_brightcove_videos(self):
234 # https://github.com/rg3/youtube-dl/issues/2283
237 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
238 self.assertIsPlaylist(result)
239 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
240 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
241 self.assertEqual(len(result['entries']), 3)
244 if __name__ == '__main__':