]>
Raphaƫl G. Git Repositories - youtubedl/blob - test/test_youtube_lists.py
2 from __future__
import unicode_literals
4 # Allow direct execution
8 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
10 from test
.helper
import FakeYDL
13 from youtube_dl
.extractor
import (
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')
24 def test_youtube_playlist_noplaylist(self
):
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')
32 def test_youtube_course(self
):
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')
42 def test_youtube_mix(self
):
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')
51 def test_youtube_toptracks(self
):
52 print('Skipping: The playlist page gives error 500')
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)
60 if __name__
== '__main__':