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