]> jfr.im git - yt-dlp.git/blame - test/test_playlists.py
[academicearth] Fix extraction
[yt-dlp.git] / test / test_playlists.py
CommitLineData
a3c736de 1#!/usr/bin/env python
39baacc4 2# encoding: utf-8
a3c736de 3
ecfef3e5
PH
4from __future__ import unicode_literals
5
a3c736de
JMF
6# Allow direct execution
7import os
44a5f171
PH
8import sys
9import unittest
10sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11
d0efb9ec 12from test.helper import FakeYDL
44a5f171 13
a3c736de 14
39baacc4 15from youtube_dl.extractor import (
d90df974 16 AcademicEarthCourseIE,
39baacc4
JMF
17 DailymotionPlaylistIE,
18 DailymotionUserIE,
19 VimeoChannelIE,
55a10eab 20 VimeoUserIE,
5cc14c2f 21 VimeoAlbumIE,
fb30ec22 22 VimeoGroupsIE,
39baacc4 23 UstreamChannelIE,
12c167c8 24 SoundcloudSetIE,
39baacc4 25 SoundcloudUserIE,
b00ca882 26 LivestreamIE,
91dbaef4 27 NHLVideocenterIE,
165e3bb6 28 BambuserChannelIE,
5270d8cb 29 BandcampAlbumIE,
30 SmotriCommunityIE,
5ce54a82 31 SmotriUserIE,
41cc67c5 32 IviCompilationIE,
4fb757d1 33 ImdbListIE,
3d3538e4 34 KhanAcademyIE,
484aaeb2 35 EveryonesMixtapeIE,
87fac323 36 RutubeChannelIE,
ccf9114e 37 GoogleSearchIE,
99877772 38 GenericIE,
39baacc4 39)
a3c736de 40
a3c736de
JMF
41
42class 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)
ecfef3e5 52 self.assertEqual(result['title'], 'SPORT')
a3c736de 53 self.assertTrue(len(result['entries']) > 20)
b00ca882 54
39baacc4
JMF
55 def test_dailymotion_user(self):
56 dl = FakeYDL()
57 ie = DailymotionUserIE(dl)
99043c2e 58 result = ie.extract('https://www.dailymotion.com/user/nqtv')
39baacc4 59 self.assertIsPlaylist(result)
99043c2e
JMF
60 self.assertEqual(result['title'], 'Rémi Gaillard')
61 self.assertTrue(len(result['entries']) >= 100)
a3c736de 62
caeefc29
JMF
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)
ecfef3e5 68 self.assertEqual(result['title'], 'Vimeo Tributes')
caeefc29
JMF
69 self.assertTrue(len(result['entries']) > 24)
70
55a10eab
JMF
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)
ecfef3e5 76 self.assertEqual(result['title'], 'Nki')
55a10eab
JMF
77 self.assertTrue(len(result['entries']) > 65)
78
5cc14c2f
JMF
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)
ecfef3e5 84 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
5cc14c2f
JMF
85 self.assertTrue(len(result['entries']) > 12)
86
fb30ec22
JMF
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)
ecfef3e5 92 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
fb30ec22
JMF
93 self.assertTrue(len(result['entries']) > 72)
94
74ac9bdd
JMF
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)
ecfef3e5 100 self.assertEqual(result['id'], '5124905')
74ac9bdd
JMF
101 self.assertTrue(len(result['entries']) >= 11)
102
12c167c8
JMF
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)
ecfef3e5 108 self.assertEqual(result['title'], 'The Royal Concept EP')
12c167c8
JMF
109 self.assertTrue(len(result['entries']) >= 6)
110
92790f4e
JMF
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)
ecfef3e5 116 self.assertEqual(result['id'], '9615865')
92790f4e
JMF
117 self.assertTrue(len(result['entries']) >= 12)
118
b00ca882
JMF
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)
ecfef3e5 124 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
b00ca882
JMF
125 self.assertTrue(len(result['entries']) >= 4)
126
91dbaef4
JMF
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)
ecfef3e5
PH
132 self.assertEqual(result['id'], '999')
133 self.assertEqual(result['title'], 'Highlights')
91dbaef4
JMF
134 self.assertEqual(len(result['entries']), 12)
135
165e3bb6
JMF
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)
ecfef3e5 141 self.assertEqual(result['title'], 'pixelversity')
d3b30148 142 self.assertTrue(len(result['entries']) >= 60)
165e3bb6 143
09804265
JMF
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)
ecfef3e5 149 self.assertEqual(result['title'], 'Nightmare Night EP')
09804265 150 self.assertTrue(len(result['entries']) >= 4)
5270d8cb 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)
ecfef3e5
PH
157 self.assertEqual(result['id'], 'kommuna')
158 self.assertEqual(result['title'], 'КПРФ')
5270d8cb 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)
ecfef3e5
PH
166 self.assertEqual(result['id'], 'inspector')
167 self.assertEqual(result['title'], 'Inspector')
5270d8cb 168 self.assertTrue(len(result['entries']) >= 9)
09804265 169
d90df974
PH
170 def test_AcademicEarthCourse(self):
171 dl = FakeYDL()
172 ie = AcademicEarthCourseIE(dl)
9e57ce71 173 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
d90df974 174 self.assertIsPlaylist(result)
9e57ce71
JMF
175 self.assertEqual(result['id'], 'laws-of-nature')
176 self.assertEqual(result['title'], 'Laws of Nature')
177 self.assertEqual(result['description'],u'Introduce yourself to the laws of nature with these free online college lectures from Yale, Harvard, and MIT.')# 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']), 4)
8c21b7c6 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)
ecfef3e5
PH
185 self.assertEqual(result['id'], 'dezhurnyi_angel')
186 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
8c21b7c6 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)
ecfef3e5
PH
194 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
195 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
8c21b7c6 196 self.assertTrue(len(result['entries']) >= 20)
41cc67c5 197
198 def test_imdb_list(self):
199 dl = FakeYDL()
200 ie = ImdbListIE(dl)
98669ed7 201 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
41cc67c5 202 self.assertIsPlaylist(result)
98669ed7 203 self.assertEqual(result['id'], 'JFs9NWw6XI0')
204 self.assertEqual(result['title'], 'March 23, 2012 Releases')
205 self.assertEqual(len(result['entries']), 7)
d90df974 206
3d3538e4
PH
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)
ecfef3e5
PH
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?')
3d3538e4
PH
215 self.assertTrue(len(result['entries']) >= 3)
216
484aaeb2
PH
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)
87fac323 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)
484aaeb2 233
99877772
PH
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
ccf9114e
PH
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)
d90df974 252
4fc946b5
PH
253 def test_generic_rss_feed(self):
254 dl = FakeYDL()
255 ie = GenericIE(dl)
256 result = ie.extract('http://www.escapistmagazine.com/rss/videos/list/1.xml')
257 self.assertIsPlaylist(result)
258 self.assertEqual(result['id'], 'http://www.escapistmagazine.com/rss/videos/list/1.xml')
259 self.assertEqual(result['title'], 'Zero Punctuation')
260 self.assertTrue(len(result['entries']) > 10)
261
a3c736de
JMF
262if __name__ == '__main__':
263 unittest.main()