adding stanford open class courses

This commit is contained in:
gcmalloc 2012-10-23 23:59:12 +02:00
parent 2876773381
commit 103c508ffa

View file

@ -8,7 +8,7 @@ from youtube_dl.FileDownloader import FileDownloader
from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE from youtube_dl.InfoExtractors import YoutubeIE, DailymotionIE
from youtube_dl.InfoExtractors import MetacafeIE, BlipTVIE from youtube_dl.InfoExtractors import MetacafeIE, BlipTVIE
from youtube_dl.InfoExtractors import XVideosIE, VimeoIE from youtube_dl.InfoExtractors import XVideosIE, VimeoIE
from youtube_dl.InfoExtractors import SoundcloudIE from youtube_dl.InfoExtractors import SoundcloudIE, StanfordOpenClassroomIE
class DownloadTest(unittest.TestCase): class DownloadTest(unittest.TestCase):
@ -44,6 +44,11 @@ class DownloadTest(unittest.TestCase):
SOUNDCLOUD_URL = "http://soundcloud.com/ethmusic/lostin-powers-she-so-heavy" SOUNDCLOUD_URL = "http://soundcloud.com/ethmusic/lostin-powers-she-so-heavy"
SOUNDCLOUD_FILE = "n6FLbx6ZzMiu.mp3" SOUNDCLOUD_FILE = "n6FLbx6ZzMiu.mp3"
STANDFORD_MD5 = "22c8206291368c4e2c9c1a307f0ea0f4"
STANDFORD_URL = "http://openclassroom.stanford.edu/MainFolder/VideoPage.php?course=PracticalUnix&video=intro-environment&speed=100"
STANDFORD_FILE = "PracticalUnix_intro-environment.mp4"
def test_youtube(self): def test_youtube(self):
#let's download a file from youtube #let's download a file from youtube
with open(DownloadTest.PARAMETERS_FILE) as f: with open(DownloadTest.PARAMETERS_FILE) as f:
@ -108,6 +113,15 @@ class DownloadTest(unittest.TestCase):
md5_down_file = md5_for_file(DownloadTest.SOUNDCLOUD_FILE) md5_down_file = md5_for_file(DownloadTest.SOUNDCLOUD_FILE)
self.assertEqual(md5_down_file, DownloadTest.SOUNDCLOUD_MD5) self.assertEqual(md5_down_file, DownloadTest.SOUNDCLOUD_MD5)
def test_standford(self):
with open(DownloadTest.PARAMETERS_FILE) as f:
fd = FileDownloader(json.load(f))
fd.add_info_extractor(StanfordOpenClassroomIE())
fd.download([DownloadTest.STANDFORD_URL])
self.assertTrue(os.path.exists(DownloadTest.STANDFORD_FILE))
md5_down_file = md5_for_file(DownloadTest.STANDFORD_FILE)
self.assertEqual(md5_down_file, DownloadTest.STANDFORD_MD5)
def tearDown(self): def tearDown(self):
if os.path.exists(DownloadTest.YOUTUBE_FILE): if os.path.exists(DownloadTest.YOUTUBE_FILE):
os.remove(DownloadTest.YOUTUBE_FILE) os.remove(DownloadTest.YOUTUBE_FILE)
@ -123,6 +137,8 @@ class DownloadTest(unittest.TestCase):
os.remove(DownloadTest.VIMEO_FILE) os.remove(DownloadTest.VIMEO_FILE)
if os.path.exists(DownloadTest.SOUNDCLOUD_FILE): if os.path.exists(DownloadTest.SOUNDCLOUD_FILE):
os.remove(DownloadTest.SOUNDCLOUD_FILE) os.remove(DownloadTest.SOUNDCLOUD_FILE)
if os.path.exists(DownloadTest.STANDFORD_FILE):
os.remove(DownloadTest.STANDFORD_FILE)
def md5_for_file(filename, block_size=2**20): def md5_for_file(filename, block_size=2**20):
with open(filename) as f: with open(filename) as f: