Merge pull request #2252 from matthewfranglen/master
[youtube-dl] / test / test_playlists.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3
4 from __future__ import unicode_literals
5
6 # Allow direct execution
7 import os
8 import sys
9 import unittest
10 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11
12 from test.helper import FakeYDL
13
14
15 from youtube_dl.extractor import (
16     AcademicEarthCourseIE,
17     DailymotionPlaylistIE,
18     DailymotionUserIE,
19     VimeoChannelIE,
20     VimeoUserIE,
21     VimeoAlbumIE,
22     VimeoGroupsIE,
23     UstreamChannelIE,
24     SoundcloudSetIE,
25     SoundcloudUserIE,
26     LivestreamIE,
27     NHLVideocenterIE,
28     BambuserChannelIE,
29     BandcampAlbumIE,
30     SmotriCommunityIE,
31     SmotriUserIE,
32     IviCompilationIE,
33     ImdbListIE,
34     KhanAcademyIE,
35     EveryonesMixtapeIE,
36     RutubeChannelIE,
37 )
38
39
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')
44
45     def test_dailymotion_playlist(self):
46         dl = FakeYDL()
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)
52
53     def test_dailymotion_user(self):
54         dl = FakeYDL()
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)
60
61     def test_vimeo_channel(self):
62         dl = FakeYDL()
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)
68
69     def test_vimeo_user(self):
70         dl = FakeYDL()
71         ie = VimeoUserIE(dl)
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)
76
77     def test_vimeo_album(self):
78         dl = FakeYDL()
79         ie = VimeoAlbumIE(dl)
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)
84
85     def test_vimeo_groups(self):
86         dl = FakeYDL()
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)
92
93     def test_ustream_channel(self):
94         dl = FakeYDL()
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)
100
101     def test_soundcloud_set(self):
102         dl = FakeYDL()
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)
108
109     def test_soundcloud_user(self):
110         dl = FakeYDL()
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)
116
117     def test_livestream_event(self):
118         dl = FakeYDL()
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)
124
125     def test_nhl_videocenter(self):
126         dl = FakeYDL()
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)
133
134     def test_bambuser_channel(self):
135         dl = FakeYDL()
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)
141
142     def test_bandcamp_album(self):
143         dl = FakeYDL()
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)
149         
150     def test_smotri_community(self):
151         dl = FakeYDL()
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)
158         
159     def test_smotri_user(self):
160         dl = FakeYDL()
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)
167
168     def test_AcademicEarthCourse(self):
169         dl = FakeYDL()
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)
177         
178     def test_ivi_compilation(self):
179         dl = FakeYDL()
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)
186         
187     def test_ivi_compilation_season(self):
188         dl = FakeYDL()
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)
195         
196     def test_imdb_list(self):
197         dl = FakeYDL()
198         ie = ImdbListIE(dl)
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)
204
205     def test_khanacademy_topic(self):
206         dl = FakeYDL()
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)
214
215     def test_EveryonesMixtape(self):
216         dl = FakeYDL()
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)
223         
224     def test_rutube_channel(self):
225         dl = FakeYDL()
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)
231
232
233 if __name__ == '__main__':
234     unittest.main()