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,
34 class TestPlaylists(unittest.TestCase):
35 def assertIsPlaylist(self, info):
36 """Make sure the info has '_type' set to 'playlist'"""
37 self.assertEqual(info['_type'], 'playlist')
39 def test_dailymotion_playlist(self):
41 ie = DailymotionPlaylistIE(dl)
42 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
43 self.assertIsPlaylist(result)
44 self.assertEqual(result['title'], u'SPORT')
45 self.assertTrue(len(result['entries']) > 20)
47 def test_dailymotion_user(self):
49 ie = DailymotionUserIE(dl)
50 result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
51 self.assertIsPlaylist(result)
52 self.assertEqual(result['title'], u'Génération Quoi')
53 self.assertTrue(len(result['entries']) >= 26)
55 def test_vimeo_channel(self):
57 ie = VimeoChannelIE(dl)
58 result = ie.extract('http://vimeo.com/channels/tributes')
59 self.assertIsPlaylist(result)
60 self.assertEqual(result['title'], u'Vimeo Tributes')
61 self.assertTrue(len(result['entries']) > 24)
63 def test_vimeo_user(self):
66 result = ie.extract('http://vimeo.com/nkistudio/videos')
67 self.assertIsPlaylist(result)
68 self.assertEqual(result['title'], u'Nki')
69 self.assertTrue(len(result['entries']) > 65)
71 def test_vimeo_album(self):
74 result = ie.extract('http://vimeo.com/album/2632481')
75 self.assertIsPlaylist(result)
76 self.assertEqual(result['title'], u'Staff Favorites: November 2013')
77 self.assertTrue(len(result['entries']) > 12)
79 def test_vimeo_groups(self):
81 ie = VimeoGroupsIE(dl)
82 result = ie.extract('http://vimeo.com/groups/rolexawards')
83 self.assertIsPlaylist(result)
84 self.assertEqual(result['title'], u'Rolex Awards for Enterprise')
85 self.assertTrue(len(result['entries']) > 72)
87 def test_ustream_channel(self):
89 ie = UstreamChannelIE(dl)
90 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
91 self.assertIsPlaylist(result)
92 self.assertEqual(result['id'], u'5124905')
93 self.assertTrue(len(result['entries']) >= 11)
95 def test_soundcloud_set(self):
97 ie = SoundcloudSetIE(dl)
98 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
99 self.assertIsPlaylist(result)
100 self.assertEqual(result['title'], u'The Royal Concept EP')
101 self.assertTrue(len(result['entries']) >= 6)
103 def test_soundcloud_user(self):
105 ie = SoundcloudUserIE(dl)
106 result = ie.extract('https://soundcloud.com/the-concept-band')
107 self.assertIsPlaylist(result)
108 self.assertEqual(result['id'], u'9615865')
109 self.assertTrue(len(result['entries']) >= 12)
111 def test_livestream_event(self):
113 ie = LivestreamIE(dl)
114 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
115 self.assertIsPlaylist(result)
116 self.assertEqual(result['title'], u'TEDCity2.0 (English)')
117 self.assertTrue(len(result['entries']) >= 4)
119 def test_nhl_videocenter(self):
121 ie = NHLVideocenterIE(dl)
122 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
123 self.assertIsPlaylist(result)
124 self.assertEqual(result['id'], u'999')
125 self.assertEqual(result['title'], u'Highlights')
126 self.assertEqual(len(result['entries']), 12)
128 def test_bambuser_channel(self):
130 ie = BambuserChannelIE(dl)
131 result = ie.extract('http://bambuser.com/channel/pixelversity')
132 self.assertIsPlaylist(result)
133 self.assertEqual(result['title'], u'pixelversity')
134 self.assertTrue(len(result['entries']) >= 60)
136 def test_bandcamp_album(self):
138 ie = BandcampAlbumIE(dl)
139 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
140 self.assertIsPlaylist(result)
141 self.assertEqual(result['title'], u'Nightmare Night EP')
142 self.assertTrue(len(result['entries']) >= 4)
144 def test_smotri_community(self):
146 ie = SmotriCommunityIE(dl)
147 result = ie.extract('http://smotri.com/community/video/kommuna')
148 self.assertIsPlaylist(result)
149 self.assertEqual(result['id'], u'kommuna')
150 self.assertEqual(result['title'], u'КПРФ')
151 self.assertTrue(len(result['entries']) >= 4)
153 def test_smotri_user(self):
155 ie = SmotriUserIE(dl)
156 result = ie.extract('http://smotri.com/user/inspector')
157 self.assertIsPlaylist(result)
158 self.assertEqual(result['id'], u'inspector')
159 self.assertEqual(result['title'], u'Inspector')
160 self.assertTrue(len(result['entries']) >= 9)
162 def test_AcademicEarthCourse(self):
164 ie = AcademicEarthCourseIE(dl)
165 result = ie.extract(u'http://academicearth.org/courses/building-dynamic-websites/')
166 self.assertIsPlaylist(result)
167 self.assertEqual(result['id'], u'building-dynamic-websites')
168 self.assertEqual(result['title'], u'Building Dynamic Websites')
169 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.")
170 self.assertEqual(len(result['entries']), 10)
173 if __name__ == '__main__':