Exemple #1
0
class EdXBrowser(object):
    def __init__(self, config):
        self._br = mechanize.Browser()
        self._cj = mechanize.LWPCookieJar()
        csrftoken = makeCsrf()
        self._cj.set_cookie(csrfCookie(csrftoken))
        self._br.set_handle_robots(False)
        self._br.set_cookiejar(self._cj)
        self._br.addheaders.append(('X-CSRFToken', csrftoken))
        self._br.addheaders.append(('Referer', base_url))
        self._logged_in = False
        self._fd = FileDownloader(config.YDL_PARAMS)
        self._fd.add_info_extractor(YoutubeIE())
        self._config = config

    def login(self):
        try:
            login_resp = self._br.open(
                base_url + login_url,
                urlencode({
                    'email': self._config.EMAIL,
                    'password': self._config.PASSWORD
                }))
            login_state = json.loads(login_resp.read())
            self._logged_in = login_state.get('success')
            if not self._logged_in:
                print login_state.get('value')
            return self._logged_in
        except mechanize.HTTPError, e:
            sys.exit('Can\'t sign in')
Exemple #2
0
class EdXBrowser(object):
    def __init__(self, config):
        self._br = mechanize.Browser()
        self._cj = mechanize.LWPCookieJar()
        csrftoken = makeCsrf()
        self._cj.set_cookie(csrfCookie(csrftoken))
        self._br.set_handle_robots(False)
        self._br.set_cookiejar(self._cj)
        self._br.addheaders.append(("X-CSRFToken", csrftoken))
        self._br.addheaders.append(("Referer", base_url))
        self._logged_in = False
        self._fd = FileDownloader(config.YDL_PARAMS)
        self._fd.add_info_extractor(YoutubeIE())
        self._config = config

    def login(self):
        try:
            login_resp = self._br.open(
                base_url + login_url, urlencode({"email": self._config.EMAIL, "password": self._config.PASSWORD})
            )
            login_state = json.loads(login_resp.read())
            self._logged_in = login_state.get("success")
            if not self._logged_in:
                print login_state.get("value")
            return self._logged_in
        except mechanize.HTTPError, e:
            sys.exit("Can't sign in")
class TenGenBrowser(object):
    def __init__(self):
        self._br = mechanize.Browser()
        self._cj = mechanize.LWPCookieJar()
        csrftoken = makeCsrf()
        self._cj.set_cookie(csrfCookie(csrftoken))
        self._br.set_handle_robots(False)
        self._br.set_cookiejar(self._cj)
        self._br.addheaders.append(('X-CSRFToken',csrftoken))
        self._br.addheaders.append(('Referer',SITE_URL))
        self._logged_in = False
        with open(YDL_PARAMS_FILE) as fydl:
            self._fd = FileDownloader(json.load(fydl))
            self._fd.add_info_extractor(YoutubeIE())

    def login(self, email, password):
        try:
            login_resp = self._br.open(SITE_URL + login_url, urlencode({'email':email, 'password':password}))
            login_state = json.loads(login_resp.read())
            self._logged_in = login_state.get('success')
            if not self._logged_in:
                print login_state.get('value')
            return self._logged_in
        except mechanize.HTTPError, e:
            sys.exit('Can\'t sign in')
Exemple #4
0
 def test_Youtube(self):
     filename = 'BaW_jenozKc.mp4'
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.YoutubeIE())
     fd.download(['http://www.youtube.com/watch?v=BaW_jenozKc'])
     self.assertTrue(os.path.exists(filename))
     self.assertEqual(os.path.getsize(filename), 1993883)
Exemple #5
0
	def test_dailymotion(self):
		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)
Exemple #6
0
	def test_youtube(self):
		#let's download a file from youtube
		with open(DownloadTest.PARAMETERS_FILE) as f:
			fd = FileDownloader(json.load(f))
		fd.add_info_extractor(YoutubeIE())
		fd.download([DownloadTest.YOUTUBE_URL])
		self.assertTrue(os.path.exists(DownloadTest.YOUTUBE_FILE))
		self.assertEqual(os.path.getsize(DownloadTest.YOUTUBE_FILE), DownloadTest.YOUTUBE_SIZE)
Exemple #7
0
 def test_Vimeo(self):
     filename = ''
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.VimeoIE())
     fd.download(['http://vimeo.com/14160053'])
     self.assertTrue(os.path.exists(filename))
     md5_for_file = _file_md5(filename)
     self.assertEqual(md5_for_file, '1ab4dedc01f771cb2a65e91caa801aaf')
Exemple #8
0
 def test_Soundcloud(self):
     filename = 'n6FLbx6ZzMiu.mp3'
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.SoundcloudIE())
     fd.download(['http://soundcloud.com/ethmusic/lostin-powers-she-so-heavy'])
     self.assertTrue(os.path.exists(filename))
     md5_for_file = _file_md5(filename)
     self.assertEqual(md5_for_file, 'c1b9b9ea8bfd620b96b2628664576e1c')
Exemple #9
0
 def test_BlipTV(self):
     filename = '5779306.m4v'
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.BlipTVIE())
     fd.download(['http://blip.tv/cbr/cbr-exclusive-gotham-city-imposters-bats-vs-jokerz-short-3-5796352'])
     self.assertTrue(os.path.exists(filename))
     md5_for_file = _file_md5(filename)
     self.assertEqual(md5_for_file, '4962f94441605832eb1008eb820ef47a')
Exemple #10
0
 def test_Dailymotion(self):
     filename = 'x33vw9.mp4'
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.DailymotionIE())
     fd.download(['http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech'])
     self.assertTrue(os.path.exists(filename))
     md5_for_file = _file_md5(filename)
     self.assertEqual(md5_for_file, 'd363a50e9eb4f22ce90d08d15695bb47')
Exemple #11
0
 def test_Youku(self):
     filename = 'XNDgyMDQ2NTQw_part00.flv'
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.YoukuIE())
     fd.download(['http://v.youku.com/v_show/id_XNDgyMDQ2NTQw.html'])
     self.assertTrue(os.path.exists(filename))
     md5_for_file = _file_md5(filename)
     self.assertEqual(md5_for_file, 'ffe3f2e435663dc2d1eea34faeff5b5b')
Exemple #12
0
 def test_XNXX(self):
     filename = '1135332.flv'
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.XNXXIE())
     fd.download(['http://video.xnxx.com/video1135332/lida_naked_funny_actress_5_'])
     self.assertTrue(os.path.exists(filename))
     md5_for_file = _file_md5(filename)
     self.assertEqual(md5_for_file, 'c5c67df477eb0d9b058200351448ba4c')
Exemple #13
0
 def test_CollegeHumor(self):
     filename = ''
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.CollegeHumorIE())
     fd.download(['http://www.collegehumor.com/video/6830834/mitt-romney-style-gangnam-style-parody'])
     self.assertTrue(os.path.exists(filename))
     md5_for_file = _file_md5(filename)
     self.assertEqual(md5_for_file, '')
Exemple #14
0
 def test_StanfordOpenClassroom(self):
     filename = 'PracticalUnix_intro-environment.mp4'
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.StanfordOpenClassroomIE())
     fd.download(['http://openclassroom.stanford.edu/MainFolder/VideoPage.php?course=PracticalUnix&video=intro-environment&speed=100'])
     self.assertTrue(os.path.exists(filename))
     md5_for_file = _file_md5(filename)
     self.assertEqual(md5_for_file, '8aac7873a07dcfaed66b1559ab128514')
Exemple #15
0
	def test_blip(self):
		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)
Exemple #16
0
 def test_XVideos(self):
     filename = '939581.flv'
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.XVideosIE())
     fd.download(['http://www.xvideos.com/video939581/funny_porns_by_s_-1'])
     self.assertTrue(os.path.exists(filename))
     md5_for_file = _file_md5(filename)
     self.assertEqual(md5_for_file, 'aecab2ea59b7996110a7e409f0c55da3')
Exemple #17
0
 def __init__(self):
     self._br = mechanize.Browser()
     self._cj = mechanize.LWPCookieJar()
     csrftoken = makeCsrf()
     self._cj.set_cookie(csrfCookie(csrftoken))
     self._br.set_handle_robots(False)
     self._br.set_cookiejar(self._cj)
     self._br.addheaders.append(('X-CSRFToken',csrftoken))
     self._br.addheaders.append(('Referer',base_url))
     self._logged_in = False
     self._fd = FileDownloader(config.YDL_PARAMS)
     self._fd.add_info_extractor(YoutubeIE())
Exemple #18
0
 def test_Metacafe(self):
     filename = 'aUehQsCQtM.flv'
     fd = FileDownloader(self.parameters)
     fd.add_info_extractor(youtube_dl.InfoExtractors.MetacafeIE())
     fd.add_info_extractor(youtube_dl.InfoExtractors.YoutubeIE())
     fd.download(['http://www.metacafe.com/watch/yt-_aUehQsCQtM/the_electric_company_short_i_pbs_kids_go/'])
     self.assertTrue(os.path.exists(filename))
     self.assertEqual(os.path.getsize(filename), 5754305)
Exemple #19
0
	def test_metacafe(self):
		#this emulate a skip,to be 2.6 compatible
		with open(DownloadTest.PARAMETERS_FILE) as f:
			fd = FileDownloader(json.load(f))
		fd.add_info_extractor(MetacafeIE())
		fd.add_info_extractor(YoutubeIE())
		fd.download([DownloadTest.METACAFE_URL])
		self.assertTrue(os.path.exists(DownloadTest.METACAFE_FILE))
		self.assertEqual(os.path.getsize(DownloadTest.METACAFE_FILE), DownloadTest.METACAFE_SIZE)
 def __init__(self):
     self._br = mechanize.Browser()
     self._cj = mechanize.LWPCookieJar()
     csrftoken = makeCsrf()
     self._cj.set_cookie(csrfCookie(csrftoken))
     self._br.set_handle_robots(False)
     self._br.set_cookiejar(self._cj)
     self._br.addheaders.append(('X-CSRFToken',csrftoken))
     self._br.addheaders.append(('Referer',SITE_URL))
     self._logged_in = False
     with open(YDL_PARAMS_FILE) as fydl:
         self._fd = FileDownloader(json.load(fydl))
         self._fd.add_info_extractor(YoutubeIE())
Exemple #21
0
 def test_template(self):
     fd = FileDownloader(ie_param)
     fd.add_info_extractor(getattr(youtube_dl, name + "IE")())
     fd.download([url])
     self.assertTrue(os.path.exists(file))
     self.assertEqual(md5_for_file(file), md5)