e22054d6943f9eaa3caf21badc3cff5a456c4e3c
[youtube-dl] / 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 )
19 from youtube_dl.utils import *
20
21 from helper import FakeYDL
22
23 class TestPlaylists(unittest.TestCase):
24     def assertIsPlaylist(self, info):
25         """Make sure the info has '_type' set to 'playlist'"""
26         self.assertEqual(info['_type'], 'playlist')
27
28     def test_dailymotion_playlist(self):
29         dl = FakeYDL()
30         ie = DailymotionPlaylistIE(dl)
31         result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
32         self.assertIsPlaylist(result)
33         self.assertEqual(result['title'], u'SPORT')
34         self.assertTrue(len(result['entries']) > 20)
35     def test_dailymotion_user(self):
36         dl = FakeYDL()
37         ie = DailymotionUserIE(dl)
38         result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
39         self.assertIsPlaylist(result)
40         self.assertEqual(result['title'], u'Génération Quoi')
41         self.assertTrue(len(result['entries']) >= 26)
42
43     def test_vimeo_channel(self):
44         dl = FakeYDL()
45         ie = VimeoChannelIE(dl)
46         result = ie.extract('http://vimeo.com/channels/tributes')
47         self.assertIsPlaylist(result)
48         self.assertEqual(result['title'], u'Vimeo Tributes')
49         self.assertTrue(len(result['entries']) > 24)
50
51     def test_ustream_channel(self):
52         dl = FakeYDL()
53         ie = UstreamChannelIE(dl)
54         result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
55         self.assertIsPlaylist(result)
56         self.assertEqual(result['id'], u'5124905')
57         self.assertTrue(len(result['entries']) >= 11)
58
59     def test_soundcloud_user(self):
60         dl = FakeYDL()
61         ie = SoundcloudUserIE(dl)
62         result = ie.extract('https://soundcloud.com/the-concept-band')
63         self.assertIsPlaylist(result)
64         self.assertEqual(result['id'], u'9615865')
65         self.assertTrue(len(result['entries']) >= 12)
66
67 if __name__ == '__main__':
68     unittest.main()