diff options
-rw-r--r-- | module/config/default.conf | 2 | ||||
-rwxr-xr-x | module/network/Request.py | 3 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 46 | ||||
-rw-r--r-- | module/plugins/hoster/MegauploadCom.py | 18 | ||||
-rw-r--r-- | module/plugins/hoster/OneFichierCom.py | 3 | ||||
-rw-r--r-- | module/plugins/hoster/RapidshareCom.py | 6 |
6 files changed, 57 insertions, 21 deletions
diff --git a/module/config/default.conf b/module/config/default.conf index 407b709f1..4ccf2e555 100644 --- a/module/config/default.conf +++ b/module/config/default.conf @@ -50,5 +50,5 @@ downloadTime - "Download Time": time end : "End" = 0:00
proxy - "Proxy":
bool activated : "Activated" = False
- str adress : "Adress" = http://localhost:8080
+ str address : "Address" = http://localhost:8080
str protocol : "Protocol" = http
diff --git a/module/network/Request.py b/module/network/Request.py index 8638cc66a..f322c847a 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -22,7 +22,6 @@ import base64 import time -from os import stat from os.path import exists, join from shutil import move import urllib @@ -232,7 +231,7 @@ class Request: self.pycurl.setopt(pycurl.URL, url) if self.canContinue: - self.offset = stat(file_temp).st_size + self.offset = partSize self.pycurl.setopt(pycurl.RESUME_FROM, self.offset) self.dl_arrived = self.offset diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index ba65370c5..8009c8f01 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -18,7 +18,6 @@ """ import logging -from os.path import join from time import time from time import sleep @@ -26,12 +25,14 @@ from time import sleep from random import randint import sys -from os.path import exists import os from os import remove from os import makedirs from os import chmod +from os import stat +from os.path import exists +from os.path import join if os.name != "nt": from os import chown @@ -96,6 +97,7 @@ class Plugin(object): if self.account and not self.account.canUse(): self.account = None if self.account: self.req = self.account.getAccountRequest(self) + #self.req.canContinue = True else: self.req = pyfile.m.core.requestFactory.getRequest(self.__name__) @@ -104,6 +106,8 @@ class Plugin(object): self.pyfile = pyfile self.thread = None # holds thread in future + self.lastDownload = "" #location where the last call to download was saved + self.setup() def __call__(self): @@ -120,6 +124,9 @@ class Plugin(object): if not self.account: self.req.clearCookies() + if self.core.config["proxy"]["activated"]: + self.req.add_proxy(None, self.core.config["proxy"]["address"]) + self.pyfile.setStatus("starting") return self.process(self.pyfile) @@ -288,7 +295,8 @@ class Plugin(object): self.pyfile.size = self.req.dl_size - if newname: + if newname and newname != name: + self.log.info("%(name)s saved as %(newname)s" % {"name": name, "newname": newname}) name = newname self.pyfile.name = newname @@ -304,4 +312,34 @@ class Plugin(object): except Exception,e: self.log.warning(_("Setting User and Group failed: %s") % str(e)) - return join(location, name)
\ No newline at end of file + self.lastDownload = join(location, name) + return self.lastDownload + + def checkDownload(self, rules, api_size=0 ,max_size=50000, delete=True): + """ checks the content of the last downloaded file + rules - dict with names and rules to match(re or strings) + size - excpected size + @return name of first rule matched or None""" + + if not exists(self.lastDownload): return None + + size = stat(self.lastDownload) + size = size.st_size + + if api_size and api_size <= size: return None + elif size > max_size: return None + + f = open(self.lastDownload, "rb") + content = f.read() + f.close() + for name, rule in rules.iteritems(): + if type(rule) in (str, unicode): + if rule in content: + if delete: + remove(self.lastDownload) + return name + elif hasattr(rule, "match"): + if rule.match(content): + if delete: + remove(self.lastDownload) + return name diff --git a/module/plugins/hoster/MegauploadCom.py b/module/plugins/hoster/MegauploadCom.py index 3712bb8d5..4d3a2a566 100644 --- a/module/plugins/hoster/MegauploadCom.py +++ b/module/plugins/hoster/MegauploadCom.py @@ -47,15 +47,20 @@ class MegauploadCom(Hoster): __name__ = "MegauploadCom" __type__ = "hoster" __pattern__ = r"http://[\w\.]*?(megaupload)\.com/.*?(\?|&)d=[0-9A-Za-z]+" - __version__ = "0.1" + __version__ = "0.2" __description__ = """Megaupload.com Download Hoster""" __author_name__ = ("spoob") __author_mail__ = ("spoob@pyload.org") def setup(self): self.html = [None, None] - self.multiDL = False + if self.account: + self.multiDL = True + self.req.canContinue = True + else: + self.multiDL = False self.api = {} + def process(self, pyfile): self.pyfile = pyfile @@ -117,19 +122,14 @@ class MegauploadCom(Hoster): post = {"id0": id} api = self.load(url, {}, post) + self.log.debug("MU API: %s" % api) api = [x.split("&") for x in re.split(r"&?(?=id[\d]+=)", api)] for data in api: if data[0].startswith("id"): tmp = [x.split("=") for x in data] - if tmp[2][1] == "3": - status = 3 - elif tmp[0][1] == "0": - status = 2 - elif tmp[0][1] == "1": + if tmp[0][1] == "1": self.offline() - else: - status = 3 name = tmp[3][1] #size = tmp[1][1] diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py index 8461482ad..ce7697943 100644 --- a/module/plugins/hoster/OneFichierCom.py +++ b/module/plugins/hoster/OneFichierCom.py @@ -19,7 +19,7 @@ class OneFichierCom(Hoster): self.multiDL = False def process(self, pyfile): - self.pyfile = pyfile + self.download_html() if not self.file_exists(): @@ -30,7 +30,6 @@ class OneFichierCom(Hoster): pyfile.size = self.get_file_size() url = self.get_file_url() - self.pyfile.setStatus("downloading") self.download(url) def download_html(self): diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index ab99a97f0..f7ee287bc 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -47,14 +47,14 @@ class RapidshareCom(Hoster): __name__ = "RapidshareCom" __type__ = "hoster" __pattern__ = r"http://[\w\.]*?rapidshare.com/(?:files/(?P<id>\d*?)/(?P<name>.+)|#!download\|(?:\d+)\|(?P<id_new>\d+)\|(?P<name_new>[^|]+))" - __version__ = "1.3" + __version__ = "1.31" __description__ = """Rapidshare.com Download Hoster""" __config__ = [["server", "Cogent;Deutsche Telekom;Level(3);Level(3) #2;GlobalCrossing;Level(3) #3;Teleglobe;GlobalCrossing #2;TeliaSonera #2;Teleglobe #2;TeliaSonera #3;TeliaSonera", "Preferred Server", "None"]] __author_name__ = ("spoob", "RaNaN", "mkaay") __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org", "mkaay@mkaay.de") def setup(self): - self.html = [None, None] + self.html = None self.no_download = True self.api_data = None self.multiDL = False @@ -190,7 +190,7 @@ class RapidshareCom(Hoster): def freeWait(self): """downloads html with the important informations """ - self.html[1] = self.load(self.pyfile.url,ref=False) + self.html = self.load("http://rapidshare.com/files/%s/%s" % (self.id, self.name),ref=False) sleep(1) |