6 from youtube_dl.FileDownloader import FileDownloader
7 from youtube_dl.InfoExtractors import YoutubeIE
9 class DownloadTest(unittest.TestCase):
10 #calculated with the md5sum utility
11 #md5sum (GNU coreutils) 8.19
12 YOUTUBE_MD5 = "8547978241cb87dd6782b10b8e90acc3"
13 YOUTUBE_URL = "http://www.youtube.com/watch?v=BaW_jenozKc"
14 YOUTUBE_FILE = "BaW_jenozKc.flv"
16 def test_youtube(self):
17 #let's download a file from youtube
19 fd = FileDownloader({})
20 fd.add_info_extractor(YoutubeIE())
21 fd.download([DownloadTest.YOUTUBE_URL])
22 self.assertTrue(os.path.exists(DownloadTest.YOUTUBE_FILE))
23 md5_down_file = md5_for_file(DownloadTest.YOUTUBE_FILE)
24 self.assertEqual(md5_down_file, DownloadTest.YOUTUBE_MD5)
27 if os.path.exists(DownloadTest.YOUTUBE_FILE):
28 os.remove(DownloadTest.YOUTUBE_FILE)
30 def md5_for_file(f, block_size=2**20):
33 data = f.read(block_size)