[vimeo] Add an extractor for albums (closes #1911)
[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     DailymotionPlaylistIE,
16     DailymotionUserIE,
17     VimeoChannelIE,
18     VimeoUserIE,
19     VimeoAlbumIE,
20     UstreamChannelIE,
21     SoundcloudSetIE,
22     SoundcloudUserIE,
23     LivestreamIE,
24     NHLVideocenterIE,
25     BambuserChannelIE,
26     BandcampAlbumIE,
27     SmotriCommunityIE,
28     SmotriUserIE
29 )
30
31
32 class TestPlaylists(unittest.TestCase):
33     def assertIsPlaylist(self, info):
34         """Make sure the info has '_type' set to 'playlist'"""
35         self.assertEqual(info['_type'], 'playlist')
36
37     def test_dailymotion_playlist(self):
38         dl = FakeYDL()
39         ie = DailymotionPlaylistIE(dl)
40         result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
41         self.assertIsPlaylist(result)
42         self.assertEqual(result['title'], u'SPORT')
43         self.assertTrue(len(result['entries']) > 20)
44
45     def test_dailymotion_user(self):
46         dl = FakeYDL()
47         ie = DailymotionUserIE(dl)
48         result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
49         self.assertIsPlaylist(result)
50         self.assertEqual(result['title'], u'Génération Quoi')
51         self.assertTrue(len(result['entries']) >= 26)
52
53     def test_vimeo_channel(self):
54         dl = FakeYDL()
55         ie = VimeoChannelIE(dl)
56         result = ie.extract('http://vimeo.com/channels/tributes')
57         self.assertIsPlaylist(result)
58         self.assertEqual(result['title'], u'Vimeo Tributes')
59         self.assertTrue(len(result['entries']) > 24)
60
61     def test_vimeo_user(self):
62         dl = FakeYDL()
63         ie = VimeoUserIE(dl)
64         result = ie.extract('http://vimeo.com/nkistudio/videos')
65         self.assertIsPlaylist(result)
66         self.assertEqual(result['title'], u'Nki')
67         self.assertTrue(len(result['entries']) > 65)
68
69     def test_vimeo_album(self):
70         dl = FakeYDL()
71         ie = VimeoAlbumIE(dl)
72         result = ie.extract('http://vimeo.com/album/2632481')
73         self.assertIsPlaylist(result)
74         self.assertEqual(result['title'], u'Staff Favorites: November 2013')
75         self.assertTrue(len(result['entries']) > 12)
76
77     def test_ustream_channel(self):
78         dl = FakeYDL()
79         ie = UstreamChannelIE(dl)
80         result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
81         self.assertIsPlaylist(result)
82         self.assertEqual(result['id'], u'5124905')
83         self.assertTrue(len(result['entries']) >= 11)
84
85     def test_soundcloud_set(self):
86         dl = FakeYDL()
87         ie = SoundcloudSetIE(dl)
88         result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
89         self.assertIsPlaylist(result)
90         self.assertEqual(result['title'], u'The Royal Concept EP')
91         self.assertTrue(len(result['entries']) >= 6)
92
93     def test_soundcloud_user(self):
94         dl = FakeYDL()
95         ie = SoundcloudUserIE(dl)
96         result = ie.extract('https://soundcloud.com/the-concept-band')
97         self.assertIsPlaylist(result)
98         self.assertEqual(result['id'], u'9615865')
99         self.assertTrue(len(result['entries']) >= 12)
100
101     def test_livestream_event(self):
102         dl = FakeYDL()
103         ie = LivestreamIE(dl)
104         result = ie.extract('http://new.livestream.com/tedx/cityenglish')
105         self.assertIsPlaylist(result)
106         self.assertEqual(result['title'], u'TEDCity2.0 (English)')
107         self.assertTrue(len(result['entries']) >= 4)
108
109     def test_nhl_videocenter(self):
110         dl = FakeYDL()
111         ie = NHLVideocenterIE(dl)
112         result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
113         self.assertIsPlaylist(result)
114         self.assertEqual(result['id'], u'999')
115         self.assertEqual(result['title'], u'Highlights')
116         self.assertEqual(len(result['entries']), 12)
117
118     def test_bambuser_channel(self):
119         dl = FakeYDL()
120         ie = BambuserChannelIE(dl)
121         result = ie.extract('http://bambuser.com/channel/pixelversity')
122         self.assertIsPlaylist(result)
123         self.assertEqual(result['title'], u'pixelversity')
124         self.assertTrue(len(result['entries']) >= 60)
125
126     def test_bandcamp_album(self):
127         dl = FakeYDL()
128         ie = BandcampAlbumIE(dl)
129         result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
130         self.assertIsPlaylist(result)
131         self.assertEqual(result['title'], u'Nightmare Night EP')
132         self.assertTrue(len(result['entries']) >= 4)
133         
134     def test_smotri_community(self):
135         dl = FakeYDL()
136         ie = SmotriCommunityIE(dl)
137         result = ie.extract('http://smotri.com/community/video/kommuna')
138         self.assertIsPlaylist(result)
139         self.assertEqual(result['id'], u'kommuna')
140         self.assertEqual(result['title'], u'КПРФ')
141         self.assertTrue(len(result['entries']) >= 4)
142         
143     def test_smotri_user(self):
144         dl = FakeYDL()
145         ie = SmotriUserIE(dl)
146         result = ie.extract('http://smotri.com/user/inspector')
147         self.assertIsPlaylist(result)
148         self.assertEqual(result['id'], u'inspector')
149         self.assertEqual(result['title'], u'Inspector')
150         self.assertTrue(len(result['entries']) >= 9)
151
152 if __name__ == '__main__':
153     unittest.main()