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