]> Raphaël G. Git Repositories - youtubedl/blob - test/test_playlists.py
Imported Upstream version 2013.12.23
[youtubedl] / test / test_playlists.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3
4
5 # Allow direct execution
6 import os
7 import sys
8 import unittest
9 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10
11 from test.helper import FakeYDL
12
13
14 from youtube_dl.extractor import (
15 AcademicEarthCourseIE,
16 DailymotionPlaylistIE,
17 DailymotionUserIE,
18 VimeoChannelIE,
19 VimeoUserIE,
20 VimeoAlbumIE,
21 VimeoGroupsIE,
22 UstreamChannelIE,
23 SoundcloudSetIE,
24 SoundcloudUserIE,
25 LivestreamIE,
26 NHLVideocenterIE,
27 BambuserChannelIE,
28 BandcampAlbumIE,
29 SmotriCommunityIE,
30 SmotriUserIE,
31 IviCompilationIE
32 )
33
34
35 class TestPlaylists(unittest.TestCase):
36 def assertIsPlaylist(self, info):
37 """Make sure the info has '_type' set to 'playlist'"""
38 self.assertEqual(info['_type'], 'playlist')
39
40 def test_dailymotion_playlist(self):
41 dl = FakeYDL()
42 ie = DailymotionPlaylistIE(dl)
43 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
44 self.assertIsPlaylist(result)
45 self.assertEqual(result['title'], u'SPORT')
46 self.assertTrue(len(result['entries']) > 20)
47
48 def test_dailymotion_user(self):
49 dl = FakeYDL()
50 ie = DailymotionUserIE(dl)
51 result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
52 self.assertIsPlaylist(result)
53 self.assertEqual(result['title'], u'Génération Quoi')
54 self.assertTrue(len(result['entries']) >= 26)
55
56 def test_vimeo_channel(self):
57 dl = FakeYDL()
58 ie = VimeoChannelIE(dl)
59 result = ie.extract('http://vimeo.com/channels/tributes')
60 self.assertIsPlaylist(result)
61 self.assertEqual(result['title'], u'Vimeo Tributes')
62 self.assertTrue(len(result['entries']) > 24)
63
64 def test_vimeo_user(self):
65 dl = FakeYDL()
66 ie = VimeoUserIE(dl)
67 result = ie.extract('http://vimeo.com/nkistudio/videos')
68 self.assertIsPlaylist(result)
69 self.assertEqual(result['title'], u'Nki')
70 self.assertTrue(len(result['entries']) > 65)
71
72 def test_vimeo_album(self):
73 dl = FakeYDL()
74 ie = VimeoAlbumIE(dl)
75 result = ie.extract('http://vimeo.com/album/2632481')
76 self.assertIsPlaylist(result)
77 self.assertEqual(result['title'], u'Staff Favorites: November 2013')
78 self.assertTrue(len(result['entries']) > 12)
79
80 def test_vimeo_groups(self):
81 dl = FakeYDL()
82 ie = VimeoGroupsIE(dl)
83 result = ie.extract('http://vimeo.com/groups/rolexawards')
84 self.assertIsPlaylist(result)
85 self.assertEqual(result['title'], u'Rolex Awards for Enterprise')
86 self.assertTrue(len(result['entries']) > 72)
87
88 def test_ustream_channel(self):
89 dl = FakeYDL()
90 ie = UstreamChannelIE(dl)
91 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
92 self.assertIsPlaylist(result)
93 self.assertEqual(result['id'], u'5124905')
94 self.assertTrue(len(result['entries']) >= 11)
95
96 def test_soundcloud_set(self):
97 dl = FakeYDL()
98 ie = SoundcloudSetIE(dl)
99 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
100 self.assertIsPlaylist(result)
101 self.assertEqual(result['title'], u'The Royal Concept EP')
102 self.assertTrue(len(result['entries']) >= 6)
103
104 def test_soundcloud_user(self):
105 dl = FakeYDL()
106 ie = SoundcloudUserIE(dl)
107 result = ie.extract('https://soundcloud.com/the-concept-band')
108 self.assertIsPlaylist(result)
109 self.assertEqual(result['id'], u'9615865')
110 self.assertTrue(len(result['entries']) >= 12)
111
112 def test_livestream_event(self):
113 dl = FakeYDL()
114 ie = LivestreamIE(dl)
115 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
116 self.assertIsPlaylist(result)
117 self.assertEqual(result['title'], u'TEDCity2.0 (English)')
118 self.assertTrue(len(result['entries']) >= 4)
119
120 def test_nhl_videocenter(self):
121 dl = FakeYDL()
122 ie = NHLVideocenterIE(dl)
123 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
124 self.assertIsPlaylist(result)
125 self.assertEqual(result['id'], u'999')
126 self.assertEqual(result['title'], u'Highlights')
127 self.assertEqual(len(result['entries']), 12)
128
129 def test_bambuser_channel(self):
130 dl = FakeYDL()
131 ie = BambuserChannelIE(dl)
132 result = ie.extract('http://bambuser.com/channel/pixelversity')
133 self.assertIsPlaylist(result)
134 self.assertEqual(result['title'], u'pixelversity')
135 self.assertTrue(len(result['entries']) >= 60)
136
137 def test_bandcamp_album(self):
138 dl = FakeYDL()
139 ie = BandcampAlbumIE(dl)
140 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
141 self.assertIsPlaylist(result)
142 self.assertEqual(result['title'], u'Nightmare Night EP')
143 self.assertTrue(len(result['entries']) >= 4)
144
145 def test_smotri_community(self):
146 dl = FakeYDL()
147 ie = SmotriCommunityIE(dl)
148 result = ie.extract('http://smotri.com/community/video/kommuna')
149 self.assertIsPlaylist(result)
150 self.assertEqual(result['id'], u'kommuna')
151 self.assertEqual(result['title'], u'КПРФ')
152 self.assertTrue(len(result['entries']) >= 4)
153
154 def test_smotri_user(self):
155 dl = FakeYDL()
156 ie = SmotriUserIE(dl)
157 result = ie.extract('http://smotri.com/user/inspector')
158 self.assertIsPlaylist(result)
159 self.assertEqual(result['id'], u'inspector')
160 self.assertEqual(result['title'], u'Inspector')
161 self.assertTrue(len(result['entries']) >= 9)
162
163 def test_AcademicEarthCourse(self):
164 dl = FakeYDL()
165 ie = AcademicEarthCourseIE(dl)
166 result = ie.extract(u'http://academicearth.org/courses/building-dynamic-websites/')
167 self.assertIsPlaylist(result)
168 self.assertEqual(result['id'], u'building-dynamic-websites')
169 self.assertEqual(result['title'], u'Building Dynamic Websites')
170 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.")
171 self.assertEqual(len(result['entries']), 10)
172
173 def test_ivi_compilation(self):
174 dl = FakeYDL()
175 ie = IviCompilationIE(dl)
176 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
177 self.assertIsPlaylist(result)
178 self.assertEqual(result['id'], u'dezhurnyi_angel')
179 self.assertEqual(result['title'], u'Дежурный ангел (2010 - 2012)')
180 self.assertTrue(len(result['entries']) >= 36)
181
182 def test_ivi_compilation_season(self):
183 dl = FakeYDL()
184 ie = IviCompilationIE(dl)
185 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
186 self.assertIsPlaylist(result)
187 self.assertEqual(result['id'], u'dezhurnyi_angel/season2')
188 self.assertEqual(result['title'], u'Дежурный ангел (2010 - 2012) 2 сезон')
189 self.assertTrue(len(result['entries']) >= 20)
190
191
192 if __name__ == '__main__':
193 unittest.main()