From b387fb0385444da4564b64e079ad1d2bba1e9e16 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Fri, 28 Sep 2012 13:29:39 +0200 Subject: [PATCH 01/18] adding test rule in the Makefile --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index f9c0aef0b..c73d0ac65 100644 --- a/Makefile +++ b/Makefile @@ -45,3 +45,8 @@ youtube-dl.bash-completion: README.md LATEST_VERSION: youtube_dl/__init__.py python -m youtube_dl --version > LATEST_VERSION + +test: + nosetests2 test/* + +.PHONY: default compile update update-latest update-readme test From 9993976ae436c62ef86c2c45f0f001e5f7e471bd Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Fri, 28 Sep 2012 14:06:37 +0200 Subject: [PATCH 02/18] correction on the sanitize title method, change in title resulting --- test/test_div.py | 29 ----------------------------- test/test_utils.py | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 29 deletions(-) delete mode 100644 test/test_div.py create mode 100644 test/test_utils.py diff --git a/test/test_div.py b/test/test_div.py deleted file mode 100644 index 4d4819b3c..000000000 --- a/test/test_div.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -# Various small unit tests - -import os,sys -sys.path.append(os.path.dirname(os.path.dirname(__file__))) - -import youtube_dl - -def test_simplify_title(): - assert youtube_dl._simplify_title(u'abc') == u'abc' - assert youtube_dl._simplify_title(u'abc_d-e') == u'abc_d-e' - - assert youtube_dl._simplify_title(u'123') == u'123' - - assert u'/' not in youtube_dl._simplify_title(u'abc/de') - assert u'abc' in youtube_dl._simplify_title(u'abc/de') - assert u'de' in youtube_dl._simplify_title(u'abc/de') - assert u'/' not in youtube_dl._simplify_title(u'abc/de///') - - assert u'\\' not in youtube_dl._simplify_title(u'abc\\de') - assert u'abc' in youtube_dl._simplify_title(u'abc\\de') - assert u'de' in youtube_dl._simplify_title(u'abc\\de') - - assert youtube_dl._simplify_title(u'ä') == u'ä' - assert youtube_dl._simplify_title(u'кириллица') == u'кириллица' - - # Strip underlines - assert youtube_dl._simplify_title(u'\'a_') == u'a' diff --git a/test/test_utils.py b/test/test_utils.py new file mode 100644 index 000000000..614ef1b03 --- /dev/null +++ b/test/test_utils.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +# Various small unit tests + +from youtube_dl.utils import sanitize_filename + +def test_sanitize_filename(): + assert sanitize_filename(u'abc') == u'abc' + assert sanitize_filename(u'abc_d-e') == u'abc_d-e' + + assert sanitize_filename(u'123') == u'123' + + assert u'/' not in sanitize_filename(u'abc/de') + assert u'abc' in sanitize_filename(u'abc/de') + assert u'de' in sanitize_filename(u'abc/de') + assert u'/' not in sanitize_filename(u'abc/de///') + + assert u'\\' not in sanitize_filename(u'abc\\de') + assert u'abc' in sanitize_filename(u'abc\\de') + assert u'de' in sanitize_filename(u'abc\\de') + + assert sanitize_filename(u'ä') == u'ä' + assert sanitize_filename(u'кириллица') == u'кириллица' From 44fb345437553801184377dde05cc8a312fd2da2 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Fri, 28 Sep 2012 14:47:01 +0200 Subject: [PATCH 03/18] adding TestCase class and corresponding test --- test/test_utils.py | 51 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/test/test_utils.py b/test/test_utils.py index 614ef1b03..d4b4cb920 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -2,22 +2,47 @@ # Various small unit tests +import unittest + +#from youtube_dl.utils import htmlentity_transform +from youtube_dl.utils import timeconvert from youtube_dl.utils import sanitize_filename +from youtube_dl.utils import unescapeHTML +from youtube_dl.utils import orderedSet -def test_sanitize_filename(): - assert sanitize_filename(u'abc') == u'abc' - assert sanitize_filename(u'abc_d-e') == u'abc_d-e' - assert sanitize_filename(u'123') == u'123' +class TestUtil(unittest.TestCase): + def test_timeconvert(self): + self.assertIsNone(timeconvert('')) + self.assertIsNone(timeconvert('bougrg')) - assert u'/' not in sanitize_filename(u'abc/de') - assert u'abc' in sanitize_filename(u'abc/de') - assert u'de' in sanitize_filename(u'abc/de') - assert u'/' not in sanitize_filename(u'abc/de///') + def test_sanitize_filename(self): + self.assertEqual(sanitize_filename(u'abc'), u'abc') + self.assertEqual(sanitize_filename(u'abc_d-e'), u'abc_d-e') + + self.assertEqual(sanitize_filename(u'123'), u'123') + + self.assertNotIn(u'/', sanitize_filename(u'abc/de')) + self.assertNotIn(u'abc', sanitize_filename(u'abc/de')) + self.assertIn(u'de', sanitize_filename(u'abc/de')) + self.assertNotIn(u'/', sanitize_filename(u'abc/de///')) + + self.assertIn(u'\\', sanitize_filename(u'abc\\de')) + self.assertIn(u'abc', sanitize_filename(u'abc\\de')) + self.assertIn(u'de', sanitize_filename(u'abc\\de')) + + self.assertEqual(sanitize_filename(u'ä'), u'ä') + self.assertEqual(sanitize_filename(u'кириллица'), u'кириллица') + + def test_ordered_set(self): + self.assertEqual(orderedSet([1,1,2,3,4,4,5,6,7,3,5]), [1,2,3,4,5,6,7]) + self.assertEqual(orderedSet([]), []) + self.assertEqual(orderedSet([1]), [1]) + #keep the list ordered + self.assertEqual(orderedSet([135,1,1,1]), [135,1]) + + def test_unescape_html(self): + self.assertEqual(unescapeHTML(u"%20;"), u"%20;") + self.assertEqual(unescapeHTML(u"gre&tre&yre"), [u'gre', u'tre', u'yre']) - assert u'\\' not in sanitize_filename(u'abc\\de') - assert u'abc' in sanitize_filename(u'abc\\de') - assert u'de' in sanitize_filename(u'abc\\de') - assert sanitize_filename(u'ä') == u'ä' - assert sanitize_filename(u'кириллица') == u'кириллица' From efe8902f0b354bc43ea36cd09778b1454fbd4bb3 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Fri, 28 Sep 2012 15:34:56 +0200 Subject: [PATCH 04/18] adding download test with md5 check --- test/test_download.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 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() From 434d60cd955ba04c2deb2c40803332235d0077d7 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Fri, 28 Sep 2012 17:57:21 +0200 Subject: [PATCH 05/18] adding clean rule in the makefile --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c73d0ac65..f52dd1dd6 100644 --- a/Makefile +++ b/Makefile @@ -49,4 +49,7 @@ LATEST_VERSION: youtube_dl/__init__.py test: nosetests2 test/* -.PHONY: default compile update update-latest update-readme test +clean: + $$(rm **/*.pyc) + +.PHONY: default compile update update-latest update-readme test clean From 80a846e119af18bb7da005c3d267a7af7a7b6a0d Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Fri, 28 Sep 2012 18:00:20 +0200 Subject: [PATCH 06/18] correction on the test for the utils.py --- test/test_utils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/test_utils.py b/test/test_utils.py index d4b4cb920..910fcfad4 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -22,13 +22,12 @@ class TestUtil(unittest.TestCase): self.assertEqual(sanitize_filename(u'123'), u'123') - self.assertNotIn(u'/', sanitize_filename(u'abc/de')) - self.assertNotIn(u'abc', sanitize_filename(u'abc/de')) + self.assertEqual(u'abc_de', sanitize_filename(u'abc/de')) self.assertIn(u'de', sanitize_filename(u'abc/de')) self.assertNotIn(u'/', sanitize_filename(u'abc/de///')) - self.assertIn(u'\\', sanitize_filename(u'abc\\de')) - self.assertIn(u'abc', sanitize_filename(u'abc\\de')) + self.assertEqual(u'abc_de', sanitize_filename(u'abc\\de')) + self.assertEqual(u'abc_de', sanitize_filename(u'abc\\de')) self.assertIn(u'de', sanitize_filename(u'abc\\de')) self.assertEqual(sanitize_filename(u'ä'), u'ä') @@ -43,6 +42,5 @@ class TestUtil(unittest.TestCase): def test_unescape_html(self): self.assertEqual(unescapeHTML(u"%20;"), u"%20;") - self.assertEqual(unescapeHTML(u"gre&tre&yre"), [u'gre', u'tre', u'yre']) From 0b4e98490b6124eae868425e683a492c49b047ae Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Tue, 2 Oct 2012 19:37:48 +0200 Subject: [PATCH 07/18] changing test video --- test/test_download.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 From 5a33b733096d3bd8a6396c04fbe6804de3946927 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 14:07:19 +0200 Subject: [PATCH 08/18] correcting the makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f52dd1dd6..9f8dc6d93 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,6 @@ test: nosetests2 test/* clean: - $$(rm **/*.pyc) + rm **/*.pyc .PHONY: default compile update update-latest update-readme test clean From 3eec021a1f4116a5ac0e0a9d4adeecb6a5d816ec Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 14:20:04 +0200 Subject: [PATCH 09/18] removing unused global modifier --- youtube_dl/FileDownloader.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index 38c6a519a..ed5a79f13 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -13,7 +13,7 @@ import urllib2 if os.name == 'nt': import ctypes - + from utils import * @@ -173,7 +173,6 @@ class FileDownloader(object): if not self.params.get('quiet', False): terminator = [u'\n', u''][skip_eol] output = message + terminator - if 'b' not in self._screen_file.mode or sys.version_info[0] < 3: # Python 2 lies about the mode of sys.stdout/sys.stderr output = output.encode(preferredencoding(), 'ignore') self._screen_file.write(output) @@ -357,7 +356,7 @@ class FileDownloader(object): raise MaxDownloadsReached() filename = self.prepare_filename(info_dict) - + # Forced printings if self.params.get('forcetitle', False): print info_dict['title'].encode(preferredencoding(), 'xmlcharrefreplace') @@ -399,10 +398,10 @@ class FileDownloader(object): except (OSError, IOError): self.trouble(u'ERROR: Cannot write description file ' + descfn) return - + if self.params.get('writesubtitles', False) and 'subtitles' in info_dict and info_dict['subtitles']: # subtitles download errors are already managed as troubles in relevant IE - # that way it will silently go on when used with unsupporting IE + # that way it will silently go on when used with unsupporting IE try: srtfn = filename.rsplit('.', 1)[0] + u'.srt' self.report_writesubtitles(srtfn) @@ -448,7 +447,7 @@ class FileDownloader(object): except (ContentTooShortError, ), err: self.trouble(u'ERROR: content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded)) return - + if success: try: self.post_process(filename, info_dict) From 137c5803c35f3e06d821ede1ef69733c3b8d338c Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 14:25:54 +0200 Subject: [PATCH 10/18] some changes to keep the same standard --- test/test_download.py | 47 +++++++++++++++++++++--------------------- test/test_utils.py | 48 +++++++++++++++++++++---------------------- 2 files changed, 46 insertions(+), 49 deletions(-) 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() diff --git a/test/test_utils.py b/test/test_utils.py index 910fcfad4..fd3ac4d46 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -12,35 +12,33 @@ from youtube_dl.utils import orderedSet class TestUtil(unittest.TestCase): - def test_timeconvert(self): - self.assertIsNone(timeconvert('')) - self.assertIsNone(timeconvert('bougrg')) + def test_timeconvert(self): + self.assertIsNone(timeconvert('')) + self.assertIsNone(timeconvert('bougrg')) - def test_sanitize_filename(self): - self.assertEqual(sanitize_filename(u'abc'), u'abc') - self.assertEqual(sanitize_filename(u'abc_d-e'), u'abc_d-e') + def test_sanitize_filename(self): + self.assertEqual(sanitize_filename(u'abc'), u'abc') + self.assertEqual(sanitize_filename(u'abc_d-e'), u'abc_d-e') - self.assertEqual(sanitize_filename(u'123'), u'123') + self.assertEqual(sanitize_filename(u'123'), u'123') - self.assertEqual(u'abc_de', sanitize_filename(u'abc/de')) - self.assertIn(u'de', sanitize_filename(u'abc/de')) - self.assertNotIn(u'/', sanitize_filename(u'abc/de///')) + self.assertEqual(u'abc_de', sanitize_filename(u'abc/de')) + self.assertIn(u'de', sanitize_filename(u'abc/de')) + self.assertNotIn(u'/', sanitize_filename(u'abc/de///')) - self.assertEqual(u'abc_de', sanitize_filename(u'abc\\de')) - self.assertEqual(u'abc_de', sanitize_filename(u'abc\\de')) - self.assertIn(u'de', sanitize_filename(u'abc\\de')) + self.assertEqual(u'abc_de', sanitize_filename(u'abc\\de')) + self.assertEqual(u'abc_de', sanitize_filename(u'abc\\de')) + self.assertIn(u'de', sanitize_filename(u'abc\\de')) - self.assertEqual(sanitize_filename(u'ä'), u'ä') - self.assertEqual(sanitize_filename(u'кириллица'), u'кириллица') - - def test_ordered_set(self): - self.assertEqual(orderedSet([1,1,2,3,4,4,5,6,7,3,5]), [1,2,3,4,5,6,7]) - self.assertEqual(orderedSet([]), []) - self.assertEqual(orderedSet([1]), [1]) - #keep the list ordered - self.assertEqual(orderedSet([135,1,1,1]), [135,1]) - - def test_unescape_html(self): - self.assertEqual(unescapeHTML(u"%20;"), u"%20;") + self.assertEqual(sanitize_filename(u'ä'), u'ä') + self.assertEqual(sanitize_filename(u'кириллица'), u'кириллица') + def test_ordered_set(self): + self.assertEqual(orderedSet([1,1,2,3,4,4,5,6,7,3,5]), [1,2,3,4,5,6,7]) + self.assertEqual(orderedSet([]), []) + self.assertEqual(orderedSet([1]), [1]) + #keep the list ordered + self.assertEqual(orderedSet([135,1,1,1]), [135,1]) + def test_unescape_html(self): + self.assertEqual(unescapeHTML(u"%20;"), u"%20;") From ff08984246ee635dc2cf89ff105f92b1098e5011 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 14:42:05 +0200 Subject: [PATCH 11/18] adding dailymotion test --- test/test_download.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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() From a4b5f2255436251b5e2d1a3ae1da369587f01f1f Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 14:47:12 +0200 Subject: [PATCH 12/18] adding metacafe test --- test/test_download.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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) From b4e5de51ec572ea086ebd392b7dac686ced15923 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 14:52:06 +0200 Subject: [PATCH 13/18] adding photobucket test --- test/test_download.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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() From 6da7877bf54f881235149d5856fe32ae4770ed90 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 15:13:37 +0200 Subject: [PATCH 14/18] adding facebook test --- test/test_download.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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() From 4c9afeca34ba3d981fa51db18fe9522212ffad4c Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Wed, 3 Oct 2012 21:10:13 +0200 Subject: [PATCH 15/18] adding xvideo --- test/test_download.py | 51 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) 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() From 729baf58b2dc6c288b54a00331acef2e62cdbe85 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Fri, 5 Oct 2012 15:52:40 +0200 Subject: [PATCH 16/18] removing extended globbing for the find utility --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9f8dc6d93..e44531527 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,6 @@ test: nosetests2 test/* clean: - rm **/*.pyc + find -name "*.pyc" -delete .PHONY: default compile update update-latest update-readme test clean From 6d9c22cd267b294c6e2abe9b0256c24a090a9349 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Fri, 12 Oct 2012 20:30:01 +0200 Subject: [PATCH 17/18] correcting the makefile according to the new one --- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e44531527..4677ff684 100644 --- a/Makefile +++ b/Makefile @@ -47,9 +47,6 @@ LATEST_VERSION: youtube_dl/__init__.py python -m youtube_dl --version > LATEST_VERSION test: - nosetests2 test/* - -clean: - find -name "*.pyc" -delete + nosetests2 test .PHONY: default compile update update-latest update-readme test clean From 17d4af4a9255e87eed69e02334d540b176156c90 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Mon, 15 Oct 2012 10:37:33 +0200 Subject: [PATCH 18/18] adding travis support --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..05dd519a8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python +#specify the python version +python: + - "2.6" + - "2.7" +# command to run tests +script: nosetests tests