]>
Raphaƫl G. Git Repositories - youtubedl/blob - test/test_youtube_lists.py
3 # Allow direct execution
7 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
9 from test
.helper
import FakeYDL
12 from youtube_dl
.extractor
import (
22 class TestYoutubeLists(unittest
.TestCase
):
23 def assertIsPlaylist(self
, info
):
24 """Make sure the info has '_type' set to 'playlist'"""
25 self
.assertEqual(info
['_type'], 'playlist')
27 def test_youtube_playlist_noplaylist(self
):
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')
33 self
.assertEqual(YoutubeIE().extract_id(result
['url']), 'FXxLjLQi3Fg')
35 def test_youtube_course(self
):
37 ie
= YoutubePlaylistIE(dl
)
38 # TODO find a > 100 (paginating?) videos course
39 result
= ie
.extract('https://www.youtube.com/course?list=ECUl4u3cNGP61MdtwGTqZA0MreSaDybji8')
40 entries
= result
['entries']
41 self
.assertEqual(YoutubeIE().extract_id(entries
[0]['url']), 'j9WZyLZCBzs')
42 self
.assertEqual(len(entries
), 25)
43 self
.assertEqual(YoutubeIE().extract_id(entries
[-1]['url']), 'rYefUsYuEp0')
45 def test_youtube_mix(self
):
47 ie
= YoutubePlaylistIE(dl
)
48 result
= ie
.extract('https://www.youtube.com/watch?v=W01L70IGBgE&index=2&list=RDOQpdSVF_k_w')
49 entries
= result
['entries']
50 self
.assertTrue(len(entries
) >= 20)
51 original_video
= entries
[0]
52 self
.assertEqual(original_video
['id'], 'OQpdSVF_k_w')
54 def test_youtube_toptracks(self
):
55 print('Skipping: The playlist page gives error 500')
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)
63 if __name__
== '__main__':