]> Raphaël G. Git Repositories - youtubedl/blob - test/test_playlists.py
706b6bdca1399284263106b755fdf9278c5d17d5
[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, global_setup
12 global_setup()
13
14
15 from youtube_dl.extractor import (
16 DailymotionPlaylistIE,
17 DailymotionUserIE,
18 VimeoChannelIE,
19 UstreamChannelIE,
20 SoundcloudSetIE,
21 SoundcloudUserIE,
22 LivestreamIE,
23 NHLVideocenterIE,
24 BambuserChannelIE,
25 )
26
27
28 class TestPlaylists(unittest.TestCase):
29 def assertIsPlaylist(self, info):
30 """Make sure the info has '_type' set to 'playlist'"""
31 self.assertEqual(info['_type'], 'playlist')
32
33 def test_dailymotion_playlist(self):
34 dl = FakeYDL()
35 ie = DailymotionPlaylistIE(dl)
36 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
37 self.assertIsPlaylist(result)
38 self.assertEqual(result['title'], u'SPORT')
39 self.assertTrue(len(result['entries']) > 20)
40
41 def test_dailymotion_user(self):
42 dl = FakeYDL()
43 ie = DailymotionUserIE(dl)
44 result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
45 self.assertIsPlaylist(result)
46 self.assertEqual(result['title'], u'Génération Quoi')
47 self.assertTrue(len(result['entries']) >= 26)
48
49 def test_vimeo_channel(self):
50 dl = FakeYDL()
51 ie = VimeoChannelIE(dl)
52 result = ie.extract('http://vimeo.com/channels/tributes')
53 self.assertIsPlaylist(result)
54 self.assertEqual(result['title'], u'Vimeo Tributes')
55 self.assertTrue(len(result['entries']) > 24)
56
57 def test_ustream_channel(self):
58 dl = FakeYDL()
59 ie = UstreamChannelIE(dl)
60 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
61 self.assertIsPlaylist(result)
62 self.assertEqual(result['id'], u'5124905')
63 self.assertTrue(len(result['entries']) >= 11)
64
65 def test_soundcloud_set(self):
66 dl = FakeYDL()
67 ie = SoundcloudSetIE(dl)
68 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
69 self.assertIsPlaylist(result)
70 self.assertEqual(result['title'], u'The Royal Concept EP')
71 self.assertTrue(len(result['entries']) >= 6)
72
73 def test_soundcloud_user(self):
74 dl = FakeYDL()
75 ie = SoundcloudUserIE(dl)
76 result = ie.extract('https://soundcloud.com/the-concept-band')
77 self.assertIsPlaylist(result)
78 self.assertEqual(result['id'], u'9615865')
79 self.assertTrue(len(result['entries']) >= 12)
80
81 def test_livestream_event(self):
82 dl = FakeYDL()
83 ie = LivestreamIE(dl)
84 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
85 self.assertIsPlaylist(result)
86 self.assertEqual(result['title'], u'TEDCity2.0 (English)')
87 self.assertTrue(len(result['entries']) >= 4)
88
89 def test_nhl_videocenter(self):
90 dl = FakeYDL()
91 ie = NHLVideocenterIE(dl)
92 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
93 self.assertIsPlaylist(result)
94 self.assertEqual(result['id'], u'999')
95 self.assertEqual(result['title'], u'Highlights')
96 self.assertEqual(len(result['entries']), 12)
97
98 def test_bambuser_channel(self):
99 dl = FakeYDL()
100 ie = BambuserChannelIE(dl)
101 result = ie.extract('http://bambuser.com/channel/pixelversity')
102 self.assertIsPlaylist(result)
103 self.assertEqual(result['title'], u'pixelversity')
104 self.assertTrue(len(result['entries']) >= 66)
105
106 if __name__ == '__main__':
107 unittest.main()