]>
Commit | Line | Data |
---|---|---|
9789a05c FV |
1 | #!/usr/bin/env python |
2 | ||
44a5f171 PH |
3 | # Allow direct execution |
4 | import os | |
9789a05c FV |
5 | import sys |
6 | import unittest | |
44a5f171 PH |
7 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
8 | ||
d0efb9ec | 9 | from test.helper import FakeYDL |
9789a05c | 10 | |
9789a05c | 11 | |
44a5f171 | 12 | from youtube_dl.extractor import ( |
44a5f171 PH |
13 | YoutubePlaylistIE, |
14 | YoutubeIE, | |
15 | YoutubeChannelIE, | |
16 | YoutubeShowIE, | |
0a688bc0 | 17 | YoutubeTopListIE, |
c9ae7b95 | 18 | YoutubeSearchURLIE, |
44a5f171 | 19 | ) |
9789a05c | 20 | |
9789a05c FV |
21 | |
22 | class TestYoutubeLists(unittest.TestCase): | |
44a5f171 | 23 | def assertIsPlaylist(self, info): |
8a38a194 JMF |
24 | """Make sure the info has '_type' set to 'playlist'""" |
25 | self.assertEqual(info['_type'], 'playlist') | |
26 | ||
d4d9920a FV |
27 | def test_youtube_playlist_noplaylist(self): |
28 | dl = FakeYDL() | |
29 | dl.params['noplaylist'] = True | |
30 | ie = YoutubePlaylistIE(dl) | |
31 | result = ie.extract('https://www.youtube.com/watch?v=FXxLjLQi3Fg&list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re') | |
32 | self.assertEqual(result['_type'], 'url') | |
97665381 | 33 | self.assertEqual(YoutubeIE().extract_id(result['url']), 'FXxLjLQi3Fg') |
9291475f | 34 | |
9789a05c | 35 | def test_youtube_course(self): |
8bf8b5a5 | 36 | dl = FakeYDL() |
679790ee | 37 | ie = YoutubePlaylistIE(dl) |
9789a05c | 38 | # TODO find a > 100 (paginating?) videos course |
dcbb4580 | 39 | result = ie.extract('https://www.youtube.com/course?list=ECUl4u3cNGP61MdtwGTqZA0MreSaDybji8') |
8a38a194 | 40 | entries = result['entries'] |
97665381 | 41 | self.assertEqual(YoutubeIE().extract_id(entries[0]['url']), 'j9WZyLZCBzs') |
8a38a194 | 42 | self.assertEqual(len(entries), 25) |
97665381 | 43 | self.assertEqual(YoutubeIE().extract_id(entries[-1]['url']), 'rYefUsYuEp0') |
9789a05c | 44 | |
652cdaa2 JMF |
45 | def test_youtube_mix(self): |
46 | dl = FakeYDL() | |
47 | ie = YoutubePlaylistIE(dl) | |
24577db2 | 48 | result = ie.extract('https://www.youtube.com/watch?v=W01L70IGBgE&index=2&list=RDOQpdSVF_k_w') |
652cdaa2 JMF |
49 | entries = result['entries'] |
50 | self.assertTrue(len(entries) >= 20) | |
51 | original_video = entries[0] | |
24577db2 | 52 | self.assertEqual(original_video['id'], 'OQpdSVF_k_w') |
652cdaa2 | 53 | |
d67cc9fa | 54 | def test_youtube_toptracks(self): |
ea5a0be8 JMF |
55 | print('Skipping: The playlist page gives error 500') |
56 | return | |
d67cc9fa JMF |
57 | dl = FakeYDL() |
58 | ie = YoutubePlaylistIE(dl) | |
59 | result = ie.extract('https://www.youtube.com/playlist?list=MCUS') | |
60 | entries = result['entries'] | |
61 | self.assertEqual(len(entries), 100) | |
62 | ||
9789a05c FV |
63 | if __name__ == '__main__': |
64 | unittest.main() |