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