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