]>
jfr.im git - yt-dlp.git/blob - test/test_download.py
3 # DO NOT EDIT THIS FILE BY HAND!
4 # It is auto-generated from tests.json and gentests.py.
13 # Allow direct execution
15 sys
.path
.append(os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
17 from youtube_dl
.FileDownloader
import FileDownloader
18 import youtube_dl
.InfoExtractors
21 with open(fn
, 'rb') as f
:
22 return hashlib
.md5(f
.read()).hexdigest()
24 def md5_for_file(filename
, block_size
=2**20):
25 with open(filename
) as f
:
28 data
= f
.read(block_size
)
32 return md5
.hexdigest()
33 _file_md5
= md5_for_file
37 _skip_unless
= unittest
.skipUnless
38 except AttributeError: # Python 2.6
39 def _skip_unless(cond
, reason
='No reason given'):
41 def wfunc(*args
, **kwargs
):
43 return f(*args
, **kwargs
)
49 _skip
= lambda *args
, **kwargs
: _skip_unless(False, *args
, **kwargs
)
51 class DownloadTest(unittest
.TestCase
):
52 PARAMETERS_FILE
= os
.path
.join(os
.path
.dirname(os
.path
.abspath(__file__
)), "parameters.json")
58 with io
.open(self
.PARAMETERS_FILE
, encoding
='utf-8') as pf
:
59 self
.parameters
= json
.load(pf
)
61 @_skip_unless(youtube_dl
.InfoExtractors
.YoutubeIE
._WORKING
, "IE marked as not _WORKING")
62 def test_Youtube(self
):
63 filename
= 'BaW_jenozKc.mp4'
64 fd
= FileDownloader(self
.parameters
)
65 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.YoutubeIE())
66 fd
.download(['http://www.youtube.com/watch?v=BaW_jenozKc'])
67 self
.assertTrue(os
.path
.exists(filename
))
68 self
.assertEqual(os
.path
.getsize(filename
), 1993883)
70 @_skip_unless(youtube_dl
.InfoExtractors
.DailymotionIE
._WORKING
, "IE marked as not _WORKING")
71 def test_Dailymotion(self
):
72 filename
= 'x33vw9.mp4'
73 fd
= FileDownloader(self
.parameters
)
74 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.DailymotionIE())
75 fd
.download(['http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech'])
76 self
.assertTrue(os
.path
.exists(filename
))
77 md5_for_file
= _file_md5(filename
)
78 self
.assertEqual(md5_for_file
, 'd363a50e9eb4f22ce90d08d15695bb47')
80 @_skip_unless(youtube_dl
.InfoExtractors
.MetacafeIE
._WORKING
, "IE marked as not _WORKING")
81 def test_Metacafe(self
):
82 filename
= 'aUehQsCQtM.flv'
83 fd
= FileDownloader(self
.parameters
)
84 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.MetacafeIE())
85 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.YoutubeIE())
86 fd
.download(['http://www.metacafe.com/watch/yt-_aUehQsCQtM/the_electric_company_short_i_pbs_kids_go/'])
87 self
.assertTrue(os
.path
.exists(filename
))
88 self
.assertEqual(os
.path
.getsize(filename
), 5754305)
90 @_skip_unless(youtube_dl
.InfoExtractors
.BlipTVIE
._WORKING
, "IE marked as not _WORKING")
91 def test_BlipTV(self
):
92 filename
= '5779306.m4v'
93 fd
= FileDownloader(self
.parameters
)
94 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.BlipTVIE())
95 fd
.download(['http://blip.tv/cbr/cbr-exclusive-gotham-city-imposters-bats-vs-jokerz-short-3-5796352'])
96 self
.assertTrue(os
.path
.exists(filename
))
97 md5_for_file
= _file_md5(filename
)
98 self
.assertEqual(md5_for_file
, '4962f94441605832eb1008eb820ef47a')
100 @_skip_unless(youtube_dl
.InfoExtractors
.XVideosIE
._WORKING
, "IE marked as not _WORKING")
101 def test_XVideos(self
):
102 filename
= '939581.flv'
103 fd
= FileDownloader(self
.parameters
)
104 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.XVideosIE())
105 fd
.download(['http://www.xvideos.com/video939581/funny_porns_by_s_-1'])
106 self
.assertTrue(os
.path
.exists(filename
))
107 md5_for_file
= _file_md5(filename
)
108 self
.assertEqual(md5_for_file
, 'aecab2ea59b7996110a7e409f0c55da3')
110 @_skip_unless(youtube_dl
.InfoExtractors
.VimeoIE
._WORKING
, "IE marked as not _WORKING")
111 @_skip("No output file specified")
112 def test_Vimeo(self
):
114 fd
= FileDownloader(self
.parameters
)
115 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.VimeoIE())
116 fd
.download(['http://vimeo.com/14160053'])
117 self
.assertTrue(os
.path
.exists(filename
))
118 md5_for_file
= _file_md5(filename
)
119 self
.assertEqual(md5_for_file
, '1ab4dedc01f771cb2a65e91caa801aaf')
121 @_skip_unless(youtube_dl
.InfoExtractors
.SoundcloudIE
._WORKING
, "IE marked as not _WORKING")
122 def test_Soundcloud(self
):
123 filename
= 'n6FLbx6ZzMiu.mp3'
124 fd
= FileDownloader(self
.parameters
)
125 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.SoundcloudIE())
126 fd
.download(['http://soundcloud.com/ethmusic/lostin-powers-she-so-heavy'])
127 self
.assertTrue(os
.path
.exists(filename
))
128 md5_for_file
= _file_md5(filename
)
129 self
.assertEqual(md5_for_file
, 'c1b9b9ea8bfd620b96b2628664576e1c')
131 @_skip_unless(youtube_dl
.InfoExtractors
.StanfordOpenClassroomIE
._WORKING
, "IE marked as not _WORKING")
132 def test_StanfordOpenClassroom(self
):
133 filename
= 'PracticalUnix_intro-environment.mp4'
134 fd
= FileDownloader(self
.parameters
)
135 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.StanfordOpenClassroomIE())
136 fd
.download(['http://openclassroom.stanford.edu/MainFolder/VideoPage.php?course=PracticalUnix&video=intro-environment&speed=100'])
137 self
.assertTrue(os
.path
.exists(filename
))
138 md5_for_file
= _file_md5(filename
)
139 self
.assertEqual(md5_for_file
, '8aac7873a07dcfaed66b1559ab128514')
141 @_skip_unless(youtube_dl
.InfoExtractors
.CollegeHumorIE
._WORKING
, "IE marked as not _WORKING")
142 @_skip("No output file specified")
143 def test_CollegeHumor(self
):
145 fd
= FileDownloader(self
.parameters
)
146 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.CollegeHumorIE())
147 fd
.download(['http://www.collegehumor.com/video/6830834/mitt-romney-style-gangnam-style-parody'])
148 self
.assertTrue(os
.path
.exists(filename
))
149 md5_for_file
= _file_md5(filename
)
150 self
.assertEqual(md5_for_file
, '')
152 @_skip_unless(youtube_dl
.InfoExtractors
.XNXXIE
._WORKING
, "IE marked as not _WORKING")
154 filename
= '1135332.flv'
155 fd
= FileDownloader(self
.parameters
)
156 fd
.add_info_extractor(youtube_dl
.InfoExtractors
.XNXXIE())
157 fd
.download(['http://video.xnxx.com/video1135332/lida_naked_funny_actress_5_'])
158 self
.assertTrue(os
.path
.exists(filename
))
159 md5_for_file
= _file_md5(filename
)
160 self
.assertEqual(md5_for_file
, 'c5c67df477eb0d9b058200351448ba4c')
164 if os
.path
.exists('BaW_jenozKc.mp4'):
165 os
.remove('BaW_jenozKc.mp4')
166 if os
.path
.exists('x33vw9.mp4'):
167 os
.remove('x33vw9.mp4')
168 if os
.path
.exists('aUehQsCQtM.flv'):
169 os
.remove('aUehQsCQtM.flv')
170 if os
.path
.exists('5779306.m4v'):
171 os
.remove('5779306.m4v')
172 if os
.path
.exists('939581.flv'):
173 os
.remove('939581.flv')
174 # No file specified for Vimeo
175 if os
.path
.exists('n6FLbx6ZzMiu.mp3'):
176 os
.remove('n6FLbx6ZzMiu.mp3')
177 if os
.path
.exists('PracticalUnix_intro-environment.mp4'):
178 os
.remove('PracticalUnix_intro-environment.mp4')
179 # No file specified for CollegeHumor
180 if os
.path
.exists('1135332.flv'):
181 os
.remove('1135332.flv')
185 if __name__
== '__main__':