b7c6850fda4436562bee2a5196b903b78b4e4d0b
[youtube-dl] / 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 )
32
33
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')
38
39     def test_dailymotion_playlist(self):
40         dl = FakeYDL()
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)
46
47     def test_dailymotion_user(self):
48         dl = FakeYDL()
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)
54
55     def test_vimeo_channel(self):
56         dl = FakeYDL()
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)
62
63     def test_vimeo_user(self):
64         dl = FakeYDL()
65         ie = VimeoUserIE(dl)
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)
70
71     def test_vimeo_album(self):
72         dl = FakeYDL()
73         ie = VimeoAlbumIE(dl)
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)
78
79     def test_vimeo_groups(self):
80         dl = FakeYDL()
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)
86
87     def test_ustream_channel(self):
88         dl = FakeYDL()
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)
94
95     def test_soundcloud_set(self):
96         dl = FakeYDL()
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)
102
103     def test_soundcloud_user(self):
104         dl = FakeYDL()
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)
110
111     def test_livestream_event(self):
112         dl = FakeYDL()
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)
118
119     def test_nhl_videocenter(self):
120         dl = FakeYDL()
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)
127
128     def test_bambuser_channel(self):
129         dl = FakeYDL()
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)
135
136     def test_bandcamp_album(self):
137         dl = FakeYDL()
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)
143         
144     def test_smotri_community(self):
145         dl = FakeYDL()
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)
152         
153     def test_smotri_user(self):
154         dl = FakeYDL()
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)
161
162     def test_AcademicEarthCourse(self):
163         dl = FakeYDL()
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'], "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)
171
172
173 if __name__ == '__main__':
174     unittest.main()