]>
Raphaƫl G. Git Repositories - youtubedl/blob - test/test_youtube_lists.py
a11a59ed761b58a8cf0b37a584a93642d1d867ff
7 # Allow direct execution
9 sys
.path
.append(os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
11 from youtube_dl
.InfoExtractors
import YoutubePlaylistIE
12 from youtube_dl
.utils
import *
14 # General configuration (from __init__, not very elegant...)
15 jar
= compat_cookiejar
.CookieJar()
16 cookie_processor
= compat_urllib_request
.HTTPCookieProcessor(jar
)
17 proxy_handler
= compat_urllib_request
.ProxyHandler()
18 opener
= compat_urllib_request
.build_opener(proxy_handler
, cookie_processor
, YoutubeDLHandler())
19 compat_urllib_request
.install_opener(opener
)
20 socket
.setdefaulttimeout(300) # 5 minutes should be enough (famous last words)
22 class FakeDownloader(object):
26 def to_screen(self
, s
):
30 def download(self
, x
):
33 class TestYoutubeLists(unittest
.TestCase
):
34 def test_youtube_playlist(self
):
36 IE
= YoutubePlaylistIE(DL
)
37 IE
.extract('https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re')
38 self
.assertEqual(DL
.result
, [
39 ['http://www.youtube.com/watch?v=bV9L5Ht9LgY'],
40 ['http://www.youtube.com/watch?v=FXxLjLQi3Fg'],
41 ['http://www.youtube.com/watch?v=tU3Bgo5qJZE']
44 def test_youtube_playlist_long(self
):
46 IE
= YoutubePlaylistIE(DL
)
47 IE
.extract('https://www.youtube.com/playlist?list=UUBABnxM4Ar9ten8Mdjj1j0Q')
48 self
.assertTrue(len(DL
.result
) >= 799)
50 def test_youtube_course(self
):
52 IE
= YoutubePlaylistIE(DL
)
53 # TODO find a > 100 (paginating?) videos course
54 IE
.extract('https://www.youtube.com/course?list=ECUl4u3cNGP61MdtwGTqZA0MreSaDybji8')
55 self
.assertEqual(DL
.result
[0], ['http://www.youtube.com/watch?v=j9WZyLZCBzs'])
56 self
.assertEqual(len(DL
.result
), 25)
57 self
.assertEqual(DL
.result
[-1], ['http://www.youtube.com/watch?v=rYefUsYuEp0'])
59 def test_youtube_channel(self
):
60 """I give up, please find a channel that does paginate and test this like test_youtube_playlist_long"""
63 def test_youtube_user(self
):
65 IE
= YoutubePlaylistIE(DL
)
66 IE
.extract('https://www.youtube.com/user/TheLinuxFoundation')
67 self
.assertTrue(len(DL
.result
) >= 320)
69 if __name__
== '__main__':