]> jfr.im git - yt-dlp.git/blame - test/test_playlists.py
[instagram] Fix info_dict key name
[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
ea38e55f
PH
12from test.helper import (
13 expect_info_dict,
14 FakeYDL,
15)
a3c736de 16
39baacc4 17from youtube_dl.extractor import (
d90df974 18 AcademicEarthCourseIE,
39baacc4
JMF
19 DailymotionPlaylistIE,
20 DailymotionUserIE,
21 VimeoChannelIE,
55a10eab 22 VimeoUserIE,
5cc14c2f 23 VimeoAlbumIE,
fb30ec22 24 VimeoGroupsIE,
39baacc4 25 UstreamChannelIE,
12c167c8 26 SoundcloudSetIE,
39baacc4 27 SoundcloudUserIE,
b00ca882 28 LivestreamIE,
91dbaef4 29 NHLVideocenterIE,
165e3bb6 30 BambuserChannelIE,
5270d8cb 31 BandcampAlbumIE,
32 SmotriCommunityIE,
5ce54a82 33 SmotriUserIE,
41cc67c5 34 IviCompilationIE,
4fb757d1 35 ImdbListIE,
3d3538e4 36 KhanAcademyIE,
484aaeb2 37 EveryonesMixtapeIE,
87fac323 38 RutubeChannelIE,
ccf9114e 39 GoogleSearchIE,
99877772 40 GenericIE,
ca1fee34 41 TEDIE,
231f76b5 42 ToypicsUserIE,
9f5809b3 43 XTubeUserIE,
ea38e55f 44 InstagramUserIE,
39baacc4 45)
a3c736de 46
a3c736de
JMF
47
48class TestPlaylists(unittest.TestCase):
49 def assertIsPlaylist(self, info):
50 """Make sure the info has '_type' set to 'playlist'"""
51 self.assertEqual(info['_type'], 'playlist')
52
53 def test_dailymotion_playlist(self):
54 dl = FakeYDL()
55 ie = DailymotionPlaylistIE(dl)
56 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
57 self.assertIsPlaylist(result)
ecfef3e5 58 self.assertEqual(result['title'], 'SPORT')
a3c736de 59 self.assertTrue(len(result['entries']) > 20)
b00ca882 60
39baacc4
JMF
61 def test_dailymotion_user(self):
62 dl = FakeYDL()
63 ie = DailymotionUserIE(dl)
99043c2e 64 result = ie.extract('https://www.dailymotion.com/user/nqtv')
39baacc4 65 self.assertIsPlaylist(result)
99043c2e
JMF
66 self.assertEqual(result['title'], 'Rémi Gaillard')
67 self.assertTrue(len(result['entries']) >= 100)
a3c736de 68
caeefc29
JMF
69 def test_vimeo_channel(self):
70 dl = FakeYDL()
71 ie = VimeoChannelIE(dl)
72 result = ie.extract('http://vimeo.com/channels/tributes')
73 self.assertIsPlaylist(result)
ecfef3e5 74 self.assertEqual(result['title'], 'Vimeo Tributes')
caeefc29
JMF
75 self.assertTrue(len(result['entries']) > 24)
76
55a10eab
JMF
77 def test_vimeo_user(self):
78 dl = FakeYDL()
79 ie = VimeoUserIE(dl)
80 result = ie.extract('http://vimeo.com/nkistudio/videos')
81 self.assertIsPlaylist(result)
ecfef3e5 82 self.assertEqual(result['title'], 'Nki')
55a10eab
JMF
83 self.assertTrue(len(result['entries']) > 65)
84
5cc14c2f
JMF
85 def test_vimeo_album(self):
86 dl = FakeYDL()
87 ie = VimeoAlbumIE(dl)
88 result = ie.extract('http://vimeo.com/album/2632481')
89 self.assertIsPlaylist(result)
ecfef3e5 90 self.assertEqual(result['title'], 'Staff Favorites: November 2013')
5cc14c2f
JMF
91 self.assertTrue(len(result['entries']) > 12)
92
fb30ec22
JMF
93 def test_vimeo_groups(self):
94 dl = FakeYDL()
95 ie = VimeoGroupsIE(dl)
96 result = ie.extract('http://vimeo.com/groups/rolexawards')
97 self.assertIsPlaylist(result)
ecfef3e5 98 self.assertEqual(result['title'], 'Rolex Awards for Enterprise')
fb30ec22
JMF
99 self.assertTrue(len(result['entries']) > 72)
100
74ac9bdd
JMF
101 def test_ustream_channel(self):
102 dl = FakeYDL()
103 ie = UstreamChannelIE(dl)
104 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
105 self.assertIsPlaylist(result)
ecfef3e5 106 self.assertEqual(result['id'], '5124905')
957688ce 107 self.assertTrue(len(result['entries']) >= 6)
74ac9bdd 108
12c167c8
JMF
109 def test_soundcloud_set(self):
110 dl = FakeYDL()
111 ie = SoundcloudSetIE(dl)
112 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
113 self.assertIsPlaylist(result)
ecfef3e5 114 self.assertEqual(result['title'], 'The Royal Concept EP')
12c167c8
JMF
115 self.assertTrue(len(result['entries']) >= 6)
116
92790f4e
JMF
117 def test_soundcloud_user(self):
118 dl = FakeYDL()
119 ie = SoundcloudUserIE(dl)
120 result = ie.extract('https://soundcloud.com/the-concept-band')
121 self.assertIsPlaylist(result)
ecfef3e5 122 self.assertEqual(result['id'], '9615865')
92790f4e
JMF
123 self.assertTrue(len(result['entries']) >= 12)
124
b00ca882
JMF
125 def test_livestream_event(self):
126 dl = FakeYDL()
127 ie = LivestreamIE(dl)
128 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
129 self.assertIsPlaylist(result)
ecfef3e5 130 self.assertEqual(result['title'], 'TEDCity2.0 (English)')
b00ca882
JMF
131 self.assertTrue(len(result['entries']) >= 4)
132
91dbaef4
JMF
133 def test_nhl_videocenter(self):
134 dl = FakeYDL()
135 ie = NHLVideocenterIE(dl)
136 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
137 self.assertIsPlaylist(result)
ecfef3e5
PH
138 self.assertEqual(result['id'], '999')
139 self.assertEqual(result['title'], 'Highlights')
91dbaef4
JMF
140 self.assertEqual(len(result['entries']), 12)
141
165e3bb6
JMF
142 def test_bambuser_channel(self):
143 dl = FakeYDL()
144 ie = BambuserChannelIE(dl)
145 result = ie.extract('http://bambuser.com/channel/pixelversity')
146 self.assertIsPlaylist(result)
ecfef3e5 147 self.assertEqual(result['title'], 'pixelversity')
d3b30148 148 self.assertTrue(len(result['entries']) >= 60)
165e3bb6 149
09804265
JMF
150 def test_bandcamp_album(self):
151 dl = FakeYDL()
152 ie = BandcampAlbumIE(dl)
153 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
154 self.assertIsPlaylist(result)
ecfef3e5 155 self.assertEqual(result['title'], 'Nightmare Night EP')
09804265 156 self.assertTrue(len(result['entries']) >= 4)
5270d8cb 157
158 def test_smotri_community(self):
159 dl = FakeYDL()
160 ie = SmotriCommunityIE(dl)
161 result = ie.extract('http://smotri.com/community/video/kommuna')
162 self.assertIsPlaylist(result)
ecfef3e5
PH
163 self.assertEqual(result['id'], 'kommuna')
164 self.assertEqual(result['title'], 'КПРФ')
5270d8cb 165 self.assertTrue(len(result['entries']) >= 4)
166
167 def test_smotri_user(self):
168 dl = FakeYDL()
169 ie = SmotriUserIE(dl)
170 result = ie.extract('http://smotri.com/user/inspector')
171 self.assertIsPlaylist(result)
ecfef3e5
PH
172 self.assertEqual(result['id'], 'inspector')
173 self.assertEqual(result['title'], 'Inspector')
5270d8cb 174 self.assertTrue(len(result['entries']) >= 9)
09804265 175
d90df974
PH
176 def test_AcademicEarthCourse(self):
177 dl = FakeYDL()
178 ie = AcademicEarthCourseIE(dl)
9e57ce71 179 result = ie.extract('http://academicearth.org/playlists/laws-of-nature/')
d90df974 180 self.assertIsPlaylist(result)
9e57ce71
JMF
181 self.assertEqual(result['id'], 'laws-of-nature')
182 self.assertEqual(result['title'], 'Laws of Nature')
183 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.")
184 self.assertEqual(len(result['entries']), 4)
8c21b7c6 185
186 def test_ivi_compilation(self):
187 dl = FakeYDL()
188 ie = IviCompilationIE(dl)
189 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
190 self.assertIsPlaylist(result)
ecfef3e5
PH
191 self.assertEqual(result['id'], 'dezhurnyi_angel')
192 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012)')
8c21b7c6 193 self.assertTrue(len(result['entries']) >= 36)
194
195 def test_ivi_compilation_season(self):
196 dl = FakeYDL()
197 ie = IviCompilationIE(dl)
198 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
199 self.assertIsPlaylist(result)
ecfef3e5
PH
200 self.assertEqual(result['id'], 'dezhurnyi_angel/season2')
201 self.assertEqual(result['title'], 'Дежурный ангел (2010 - 2012) 2 сезон')
8c21b7c6 202 self.assertTrue(len(result['entries']) >= 20)
41cc67c5 203
204 def test_imdb_list(self):
205 dl = FakeYDL()
206 ie = ImdbListIE(dl)
98669ed7 207 result = ie.extract('http://www.imdb.com/list/JFs9NWw6XI0')
41cc67c5 208 self.assertIsPlaylist(result)
98669ed7 209 self.assertEqual(result['id'], 'JFs9NWw6XI0')
210 self.assertEqual(result['title'], 'March 23, 2012 Releases')
211 self.assertEqual(len(result['entries']), 7)
d90df974 212
3d3538e4
PH
213 def test_khanacademy_topic(self):
214 dl = FakeYDL()
215 ie = KhanAcademyIE(dl)
216 result = ie.extract('https://www.khanacademy.org/math/applied-math/cryptography')
217 self.assertIsPlaylist(result)
ecfef3e5
PH
218 self.assertEqual(result['id'], 'cryptography')
219 self.assertEqual(result['title'], 'Journey into cryptography')
220 self.assertEqual(result['description'], 'How have humans protected their secret messages through history? What has changed today?')
3d3538e4
PH
221 self.assertTrue(len(result['entries']) >= 3)
222
484aaeb2
PH
223 def test_EveryonesMixtape(self):
224 dl = FakeYDL()
225 ie = EveryonesMixtapeIE(dl)
226 result = ie.extract('http://everyonesmixtape.com/#/mix/m7m0jJAbMQi')
227 self.assertIsPlaylist(result)
228 self.assertEqual(result['id'], 'm7m0jJAbMQi')
229 self.assertEqual(result['title'], 'Driving')
230 self.assertEqual(len(result['entries']), 24)
87fac323 231
232 def test_rutube_channel(self):
233 dl = FakeYDL()
234 ie = RutubeChannelIE(dl)
235 result = ie.extract('http://rutube.ru/tags/video/1409')
236 self.assertIsPlaylist(result)
237 self.assertEqual(result['id'], '1409')
238 self.assertTrue(len(result['entries']) >= 34)
484aaeb2 239
99877772
PH
240 def test_multiple_brightcove_videos(self):
241 # https://github.com/rg3/youtube-dl/issues/2283
242 dl = FakeYDL()
243 ie = GenericIE(dl)
244 result = ie.extract('http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html')
245 self.assertIsPlaylist(result)
246 self.assertEqual(result['id'], 'always-never-nuclear-command-and-control')
247 self.assertEqual(result['title'], 'Always/Never: A Little-Seen Movie About Nuclear Command and Control : The New Yorker')
248 self.assertEqual(len(result['entries']), 3)
249
ccf9114e
PH
250 def test_GoogleSearch(self):
251 dl = FakeYDL()
252 ie = GoogleSearchIE(dl)
253 result = ie.extract('gvsearch15:python language')
254 self.assertIsPlaylist(result)
255 self.assertEqual(result['id'], 'python language')
256 self.assertEqual(result['title'], 'python language')
c3d36f13 257 self.assertEqual(len(result['entries']), 15)
d90df974 258
4fc946b5
PH
259 def test_generic_rss_feed(self):
260 dl = FakeYDL()
261 ie = GenericIE(dl)
6a724239 262 result = ie.extract('http://phihag.de/2014/youtube-dl/rss.xml')
4fc946b5 263 self.assertIsPlaylist(result)
6a724239 264 self.assertEqual(result['id'], 'http://phihag.de/2014/youtube-dl/rss.xml')
4fc946b5
PH
265 self.assertEqual(result['title'], 'Zero Punctuation')
266 self.assertTrue(len(result['entries']) > 10)
267
ca1fee34
JMF
268 def test_ted_playlist(self):
269 dl = FakeYDL()
270 ie = TEDIE(dl)
271 result = ie.extract('http://www.ted.com/playlists/who_are_the_hackers')
272 self.assertIsPlaylist(result)
273 self.assertEqual(result['id'], '10')
274 self.assertEqual(result['title'], 'Who are the hackers?')
275 self.assertTrue(len(result['entries']) >= 6)
276
231f76b5
PH
277 def test_toypics_user(self):
278 dl = FakeYDL()
279 ie = ToypicsUserIE(dl)
280 result = ie.extract('http://videos.toypics.net/Mikey')
281 self.assertIsPlaylist(result)
282 self.assertEqual(result['id'], 'Mikey')
283 self.assertTrue(len(result['entries']) >= 17)
284
9f5809b3 285 def test_xtube_user(self):
286 dl = FakeYDL()
287 ie = XTubeUserIE(dl)
288 result = ie.extract('http://www.xtube.com/community/profile.php?user=greenshowers')
289 self.assertIsPlaylist(result)
290 self.assertEqual(result['id'], 'greenshowers')
291 self.assertTrue(len(result['entries']) >= 155)
292
ea38e55f
PH
293 def test_InstagramUser(self):
294 dl = FakeYDL()
295 ie = InstagramUserIE(dl)
296 result = ie.extract('http://instagram.com/porsche')
297 self.assertIsPlaylist(result)
298 self.assertEqual(result['id'], 'porsche')
299 self.assertTrue(len(result['entries']) >= 2)
300 test_video = next(
301 e for e in result['entries']
302 if e['id'] == '614605558512799803_462752227')
303 dl.add_default_extra_info(test_video, ie, '(irrelevant URL)')
304 dl.process_video_result(test_video, download=False)
305 EXPECTED = {
306 'id': '614605558512799803_462752227',
307 'ext': 'mp4',
308 'title': '#Porsche Intelligent Performance.',
309 'thumbnail': 're:^https?://.*\.jpg',
310 'uploader': 'Porsche',
311 'uploader_id': 'porsche',
912b38b4
PH
312 'timestamp': 1387486713,
313 'upload_date': '20131219',
ea38e55f
PH
314 }
315 expect_info_dict(self, EXPECTED, test_video)
316
317
a3c736de
JMF
318if __name__ == '__main__':
319 unittest.main()