8 # Allow direct execution
10 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
12 from youtube_dl.extractor import (
13 DailymotionPlaylistIE,
21 from youtube_dl.utils import *
23 from helper import FakeYDL
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')
30 def test_dailymotion_playlist(self):
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)
38 def test_dailymotion_user(self):
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)
46 def test_vimeo_channel(self):
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)
54 def test_ustream_channel(self):
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)
62 def test_soundcloud_user(self):
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)
70 def test_livestream_event(self):
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)
78 def test_nhl_videocenter(self):
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)
87 if __name__ == '__main__':