Merge remote-tracking branch 'epitron/metadata-pp'
[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     IviCompilationIE,
32     ImdbListIE,
33 )
34
35
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')
40
41     def test_dailymotion_playlist(self):
42         dl = FakeYDL()
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)
48
49     def test_dailymotion_user(self):
50         dl = FakeYDL()
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)
56
57     def test_vimeo_channel(self):
58         dl = FakeYDL()
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)
64
65     def test_vimeo_user(self):
66         dl = FakeYDL()
67         ie = VimeoUserIE(dl)
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)
72
73     def test_vimeo_album(self):
74         dl = FakeYDL()
75         ie = VimeoAlbumIE(dl)
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)
80
81     def test_vimeo_groups(self):
82         dl = FakeYDL()
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)
88
89     def test_ustream_channel(self):
90         dl = FakeYDL()
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)
96
97     def test_soundcloud_set(self):
98         dl = FakeYDL()
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)
104
105     def test_soundcloud_user(self):
106         dl = FakeYDL()
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)
112
113     def test_livestream_event(self):
114         dl = FakeYDL()
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)
120
121     def test_nhl_videocenter(self):
122         dl = FakeYDL()
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)
129
130     def test_bambuser_channel(self):
131         dl = FakeYDL()
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)
137
138     def test_bandcamp_album(self):
139         dl = FakeYDL()
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)
145         
146     def test_smotri_community(self):
147         dl = FakeYDL()
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)
154         
155     def test_smotri_user(self):
156         dl = FakeYDL()
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)
163
164     def test_AcademicEarthCourse(self):
165         dl = FakeYDL()
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)
173         
174     def test_ivi_compilation(self):
175         dl = FakeYDL()
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)
182         
183     def test_ivi_compilation_season(self):
184         dl = FakeYDL()
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)
191         
192     def test_imdb_list(self):
193         dl = FakeYDL()
194         ie = ImdbListIE(dl)
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)
200
201
202 if __name__ == '__main__':
203     unittest.main()