From efe8902f0b354bc43ea36cd09778b1454fbd4bb3 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Fri, 28 Sep 2012 15:34:56 +0200 Subject: adding download test with md5 check --- test/test_download.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/test_download.py (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py new file mode 100644 index 000000000..ff0d69300 --- /dev/null +++ b/test/test_download.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python2 +import unittest +import hashlib +import os + +from youtube_dl.FileDownloader import FileDownloader +from youtube_dl.InfoExtractors import YoutubeIE + +class DownloadTest(unittest.TestCase): + #calculated with the md5sum utility + #md5sum (GNU coreutils) 8.19 + YOUTUBE_MD5 = "ba4092da68c9ded8ef3aaace5ffd1860" + YOUTUBE_URL = "http://www.youtube.com/watch?v=u0VbyYcljx8&feature=related" + YOUTUBE_FILE = "u0VbyYcljx8.flv" + + def test_youtube(self): + #let's download a file from youtube + global YOUTUBE_URL + fd = FileDownloader({}) + fd.add_info_extractor(YoutubeIE()) + fd.download([DownloadTest.YOUTUBE_URL]) + self.assertTrue(os.path.exists(DownloadTest.YOUTUBE_FILE)) + md5_down_file = md5_for_file(DownloadTest.YOUTUBE_FILE) + self.assertEqual(md5_down_file, DownloadTest.YOUTUBE_MD5) + + def cleanUp(self): + if os.path.exists(DownloadTest.YOUTUBE_FILE): + os.remove(DownloadTest.YOUTUBE_FILE) + +def md5_for_file(f, block_size=2**20): + md5 = hashlib.md5() + while True: + data = f.read(block_size) + if not data: + break + md5.update(data) + return md5.digest() -- cgit v1.2.3 From 0b4e98490b6124eae868425e683a492c49b047ae Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Tue, 2 Oct 2012 19:37:48 +0200 Subject: changing test video --- test/test_download.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index ff0d69300..987f53ecb 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -9,9 +9,9 @@ from youtube_dl.InfoExtractors import YoutubeIE class DownloadTest(unittest.TestCase): #calculated with the md5sum utility #md5sum (GNU coreutils) 8.19 - YOUTUBE_MD5 = "ba4092da68c9ded8ef3aaace5ffd1860" - YOUTUBE_URL = "http://www.youtube.com/watch?v=u0VbyYcljx8&feature=related" - YOUTUBE_FILE = "u0VbyYcljx8.flv" + YOUTUBE_MD5 = "8547978241cb87dd6782b10b8e90acc3" + YOUTUBE_URL = "http://www.youtube.com/watch?v=BaW_jenozKc" + YOUTUBE_FILE = "BaW_jenozKc.flv" def test_youtube(self): #let's download a file from youtube -- cgit v1.2.3 From 137c5803c35f3e06d821ede1ef69733c3b8d338c Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 14:25:54 +0200 Subject: some changes to keep the same standard --- test/test_download.py | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index 987f53ecb..50d3a12aa 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -7,31 +7,30 @@ from youtube_dl.FileDownloader import FileDownloader from youtube_dl.InfoExtractors import YoutubeIE class DownloadTest(unittest.TestCase): - #calculated with the md5sum utility - #md5sum (GNU coreutils) 8.19 - YOUTUBE_MD5 = "8547978241cb87dd6782b10b8e90acc3" - YOUTUBE_URL = "http://www.youtube.com/watch?v=BaW_jenozKc" - YOUTUBE_FILE = "BaW_jenozKc.flv" + #calculated with md5sum: + # md5sum (GNU coreutils) 8.19 + YOUTUBE_MD5 = "8547978241cb87dd6782b10b8e90acc3" + YOUTUBE_URL = "http://www.youtube.com/watch?v=BaW_jenozKc" + YOUTUBE_FILE = "BaW_jenozKc.flv" - def test_youtube(self): - #let's download a file from youtube - global YOUTUBE_URL - fd = FileDownloader({}) - fd.add_info_extractor(YoutubeIE()) - fd.download([DownloadTest.YOUTUBE_URL]) - self.assertTrue(os.path.exists(DownloadTest.YOUTUBE_FILE)) - md5_down_file = md5_for_file(DownloadTest.YOUTUBE_FILE) - self.assertEqual(md5_down_file, DownloadTest.YOUTUBE_MD5) + def test_youtube(self): + #let's download a file from youtube + fd = FileDownloader({}) + fd.add_info_extractor(YoutubeIE()) + fd.download([DownloadTest.YOUTUBE_URL]) + self.assertTrue(os.path.exists(DownloadTest.YOUTUBE_FILE)) + md5_down_file = md5_for_file(DownloadTest.YOUTUBE_FILE) + self.assertEqual(md5_down_file, DownloadTest.YOUTUBE_MD5) - def cleanUp(self): - if os.path.exists(DownloadTest.YOUTUBE_FILE): - os.remove(DownloadTest.YOUTUBE_FILE) + def cleanUp(self): + if os.path.exists(DownloadTest.YOUTUBE_FILE): + os.remove(DownloadTest.YOUTUBE_FILE) def md5_for_file(f, block_size=2**20): - md5 = hashlib.md5() - while True: - data = f.read(block_size) - if not data: - break - md5.update(data) - return md5.digest() + md5 = hashlib.md5() + while True: + data = f.read(block_size) + if not data: + break + md5.update(data) + return md5.digest() -- cgit v1.2.3 From ff08984246ee635dc2cf89ff105f92b1098e5011 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 14:42:05 +0200 Subject: adding dailymotion test --- test/test_download.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index 50d3a12aa..b90ce6323 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -4,7 +4,7 @@ import hashlib import os from youtube_dl.FileDownloader import FileDownloader -from youtube_dl.InfoExtractors import YoutubeIE +from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE class DownloadTest(unittest.TestCase): #calculated with md5sum: @@ -13,6 +13,10 @@ class DownloadTest(unittest.TestCase): YOUTUBE_URL = "http://www.youtube.com/watch?v=BaW_jenozKc" YOUTUBE_FILE = "BaW_jenozKc.flv" + DAILYMOTION_MD5 = "" + DAILYMOTION_URL = "http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech" + DAILYMOTION_FILE = "" + def test_youtube(self): #let's download a file from youtube fd = FileDownloader({}) @@ -22,9 +26,20 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.YOUTUBE_FILE) self.assertEqual(md5_down_file, DownloadTest.YOUTUBE_MD5) + def test_dailymotion(self): + fd = FileDownloader({}) + fd.add_info_extractor(DailymotionIE()) + fd.download([DownloadTest.DAILYMOTION_URL]) + self.assertTrue(os.path.exists(DownloadTest.DAILYMOTION_FILE)) + md5_down_file = md5_for_file(DownloadTest.DAILYMOTION_FILE) + self.assertEqual(md5_down_file, DownloadTest.DAILYMOTION_MD5) + + def cleanUp(self): if os.path.exists(DownloadTest.YOUTUBE_FILE): os.remove(DownloadTest.YOUTUBE_FILE) + if os.path.exists(DownloadTest.DAILYMOTION_FILE): + os.remove(DownloadTest.DAILYMOTION_FILE) def md5_for_file(f, block_size=2**20): md5 = hashlib.md5() -- cgit v1.2.3 From a4b5f2255436251b5e2d1a3ae1da369587f01f1f Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 14:47:12 +0200 Subject: adding metacafe test --- test/test_download.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index b90ce6323..871591a53 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -4,7 +4,7 @@ import hashlib import os from youtube_dl.FileDownloader import FileDownloader -from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE +from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE, MetacafeIE class DownloadTest(unittest.TestCase): #calculated with md5sum: @@ -17,6 +17,11 @@ class DownloadTest(unittest.TestCase): DAILYMOTION_URL = "http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech" DAILYMOTION_FILE = "" + + METACAFE_MD5 = "" + METACAFE_URL = "http://www.metacafe.com/watch/yt-bV9L5Ht9LgY/download_youtube_playlist_with_youtube_dl/" + METACAFE_FILE = "" + def test_youtube(self): #let's download a file from youtube fd = FileDownloader({}) @@ -35,6 +40,14 @@ class DownloadTest(unittest.TestCase): self.assertEqual(md5_down_file, DownloadTest.DAILYMOTION_MD5) + def test_metacafe(self): + fd = FileDownloader({}) + fd.add_info_extractor(MetacafeIE()) + fd.download([DownloadTest.METACAFE_URL]) + self.assertTrue(os.path.exists(DownloadTest.METACAFE_FILE)) + md5_down_file = md5_for_file(DownloadTest.METACAFE_FILE) + self.assertEqual(md5_down_file, DownloadTest.METACAFE_MD5) + def cleanUp(self): if os.path.exists(DownloadTest.YOUTUBE_FILE): os.remove(DownloadTest.YOUTUBE_FILE) -- cgit v1.2.3 From b4e5de51ec572ea086ebd392b7dac686ced15923 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 14:52:06 +0200 Subject: adding photobucket test --- test/test_download.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index 871591a53..7359b7999 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -4,7 +4,7 @@ import hashlib import os from youtube_dl.FileDownloader import FileDownloader -from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE, MetacafeIE +from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE, MetacafeIE, PhotobucketIE class DownloadTest(unittest.TestCase): #calculated with md5sum: @@ -22,6 +22,11 @@ class DownloadTest(unittest.TestCase): METACAFE_URL = "http://www.metacafe.com/watch/yt-bV9L5Ht9LgY/download_youtube_playlist_with_youtube_dl/" METACAFE_FILE = "" + + PHOTOBUCKET_MD5 = "" + PHOTOBUCKET_URL = "http://www.metacafe.com/watch/yt-bV9L5Ht9LgY/download_youtube_playlist_with_youtube_dl/" + PHOTOBUCKET_FILE = "" + def test_youtube(self): #let's download a file from youtube fd = FileDownloader({}) @@ -48,11 +53,24 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.METACAFE_FILE) self.assertEqual(md5_down_file, DownloadTest.METACAFE_MD5) + def test_photobucket(self): + fd = FileDownloader({}) + fd.add_info_extractor(PhotobucketIE()) + fd.download([DownloadTest.PHOTOBUCKET_URL]) + self.assertTrue(os.path.exists(DownloadTest.PHOTOBUCKET_FILE)) + md5_down_file = md5_for_file(DownloadTest.PHOTOBUCKET_FILE) + self.assertEqual(md5_down_file, DownloadTest.PHOTOBUCKET_MD5) + + def cleanUp(self): if os.path.exists(DownloadTest.YOUTUBE_FILE): os.remove(DownloadTest.YOUTUBE_FILE) if os.path.exists(DownloadTest.DAILYMOTION_FILE): os.remove(DownloadTest.DAILYMOTION_FILE) + if os.path.exists(DownloadTest.METACAFE_FILE): + os.remove(DownloadTest.METACAFE_FILE) + if os.path.exists(DownloadTest.PHOTOBUCKET_FILE): + os.remove(DownloadTest.PHOTOBUCKET_FILE) def md5_for_file(f, block_size=2**20): md5 = hashlib.md5() -- cgit v1.2.3 From 6da7877bf54f881235149d5856fe32ae4770ed90 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 15:13:37 +0200 Subject: adding facebook test --- test/test_download.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index 7359b7999..bf484c8b9 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -4,7 +4,9 @@ import hashlib import os from youtube_dl.FileDownloader import FileDownloader -from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE, MetacafeIE, PhotobucketIE +from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE +from youtube_dl.InfoExtractors import MetacafeIE, PhotobucketIE +from youtube_dl.InfoExtractors import FacebookIE class DownloadTest(unittest.TestCase): #calculated with md5sum: @@ -13,6 +15,7 @@ class DownloadTest(unittest.TestCase): YOUTUBE_URL = "http://www.youtube.com/watch?v=BaW_jenozKc" YOUTUBE_FILE = "BaW_jenozKc.flv" + DAILYMOTION_MD5 = "" DAILYMOTION_URL = "http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech" DAILYMOTION_FILE = "" @@ -27,6 +30,12 @@ class DownloadTest(unittest.TestCase): PHOTOBUCKET_URL = "http://www.metacafe.com/watch/yt-bV9L5Ht9LgY/download_youtube_playlist_with_youtube_dl/" PHOTOBUCKET_FILE = "" + + FACEBOOK_MD5 = "" + FACEBOOK_URL = "https://www.facebook.com/video/video.php?v=207446242657384" + FACEBOOK_FILE = "" + + def test_youtube(self): #let's download a file from youtube fd = FileDownloader({}) @@ -62,6 +71,14 @@ class DownloadTest(unittest.TestCase): self.assertEqual(md5_down_file, DownloadTest.PHOTOBUCKET_MD5) + def test_facebook(self): + fd = FileDownloader({}) + fd.add_info_extractor(FacebookIE()) + fd.download([DownloadTest.FACEBOOK_URL]) + self.assertTrue(os.path.exists(DownloadTest.FACEBOOK_FILE)) + md5_down_file = md5_for_file(DownloadTest.FACEBOOK_FILE) + self.assertEqual(md5_down_file, DownloadTest.FACEBOOK_MD5) + def cleanUp(self): if os.path.exists(DownloadTest.YOUTUBE_FILE): os.remove(DownloadTest.YOUTUBE_FILE) @@ -71,6 +88,8 @@ class DownloadTest(unittest.TestCase): os.remove(DownloadTest.METACAFE_FILE) if os.path.exists(DownloadTest.PHOTOBUCKET_FILE): os.remove(DownloadTest.PHOTOBUCKET_FILE) + if os.path.exists(DownloadTest.FACEBOOK_FILE): + os.remove(DownloadTest.FACEBOOK_FILE) def md5_for_file(f, block_size=2**20): md5 = hashlib.md5() -- cgit v1.2.3 From 4c9afeca34ba3d981fa51db18fe9522212ffad4c Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 21:10:13 +0200 Subject: adding xvideo --- test/test_download.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index bf484c8b9..a2f5abcb2 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -6,11 +6,13 @@ import os from youtube_dl.FileDownloader import FileDownloader from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE from youtube_dl.InfoExtractors import MetacafeIE, PhotobucketIE -from youtube_dl.InfoExtractors import FacebookIE +from youtube_dl.InfoExtractors import FacebookIE, BlipTVIE +from youtube_dl.InfoExtractors import VimeoIE, XVideosIE + class DownloadTest(unittest.TestCase): #calculated with md5sum: - # md5sum (GNU coreutils) 8.19 + #md5sum (GNU coreutils) 8.19 YOUTUBE_MD5 = "8547978241cb87dd6782b10b8e90acc3" YOUTUBE_URL = "http://www.youtube.com/watch?v=BaW_jenozKc" YOUTUBE_FILE = "BaW_jenozKc.flv" @@ -36,6 +38,19 @@ class DownloadTest(unittest.TestCase): FACEBOOK_FILE = "" + BLIP_MD5 = "" + BLIP_URL = "https://www.facebook.com/video/video.php?v=207446242657384" + BLIP_FILE = "" + + VIMEO_MD5 = "" + VIMEO_URL = "https://www.facebook.com/video/video.php?v=207446242657384" + VIMEO_FILE = "" + + XVIDEO_MD5 = "" + XVIDEO_URL = "https://www.facebook.com/video/video.php?v=207446242657384" + XVIDEO_FILE = "" + + def test_youtube(self): #let's download a file from youtube fd = FileDownloader({}) @@ -79,6 +94,32 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.FACEBOOK_FILE) self.assertEqual(md5_down_file, DownloadTest.FACEBOOK_MD5) + def test_blip(self): + fd = FileDownloader({}) + fd.add_info_extractor(BlipTVIE()) + fd.download([DownloadTest.BLIP_URL]) + self.assertTrue(os.path.exists(DownloadTest.BLIP_FILE)) + md5_down_file = md5_for_file(DownloadTest.BLIP_FILE) + self.assertEqual(md5_down_file, DownloadTest.BLIP_MD5) + + + def test_vimeo(self): + fd = FileDownloader({}) + fd.add_info_extractor(VimeoIE()) + fd.download([DownloadTest.VIMEO_URL]) + self.assertTrue(os.path.exists(DownloadTest.VIMEO_FILE)) + md5_down_file = md5_for_file(DownloadTest.VIMEO_FILE) + self.assertEqual(md5_down_file, DownloadTest.VIMEO_MD5) + + + def test_xvideo(self): + fd = FileDownloader({}) + fd.add_info_extractor(XVideosIE()) + fd.download([DownloadTest.XVIDEO_URL]) + self.assertTrue(os.path.exists(DownloadTest.XVIDEO_FILE)) + md5_down_file = md5_for_file(DownloadTest.XVIDEO_FILE) + self.assertEqual(md5_down_file, DownloadTest.XVIDEO_MD5) + def cleanUp(self): if os.path.exists(DownloadTest.YOUTUBE_FILE): os.remove(DownloadTest.YOUTUBE_FILE) @@ -90,6 +131,12 @@ class DownloadTest(unittest.TestCase): os.remove(DownloadTest.PHOTOBUCKET_FILE) if os.path.exists(DownloadTest.FACEBOOK_FILE): os.remove(DownloadTest.FACEBOOK_FILE) + if os.path.exists(DownloadTest.BLIP_FILE): + os.remove(DownloadTest.BLIP_FILE) + if os.path.exists(DownloadTest.VIMEO_FILE): + os.remove(DownloadTest.VIMEO_FILE) + if os.path.exists(DownloadTest.XVIDEO_FILE): + os.remove(DownloadTest.XVIDEO_FILE) def md5_for_file(f, block_size=2**20): md5 = hashlib.md5() -- cgit v1.2.3 From 7f60b5aa404cf53e780039791ad45d1fe98a971f Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Mon, 15 Oct 2012 13:01:36 +0200 Subject: correction on the test --- test/test_download.py | 61 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 25 deletions(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index a2f5abcb2..84a98908a 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -2,6 +2,7 @@ import unittest import hashlib import os +import json from youtube_dl.FileDownloader import FileDownloader from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE @@ -11,16 +12,18 @@ from youtube_dl.InfoExtractors import VimeoIE, XVideosIE class DownloadTest(unittest.TestCase): + PARAMETERS_FILE = "test/parameters.json" #calculated with md5sum: #md5sum (GNU coreutils) 8.19 - YOUTUBE_MD5 = "8547978241cb87dd6782b10b8e90acc3" + + YOUTUBE_MD5 = "ab62e120445e8f68e8c8fddb7bd3ed76" YOUTUBE_URL = "http://www.youtube.com/watch?v=BaW_jenozKc" - YOUTUBE_FILE = "BaW_jenozKc.flv" + YOUTUBE_FILE = "BaW_jenozKc.mp4" - DAILYMOTION_MD5 = "" + DAILYMOTION_MD5 = "d363a50e9eb4f22ce90d08d15695bb47" DAILYMOTION_URL = "http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech" - DAILYMOTION_FILE = "" + DAILYMOTION_FILE = "x33vw9.mp4" METACAFE_MD5 = "" @@ -29,54 +32,60 @@ class DownloadTest(unittest.TestCase): PHOTOBUCKET_MD5 = "" - PHOTOBUCKET_URL = "http://www.metacafe.com/watch/yt-bV9L5Ht9LgY/download_youtube_playlist_with_youtube_dl/" + PHOTOBUCKET_URL = "" PHOTOBUCKET_FILE = "" FACEBOOK_MD5 = "" - FACEBOOK_URL = "https://www.facebook.com/video/video.php?v=207446242657384" + FACEBOOK_URL = "" FACEBOOK_FILE = "" BLIP_MD5 = "" - BLIP_URL = "https://www.facebook.com/video/video.php?v=207446242657384" + BLIP_URL = "" BLIP_FILE = "" VIMEO_MD5 = "" - VIMEO_URL = "https://www.facebook.com/video/video.php?v=207446242657384" + VIMEO_URL = "" VIMEO_FILE = "" XVIDEO_MD5 = "" - XVIDEO_URL = "https://www.facebook.com/video/video.php?v=207446242657384" + XVIDEO_URL = "" XVIDEO_FILE = "" def test_youtube(self): #let's download a file from youtube - fd = FileDownloader({}) + with open(DownloadTest.PARAMETERS_FILE) as f: + fd = FileDownloader(json.load(f)) fd.add_info_extractor(YoutubeIE()) fd.download([DownloadTest.YOUTUBE_URL]) + print(os.path.abspath(DownloadTest.YOUTUBE_FILE)) self.assertTrue(os.path.exists(DownloadTest.YOUTUBE_FILE)) md5_down_file = md5_for_file(DownloadTest.YOUTUBE_FILE) self.assertEqual(md5_down_file, DownloadTest.YOUTUBE_MD5) def test_dailymotion(self): - fd = FileDownloader({}) + with open(DownloadTest.PARAMETERS_FILE) as f: + fd = FileDownloader(json.load(f)) fd.add_info_extractor(DailymotionIE()) fd.download([DownloadTest.DAILYMOTION_URL]) self.assertTrue(os.path.exists(DownloadTest.DAILYMOTION_FILE)) md5_down_file = md5_for_file(DownloadTest.DAILYMOTION_FILE) self.assertEqual(md5_down_file, DownloadTest.DAILYMOTION_MD5) - + @unittest.skip("no suitable ie") def test_metacafe(self): - fd = FileDownloader({}) + with open("test/json") as f: + fd = FileDownloader(json.load(f)) + print fd fd.add_info_extractor(MetacafeIE()) fd.download([DownloadTest.METACAFE_URL]) self.assertTrue(os.path.exists(DownloadTest.METACAFE_FILE)) md5_down_file = md5_for_file(DownloadTest.METACAFE_FILE) self.assertEqual(md5_down_file, DownloadTest.METACAFE_MD5) + @unittest.skip("no suitable url") def test_photobucket(self): fd = FileDownloader({}) fd.add_info_extractor(PhotobucketIE()) @@ -85,7 +94,7 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.PHOTOBUCKET_FILE) self.assertEqual(md5_down_file, DownloadTest.PHOTOBUCKET_MD5) - + @unittest.skip("no suitable url") def test_facebook(self): fd = FileDownloader({}) fd.add_info_extractor(FacebookIE()) @@ -94,6 +103,7 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.FACEBOOK_FILE) self.assertEqual(md5_down_file, DownloadTest.FACEBOOK_MD5) + @unittest.skip("no suitable url") def test_blip(self): fd = FileDownloader({}) fd.add_info_extractor(BlipTVIE()) @@ -102,7 +112,7 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.BLIP_FILE) self.assertEqual(md5_down_file, DownloadTest.BLIP_MD5) - + @unittest.skip("no suitable url") def test_vimeo(self): fd = FileDownloader({}) fd.add_info_extractor(VimeoIE()) @@ -111,7 +121,7 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.VIMEO_FILE) self.assertEqual(md5_down_file, DownloadTest.VIMEO_MD5) - + @unittest.skip("no suitable url") def test_xvideo(self): fd = FileDownloader({}) fd.add_info_extractor(XVideosIE()) @@ -120,7 +130,7 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.XVIDEO_FILE) self.assertEqual(md5_down_file, DownloadTest.XVIDEO_MD5) - def cleanUp(self): + def tearDown(self): if os.path.exists(DownloadTest.YOUTUBE_FILE): os.remove(DownloadTest.YOUTUBE_FILE) if os.path.exists(DownloadTest.DAILYMOTION_FILE): @@ -138,11 +148,12 @@ class DownloadTest(unittest.TestCase): if os.path.exists(DownloadTest.XVIDEO_FILE): os.remove(DownloadTest.XVIDEO_FILE) -def md5_for_file(f, block_size=2**20): - md5 = hashlib.md5() - while True: - data = f.read(block_size) - if not data: - break - md5.update(data) - return md5.digest() +def md5_for_file(filename, block_size=2**20): + with open(filename) as f: + md5 = hashlib.md5() + while True: + data = f.read(block_size) + if not data: + break + md5.update(data) + return md5.hexdigest() -- cgit v1.2.3 From 4279a0ca983476a0bdf86e23251b866616cbd434 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Mon, 15 Oct 2012 14:34:54 +0200 Subject: correcting test to be compatible with python2.6 --- test/test_download.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index 84a98908a..7de9f2a48 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -74,9 +74,10 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.DAILYMOTION_FILE) self.assertEqual(md5_down_file, DownloadTest.DAILYMOTION_MD5) - @unittest.skip("no suitable ie") def test_metacafe(self): - with open("test/json") as f: + #this emulate a skip,to be 2.6 compatible + return + with open(DownloadTest.PARAMETERS_FILE) as f: fd = FileDownloader(json.load(f)) print fd fd.add_info_extractor(MetacafeIE()) @@ -85,45 +86,50 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.METACAFE_FILE) self.assertEqual(md5_down_file, DownloadTest.METACAFE_MD5) - @unittest.skip("no suitable url") def test_photobucket(self): - fd = FileDownloader({}) + return + with open(DownloadTest.PARAMETERS_FILE) as f: + fd = FileDownloader(json.load(f)) fd.add_info_extractor(PhotobucketIE()) fd.download([DownloadTest.PHOTOBUCKET_URL]) self.assertTrue(os.path.exists(DownloadTest.PHOTOBUCKET_FILE)) md5_down_file = md5_for_file(DownloadTest.PHOTOBUCKET_FILE) self.assertEqual(md5_down_file, DownloadTest.PHOTOBUCKET_MD5) - @unittest.skip("no suitable url") def test_facebook(self): - fd = FileDownloader({}) + return + with open(DownloadTest.PARAMETERS_FILE) as f: + fd = FileDownloader(json.load(f)) fd.add_info_extractor(FacebookIE()) fd.download([DownloadTest.FACEBOOK_URL]) self.assertTrue(os.path.exists(DownloadTest.FACEBOOK_FILE)) md5_down_file = md5_for_file(DownloadTest.FACEBOOK_FILE) self.assertEqual(md5_down_file, DownloadTest.FACEBOOK_MD5) - @unittest.skip("no suitable url") def test_blip(self): - fd = FileDownloader({}) + return + with open(DownloadTest.PARAMETERS_FILE) as f: + fd = FileDownloader(json.load(f)) fd.add_info_extractor(BlipTVIE()) fd.download([DownloadTest.BLIP_URL]) self.assertTrue(os.path.exists(DownloadTest.BLIP_FILE)) md5_down_file = md5_for_file(DownloadTest.BLIP_FILE) self.assertEqual(md5_down_file, DownloadTest.BLIP_MD5) - @unittest.skip("no suitable url") def test_vimeo(self): - fd = FileDownloader({}) + return + with open(DownloadTest.PARAMETERS_FILE) as f: + fd = FileDownloader(json.load(f)) fd.add_info_extractor(VimeoIE()) fd.download([DownloadTest.VIMEO_URL]) self.assertTrue(os.path.exists(DownloadTest.VIMEO_FILE)) md5_down_file = md5_for_file(DownloadTest.VIMEO_FILE) self.assertEqual(md5_down_file, DownloadTest.VIMEO_MD5) - @unittest.skip("no suitable url") def test_xvideo(self): - fd = FileDownloader({}) + return + with open(DownloadTest.PARAMETERS_FILE) as f: + fd = FileDownloader(json.load(f)) fd.add_info_extractor(XVideosIE()) fd.download([DownloadTest.XVIDEO_URL]) self.assertTrue(os.path.exists(DownloadTest.XVIDEO_FILE)) -- cgit v1.2.3 From 97a37c231903d6b9bf323a956d4dc2450cb6b637 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Mon, 15 Oct 2012 17:40:16 +0200 Subject: some assertion on the file downloaded --- test/test_download.py | 60 +++++++++------------------------------------------ 1 file changed, 10 insertions(+), 50 deletions(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index 7de9f2a48..fc68968c7 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -20,34 +20,21 @@ class DownloadTest(unittest.TestCase): YOUTUBE_URL = "http://www.youtube.com/watch?v=BaW_jenozKc" YOUTUBE_FILE = "BaW_jenozKc.mp4" - DAILYMOTION_MD5 = "d363a50e9eb4f22ce90d08d15695bb47" DAILYMOTION_URL = "http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech" DAILYMOTION_FILE = "x33vw9.mp4" + METACAFE_SIZE = 5754305 + METACAFE_URL = "http://www.metacafe.com/watch/yt-_aUehQsCQtM/the_electric_company_short_i_pbs_kids_go/" + METACAFE_FILE = "_aUehQsCQtM.flv" - METACAFE_MD5 = "" - METACAFE_URL = "http://www.metacafe.com/watch/yt-bV9L5Ht9LgY/download_youtube_playlist_with_youtube_dl/" - METACAFE_FILE = "" - - - PHOTOBUCKET_MD5 = "" - PHOTOBUCKET_URL = "" - PHOTOBUCKET_FILE = "" - - - FACEBOOK_MD5 = "" - FACEBOOK_URL = "" - FACEBOOK_FILE = "" - - - BLIP_MD5 = "" - BLIP_URL = "" - BLIP_FILE = "" + BLIP_MD5 = "93c24d2f4e0782af13b8a7606ea97ba7" + BLIP_URL = "http://blip.tv/cbr/cbr-exclusive-gotham-city-imposters-bats-vs-jokerz-short-3-5796352" + BLIP_FILE = "5779306.m4v" VIMEO_MD5 = "" - VIMEO_URL = "" - VIMEO_FILE = "" + VIMEO_URL = "http://vimeo.com/3156959" + VIMEO_FILE = "3156959.mp4" XVIDEO_MD5 = "" XVIDEO_URL = "" @@ -76,38 +63,16 @@ class DownloadTest(unittest.TestCase): def test_metacafe(self): #this emulate a skip,to be 2.6 compatible - return with open(DownloadTest.PARAMETERS_FILE) as f: fd = FileDownloader(json.load(f)) print fd fd.add_info_extractor(MetacafeIE()) + fd.add_info_extractor(YoutubeIE()) fd.download([DownloadTest.METACAFE_URL]) self.assertTrue(os.path.exists(DownloadTest.METACAFE_FILE)) - md5_down_file = md5_for_file(DownloadTest.METACAFE_FILE) - self.assertEqual(md5_down_file, DownloadTest.METACAFE_MD5) - - def test_photobucket(self): - return - with open(DownloadTest.PARAMETERS_FILE) as f: - fd = FileDownloader(json.load(f)) - fd.add_info_extractor(PhotobucketIE()) - fd.download([DownloadTest.PHOTOBUCKET_URL]) - self.assertTrue(os.path.exists(DownloadTest.PHOTOBUCKET_FILE)) - md5_down_file = md5_for_file(DownloadTest.PHOTOBUCKET_FILE) - self.assertEqual(md5_down_file, DownloadTest.PHOTOBUCKET_MD5) - - def test_facebook(self): - return - with open(DownloadTest.PARAMETERS_FILE) as f: - fd = FileDownloader(json.load(f)) - fd.add_info_extractor(FacebookIE()) - fd.download([DownloadTest.FACEBOOK_URL]) - self.assertTrue(os.path.exists(DownloadTest.FACEBOOK_FILE)) - md5_down_file = md5_for_file(DownloadTest.FACEBOOK_FILE) - self.assertEqual(md5_down_file, DownloadTest.FACEBOOK_MD5) + self.assertEqual(os.path.getsize(DownloadTest.METACAFE_FILE), DownloadTest.METACAFE_SIZE) def test_blip(self): - return with open(DownloadTest.PARAMETERS_FILE) as f: fd = FileDownloader(json.load(f)) fd.add_info_extractor(BlipTVIE()) @@ -117,7 +82,6 @@ class DownloadTest(unittest.TestCase): self.assertEqual(md5_down_file, DownloadTest.BLIP_MD5) def test_vimeo(self): - return with open(DownloadTest.PARAMETERS_FILE) as f: fd = FileDownloader(json.load(f)) fd.add_info_extractor(VimeoIE()) @@ -143,10 +107,6 @@ class DownloadTest(unittest.TestCase): os.remove(DownloadTest.DAILYMOTION_FILE) if os.path.exists(DownloadTest.METACAFE_FILE): os.remove(DownloadTest.METACAFE_FILE) - if os.path.exists(DownloadTest.PHOTOBUCKET_FILE): - os.remove(DownloadTest.PHOTOBUCKET_FILE) - if os.path.exists(DownloadTest.FACEBOOK_FILE): - os.remove(DownloadTest.FACEBOOK_FILE) if os.path.exists(DownloadTest.BLIP_FILE): os.remove(DownloadTest.BLIP_FILE) if os.path.exists(DownloadTest.VIMEO_FILE): -- cgit v1.2.3 From fc7376016c2cb657b274a18fa7db275add6f8a46 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Mon, 15 Oct 2012 17:51:27 +0200 Subject: cleaning the test that doesn't work with the api for the moment --- test/test_download.py | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index fc68968c7..2711980f0 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -6,9 +6,7 @@ import json from youtube_dl.FileDownloader import FileDownloader from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE -from youtube_dl.InfoExtractors import MetacafeIE, PhotobucketIE -from youtube_dl.InfoExtractors import FacebookIE, BlipTVIE -from youtube_dl.InfoExtractors import VimeoIE, XVideosIE +from youtube_dl.InfoExtractors import MetacafeIE, BlipTVIE class DownloadTest(unittest.TestCase): @@ -32,10 +30,6 @@ class DownloadTest(unittest.TestCase): BLIP_URL = "http://blip.tv/cbr/cbr-exclusive-gotham-city-imposters-bats-vs-jokerz-short-3-5796352" BLIP_FILE = "5779306.m4v" - VIMEO_MD5 = "" - VIMEO_URL = "http://vimeo.com/3156959" - VIMEO_FILE = "3156959.mp4" - XVIDEO_MD5 = "" XVIDEO_URL = "" XVIDEO_FILE = "" @@ -81,25 +75,6 @@ class DownloadTest(unittest.TestCase): md5_down_file = md5_for_file(DownloadTest.BLIP_FILE) self.assertEqual(md5_down_file, DownloadTest.BLIP_MD5) - def test_vimeo(self): - with open(DownloadTest.PARAMETERS_FILE) as f: - fd = FileDownloader(json.load(f)) - fd.add_info_extractor(VimeoIE()) - fd.download([DownloadTest.VIMEO_URL]) - self.assertTrue(os.path.exists(DownloadTest.VIMEO_FILE)) - md5_down_file = md5_for_file(DownloadTest.VIMEO_FILE) - self.assertEqual(md5_down_file, DownloadTest.VIMEO_MD5) - - def test_xvideo(self): - return - with open(DownloadTest.PARAMETERS_FILE) as f: - fd = FileDownloader(json.load(f)) - fd.add_info_extractor(XVideosIE()) - fd.download([DownloadTest.XVIDEO_URL]) - self.assertTrue(os.path.exists(DownloadTest.XVIDEO_FILE)) - md5_down_file = md5_for_file(DownloadTest.XVIDEO_FILE) - self.assertEqual(md5_down_file, DownloadTest.XVIDEO_MD5) - def tearDown(self): if os.path.exists(DownloadTest.YOUTUBE_FILE): os.remove(DownloadTest.YOUTUBE_FILE) @@ -109,10 +84,6 @@ class DownloadTest(unittest.TestCase): os.remove(DownloadTest.METACAFE_FILE) if os.path.exists(DownloadTest.BLIP_FILE): os.remove(DownloadTest.BLIP_FILE) - if os.path.exists(DownloadTest.VIMEO_FILE): - os.remove(DownloadTest.VIMEO_FILE) - if os.path.exists(DownloadTest.XVIDEO_FILE): - os.remove(DownloadTest.XVIDEO_FILE) def md5_for_file(filename, block_size=2**20): with open(filename) as f: -- cgit v1.2.3 From 591bbe9c902c7af536729d61b4cad07559818242 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Mon, 15 Oct 2012 18:27:26 +0200 Subject: changing test from md5 to filesize, the file changed between download --- test/test_download.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'test/test_download.py') diff --git a/test/test_download.py b/test/test_download.py index 2711980f0..545afb922 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -14,7 +14,7 @@ class DownloadTest(unittest.TestCase): #calculated with md5sum: #md5sum (GNU coreutils) 8.19 - YOUTUBE_MD5 = "ab62e120445e8f68e8c8fddb7bd3ed76" + YOUTUBE_SIZE = 1993883 YOUTUBE_URL = "http://www.youtube.com/watch?v=BaW_jenozKc" YOUTUBE_FILE = "BaW_jenozKc.mp4" @@ -41,10 +41,8 @@ class DownloadTest(unittest.TestCase): fd = FileDownloader(json.load(f)) fd.add_info_extractor(YoutubeIE()) fd.download([DownloadTest.YOUTUBE_URL]) - print(os.path.abspath(DownloadTest.YOUTUBE_FILE)) self.assertTrue(os.path.exists(DownloadTest.YOUTUBE_FILE)) - md5_down_file = md5_for_file(DownloadTest.YOUTUBE_FILE) - self.assertEqual(md5_down_file, DownloadTest.YOUTUBE_MD5) + self.assertEqual(os.path.getsize(DownloadTest.YOUTUBE_FILE), DownloadTest.YOUTUBE_SIZE) def test_dailymotion(self): with open(DownloadTest.PARAMETERS_FILE) as f: @@ -59,7 +57,6 @@ class DownloadTest(unittest.TestCase): #this emulate a skip,to be 2.6 compatible with open(DownloadTest.PARAMETERS_FILE) as f: fd = FileDownloader(json.load(f)) - print fd fd.add_info_extractor(MetacafeIE()) fd.add_info_extractor(YoutubeIE()) fd.download([DownloadTest.METACAFE_URL]) -- cgit v1.2.3