5 # Allow direct execution
9 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11 from test.helper import FakeYDL
14 from youtube_dl.extractor import (
15 AcademicEarthCourseIE,
16 DailymotionPlaylistIE,
36 class TestPlaylists(unittest.TestCase):
37 def assertIsPlaylist(self, info):
38 """Make sure the info has '_type' set to 'playlist'"""
39 self.assertEqual(info['_type'], 'playlist')
41 def test_dailymotion_playlist(self):
43 ie = DailymotionPlaylistIE(dl)
44 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
45 self.assertIsPlaylist(result)
46 self.assertEqual(result['title'], u'SPORT')
47 self.assertTrue(len(result['entries']) > 20)
49 def test_dailymotion_user(self):
51 ie = DailymotionUserIE(dl)
52 result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
53 self.assertIsPlaylist(result)
54 self.assertEqual(result['title'], u'Génération Quoi')
55 self.assertTrue(len(result['entries']) >= 26)
57 def test_vimeo_channel(self):
59 ie = VimeoChannelIE(dl)
60 result = ie.extract('http://vimeo.com/channels/tributes')
61 self.assertIsPlaylist(result)
62 self.assertEqual(result['title'], u'Vimeo Tributes')
63 self.assertTrue(len(result['entries']) > 24)
65 def test_vimeo_user(self):
68 result = ie.extract('http://vimeo.com/nkistudio/videos')
69 self.assertIsPlaylist(result)
70 self.assertEqual(result['title'], u'Nki')
71 self.assertTrue(len(result['entries']) > 65)
73 def test_vimeo_album(self):
76 result = ie.extract('http://vimeo.com/album/2632481')
77 self.assertIsPlaylist(result)
78 self.assertEqual(result['title'], u'Staff Favorites: November 2013')
79 self.assertTrue(len(result['entries']) > 12)
81 def test_vimeo_groups(self):
83 ie = VimeoGroupsIE(dl)
84 result = ie.extract('http://vimeo.com/groups/rolexawards')
85 self.assertIsPlaylist(result)
86 self.assertEqual(result['title'], u'Rolex Awards for Enterprise')
87 self.assertTrue(len(result['entries']) > 72)
89 def test_ustream_channel(self):
91 ie = UstreamChannelIE(dl)
92 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
93 self.assertIsPlaylist(result)
94 self.assertEqual(result['id'], u'5124905')
95 self.assertTrue(len(result['entries']) >= 11)
97 def test_soundcloud_set(self):
99 ie = SoundcloudSetIE(dl)
100 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
101 self.assertIsPlaylist(result)
102 self.assertEqual(result['title'], u'The Royal Concept EP')
103 self.assertTrue(len(result['entries']) >= 6)
105 def test_soundcloud_user(self):
107 ie = SoundcloudUserIE(dl)
108 result = ie.extract('https://soundcloud.com/the-concept-band')
109 self.assertIsPlaylist(result)
110 self.assertEqual(result['id'], u'9615865')
111 self.assertTrue(len(result['entries']) >= 12)
113 def test_livestream_event(self):
115 ie = LivestreamIE(dl)
116 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
117 self.assertIsPlaylist(result)
118 self.assertEqual(result['title'], u'TEDCity2.0 (English)')
119 self.assertTrue(len(result['entries']) >= 4)
121 def test_nhl_videocenter(self):
123 ie = NHLVideocenterIE(dl)
124 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
125 self.assertIsPlaylist(result)
126 self.assertEqual(result['id'], u'999')
127 self.assertEqual(result['title'], u'Highlights')
128 self.assertEqual(len(result['entries']), 12)
130 def test_bambuser_channel(self):
132 ie = BambuserChannelIE(dl)
133 result = ie.extract('http://bambuser.com/channel/pixelversity')
134 self.assertIsPlaylist(result)
135 self.assertEqual(result['title'], u'pixelversity')
136 self.assertTrue(len(result['entries']) >= 60)
138 def test_bandcamp_album(self):
140 ie = BandcampAlbumIE(dl)
141 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
142 self.assertIsPlaylist(result)
143 self.assertEqual(result['title'], u'Nightmare Night EP')
144 self.assertTrue(len(result['entries']) >= 4)
146 def test_smotri_community(self):
148 ie = SmotriCommunityIE(dl)
149 result = ie.extract('http://smotri.com/community/video/kommuna')
150 self.assertIsPlaylist(result)
151 self.assertEqual(result['id'], u'kommuna')
152 self.assertEqual(result['title'], u'КПРФ')
153 self.assertTrue(len(result['entries']) >= 4)
155 def test_smotri_user(self):
157 ie = SmotriUserIE(dl)
158 result = ie.extract('http://smotri.com/user/inspector')
159 self.assertIsPlaylist(result)
160 self.assertEqual(result['id'], u'inspector')
161 self.assertEqual(result['title'], u'Inspector')
162 self.assertTrue(len(result['entries']) >= 9)
164 def test_AcademicEarthCourse(self):
166 ie = AcademicEarthCourseIE(dl)
167 result = ie.extract(u'http://academicearth.org/courses/building-dynamic-websites/')
168 self.assertIsPlaylist(result)
169 self.assertEqual(result['id'], u'building-dynamic-websites')
170 self.assertEqual(result['title'], u'Building Dynamic Websites')
171 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.")
172 self.assertEqual(len(result['entries']), 10)
174 def test_ivi_compilation(self):
176 ie = IviCompilationIE(dl)
177 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
178 self.assertIsPlaylist(result)
179 self.assertEqual(result['id'], u'dezhurnyi_angel')
180 self.assertEqual(result['title'], u'Дежурный ангел (2010 - 2012)')
181 self.assertTrue(len(result['entries']) >= 36)
183 def test_ivi_compilation_season(self):
185 ie = IviCompilationIE(dl)
186 result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
187 self.assertIsPlaylist(result)
188 self.assertEqual(result['id'], u'dezhurnyi_angel/season2')
189 self.assertEqual(result['title'], u'Дежурный ангел (2010 - 2012) 2 сезон')
190 self.assertTrue(len(result['entries']) >= 20)
192 def test_imdb_list(self):
195 result = ie.extract('http://www.imdb.com/list/sMjedvGDd8U')
196 self.assertIsPlaylist(result)
197 self.assertEqual(result['id'], u'sMjedvGDd8U')
198 self.assertEqual(result['title'], u'Animated and Family Films')
199 self.assertTrue(len(result['entries']) >= 48)
202 if __name__ == '__main__':