]> Raphaƫl G. Git Repositories - youtubedl/blob - test/test_youtube_lists.py
debian/NEWS: Document that the --max-quality option is gone.
[youtubedl] / test / test_youtube_lists.py
1 #!/usr/bin/env python
2 from __future__ import unicode_literals
3
4 # Allow direct execution
5 import os
6 import sys
7 import unittest
8 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
9
10 from test.helper import FakeYDL
11
12
13 from youtube_dl.extractor import (
14 YoutubePlaylistIE,
15 YoutubeIE,
16 )
17
18
19 class TestYoutubeLists(unittest.TestCase):
20 def assertIsPlaylist(self, info):
21 """Make sure the info has '_type' set to 'playlist'"""
22 self.assertEqual(info['_type'], 'playlist')
23
24 def test_youtube_playlist_noplaylist(self):
25 dl = FakeYDL()
26 dl.params['noplaylist'] = True
27 ie = YoutubePlaylistIE(dl)
28 result = ie.extract('https://www.youtube.com/watch?v=FXxLjLQi3Fg&list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re')
29 self.assertEqual(result['_type'], 'url')
30 self.assertEqual(YoutubeIE().extract_id(result['url']), 'FXxLjLQi3Fg')
31
32 def test_youtube_course(self):
33 dl = FakeYDL()
34 ie = YoutubePlaylistIE(dl)
35 # TODO find a > 100 (paginating?) videos course
36 result = ie.extract('https://www.youtube.com/course?list=ECUl4u3cNGP61MdtwGTqZA0MreSaDybji8')
37 entries = result['entries']
38 self.assertEqual(YoutubeIE().extract_id(entries[0]['url']), 'j9WZyLZCBzs')
39 self.assertEqual(len(entries), 25)
40 self.assertEqual(YoutubeIE().extract_id(entries[-1]['url']), 'rYefUsYuEp0')
41
42 def test_youtube_mix(self):
43 dl = FakeYDL()
44 ie = YoutubePlaylistIE(dl)
45 result = ie.extract('https://www.youtube.com/watch?v=W01L70IGBgE&index=2&list=RDOQpdSVF_k_w')
46 entries = result['entries']
47 self.assertTrue(len(entries) >= 20)
48 original_video = entries[0]
49 self.assertEqual(original_video['id'], 'OQpdSVF_k_w')
50
51 def test_youtube_toptracks(self):
52 print('Skipping: The playlist page gives error 500')
53 return
54 dl = FakeYDL()
55 ie = YoutubePlaylistIE(dl)
56 result = ie.extract('https://www.youtube.com/playlist?list=MCUS')
57 entries = result['entries']
58 self.assertEqual(len(entries), 100)
59
60 if __name__ == '__main__':
61 unittest.main()