From 1988522c74f0dd6bc18a29821aabee70c132ce5e Mon Sep 17 00:00:00 2001 From: KingZero Date: Sun, 2 Aug 2009 02:49:46 +0200 Subject: added megaupload plugin --- Plugins/MegauploadCom.py | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ captcha/captcha.py | 1 - config | 2 +- module/file_list.py | 2 ++ 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 Plugins/MegauploadCom.py diff --git a/Plugins/MegauploadCom.py b/Plugins/MegauploadCom.py new file mode 100644 index 000000000..6f5882458 --- /dev/null +++ b/Plugins/MegauploadCom.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import re +import tempfile +from time import time +from time import sleep + +from Plugin import Plugin + +class MegauploadCom(Plugin): + + def __init__(self, parent): + Plugin.__init__(self, parent) + props = {} + props['name'] = "MegauploadCom" + props['type'] = "hoster" + props['pattern'] = r"http://(?:www.)megaupload.com/" + props['version'] = "0.1" + props['description'] = """Megaupload.com Download Plugin""" + props['author_name'] = ("spoob") + props['author_mail'] = ("spoob@pyload.org") + self.props = props + self.parent = parent + self.html = [None, None] + self.want_reconnect = False + self.init_ocr() + self.multi_dl = False + + def download_html(self): + url = self.parent.url + + captcha_image = tempfile.NamedTemporaryFile(suffix=".gif").name + + for i in range(5): + self.html[0] = self.req.load(url, cookies=True) + url_captcha_html = re.search('(http://www.{,3}\.megaupload\.com/gencap.php\?.*\.gif)', self.html[0]).group(1) + self.req.download(url_captcha_html, captcha_image, cookies=True) + captcha = self.ocr.get_captcha(captcha_image) + captchacode = re.search('name="captchacode" value="(.*)"', self.html[0]).group(1) + megavar = re.search('name="megavar" value="(.*)">', self.html[0]).group(1) + self.html[1] = self.req.load(url, post={"captcha": captcha, "captchacode": captchacode, "megavar": megavar}, cookies=True) + if re.search(r"Waiting time before each download begins", self.html[1]) != None: + break + + os.remove(captcha_image) + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if self.html[0] == None: + self.download_html() + if not self.want_reconnect: + file_url_pattern = 'id="downloadlink">(.*)
' + return re.search(file_name_pattern, self.html[0]).group(1) + else: + return self.parent.url + + def file_exists(self): + """ returns True or False + """ + if self.html[0] == None: + self.download_html() + if re.search(r"Unfortunately, the link you have clicked is not available.", self.html[0]) != None: + return False + else: + return True + + def proceed(self, url, location): + self.req.download(url, location, cookies=True) diff --git a/captcha/captcha.py b/captcha/captcha.py index 6d4cd86e8..073637795 100644 --- a/captcha/captcha.py +++ b/captcha/captcha.py @@ -75,7 +75,6 @@ class OCR(object): thread = RunThread() result = thread.e(command, inputdata) - print result return result def run_gocr(self): diff --git a/config b/config index 8769710b2..acffa9bcc 100644 --- a/config +++ b/config @@ -4,7 +4,7 @@ language: de download_folder = Downloads link_file = links.txt failed_file = failed_links.txt -use_reconnect = True +use_reconnect = False reconnect_method = reconnect max_downloads = 3 [updates] diff --git a/module/file_list.py b/module/file_list.py index cb7336620..b96c7a63d 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -57,6 +57,8 @@ class File_List(object): def remove(self, pyfile): + #pass + if pyfile in self.files: self.files.remove(pyfile) -- cgit v1.2.3