]> Raphaël G. Git Repositories - youtubedl/blob - test/test_playlists.py
c33511333bd82c2e180bf295587fad3078a755f5
[youtubedl] / test / test_playlists.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3
4 import sys
5 import unittest
6 import json
7
8 # Allow direct execution
9 import os
10 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11
12 from youtube_dl.extractor import (
13 DailymotionPlaylistIE,
14 DailymotionUserIE,
15 VimeoChannelIE,
16 UstreamChannelIE,
17 SoundcloudUserIE,
18 LivestreamIE,
19 )
20 from youtube_dl.utils import *
21
22 from helper import FakeYDL
23
24 class TestPlaylists(unittest.TestCase):
25 def assertIsPlaylist(self, info):
26 """Make sure the info has '_type' set to 'playlist'"""
27 self.assertEqual(info['_type'], 'playlist')
28
29 def test_dailymotion_playlist(self):
30 dl = FakeYDL()
31 ie = DailymotionPlaylistIE(dl)
32 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
33 self.assertIsPlaylist(result)
34 self.assertEqual(result['title'], u'SPORT')
35 self.assertTrue(len(result['entries']) > 20)
36
37 def test_dailymotion_user(self):
38 dl = FakeYDL()
39 ie = DailymotionUserIE(dl)
40 result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
41 self.assertIsPlaylist(result)
42 self.assertEqual(result['title'], u'Génération Quoi')
43 self.assertTrue(len(result['entries']) >= 26)
44
45 def test_vimeo_channel(self):
46 dl = FakeYDL()
47 ie = VimeoChannelIE(dl)
48 result = ie.extract('http://vimeo.com/channels/tributes')
49 self.assertIsPlaylist(result)
50 self.assertEqual(result['title'], u'Vimeo Tributes')
51 self.assertTrue(len(result['entries']) > 24)
52
53 def test_ustream_channel(self):
54 dl = FakeYDL()
55 ie = UstreamChannelIE(dl)
56 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
57 self.assertIsPlaylist(result)
58 self.assertEqual(result['id'], u'5124905')
59 self.assertTrue(len(result['entries']) >= 11)
60
61 def test_soundcloud_user(self):
62 dl = FakeYDL()
63 ie = SoundcloudUserIE(dl)
64 result = ie.extract('https://soundcloud.com/the-concept-band')
65 self.assertIsPlaylist(result)
66 self.assertEqual(result['id'], u'9615865')
67 self.assertTrue(len(result['entries']) >= 12)
68
69 def test_livestream_event(self):
70 dl = FakeYDL()
71 ie = LivestreamIE(dl)
72 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
73 self.assertIsPlaylist(result)
74 self.assertEqual(result['title'], u'TEDCity2.0 (English)')
75 self.assertTrue(len(result['entries']) >= 4)
76
77 if __name__ == '__main__':
78 unittest.main()