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