]> jfr.im git - yt-dlp.git/blob - test/test_playlists.py
7c67239a438917fd6e64af152cb63c124ff6721c
[yt-dlp.git] / 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 SoundcloudSetIE,
21 SoundcloudUserIE,
22 LivestreamIE,
23 NHLVideocenterIE,
24 BambuserChannelIE,
25 BandcampAlbumIE
26 )
27
28
29 class TestPlaylists(unittest.TestCase):
30 def assertIsPlaylist(self, info):
31 """Make sure the info has '_type' set to 'playlist'"""
32 self.assertEqual(info['_type'], 'playlist')
33
34 def test_dailymotion_playlist(self):
35 dl = FakeYDL()
36 ie = DailymotionPlaylistIE(dl)
37 result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
38 self.assertIsPlaylist(result)
39 self.assertEqual(result['title'], u'SPORT')
40 self.assertTrue(len(result['entries']) > 20)
41
42 def test_dailymotion_user(self):
43 dl = FakeYDL()
44 ie = DailymotionUserIE(dl)
45 result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
46 self.assertIsPlaylist(result)
47 self.assertEqual(result['title'], u'Génération Quoi')
48 self.assertTrue(len(result['entries']) >= 26)
49
50 def test_vimeo_channel(self):
51 dl = FakeYDL()
52 ie = VimeoChannelIE(dl)
53 result = ie.extract('http://vimeo.com/channels/tributes')
54 self.assertIsPlaylist(result)
55 self.assertEqual(result['title'], u'Vimeo Tributes')
56 self.assertTrue(len(result['entries']) > 24)
57
58 def test_ustream_channel(self):
59 dl = FakeYDL()
60 ie = UstreamChannelIE(dl)
61 result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
62 self.assertIsPlaylist(result)
63 self.assertEqual(result['id'], u'5124905')
64 self.assertTrue(len(result['entries']) >= 11)
65
66 def test_soundcloud_set(self):
67 dl = FakeYDL()
68 ie = SoundcloudSetIE(dl)
69 result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
70 self.assertIsPlaylist(result)
71 self.assertEqual(result['title'], u'The Royal Concept EP')
72 self.assertTrue(len(result['entries']) >= 6)
73
74 def test_soundcloud_user(self):
75 dl = FakeYDL()
76 ie = SoundcloudUserIE(dl)
77 result = ie.extract('https://soundcloud.com/the-concept-band')
78 self.assertIsPlaylist(result)
79 self.assertEqual(result['id'], u'9615865')
80 self.assertTrue(len(result['entries']) >= 12)
81
82 def test_livestream_event(self):
83 dl = FakeYDL()
84 ie = LivestreamIE(dl)
85 result = ie.extract('http://new.livestream.com/tedx/cityenglish')
86 self.assertIsPlaylist(result)
87 self.assertEqual(result['title'], u'TEDCity2.0 (English)')
88 self.assertTrue(len(result['entries']) >= 4)
89
90 def test_nhl_videocenter(self):
91 dl = FakeYDL()
92 ie = NHLVideocenterIE(dl)
93 result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
94 self.assertIsPlaylist(result)
95 self.assertEqual(result['id'], u'999')
96 self.assertEqual(result['title'], u'Highlights')
97 self.assertEqual(len(result['entries']), 12)
98
99 def test_bambuser_channel(self):
100 dl = FakeYDL()
101 ie = BambuserChannelIE(dl)
102 result = ie.extract('http://bambuser.com/channel/pixelversity')
103 self.assertIsPlaylist(result)
104 self.assertEqual(result['title'], u'pixelversity')
105 self.assertTrue(len(result['entries']) >= 60)
106
107 def test_bandcamp_album(self):
108 dl = FakeYDL()
109 ie = BandcampAlbumIE(dl)
110 result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
111 self.assertIsPlaylist(result)
112 self.assertEqual(result['title'], u'Nightmare Night EP')
113 self.assertTrue(len(result['entries']) >= 4)
114
115 if __name__ == '__main__':
116 unittest.main()