diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-11-07 17:08:21 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-11-07 17:08:21 +0100 |
commit | 58c9c8d78417ec6ccac5b6b117ea540033a09574 (patch) | |
tree | 38b4cef702d015cae371dc661e214d701ca8c5c4 /module/plugins | |
parent | [DataportCz][SendspaceCom] Fix missing getInfo (diff) | |
download | pyload-58c9c8d78417ec6ccac5b6b117ea540033a09574.tar.xz |
Fix download link formatting in some plugins
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/Plugin.py | 4 | ||||
-rw-r--r-- | module/plugins/crypter/EmbeduploadCom.py | 2 | ||||
-rw-r--r-- | module/plugins/crypter/SafelinkingNet.py | 16 | ||||
-rw-r--r-- | module/plugins/hoster/GigapetaCom.py | 8 | ||||
-rw-r--r-- | module/plugins/hoster/QuickshareCz.py | 6 | ||||
-rw-r--r-- | module/plugins/hoster/StreamcloudEu.py | 99 | ||||
-rw-r--r-- | module/plugins/internal/SimpleHoster.py | 4 | ||||
-rw-r--r-- | module/plugins/internal/XFSHoster.py | 57 |
8 files changed, 53 insertions, 143 deletions
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index f80eb461b..426a406a9 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -458,7 +458,7 @@ class Plugin(Base): if self.pyfile.abort: raise Abort - url = url.strip().lower() + url = url.strip() if type(url) == unicode: # utf8 vs decode -> please use decode attribute in all future plugins url = str(url) #: encode('utf8') @@ -526,7 +526,7 @@ class Plugin(Base): if self.pyfile.abort: raise Abort - url = url.strip().lower() + url = url.strip() if self.core.debug: self.logDebug("Download url: " + url, *["%s=%s" % (key, val) for key, val in locals().iteritems() if key not in ("self", "url")]) diff --git a/module/plugins/crypter/EmbeduploadCom.py b/module/plugins/crypter/EmbeduploadCom.py index 7f06c99bd..1c372c1ca 100644 --- a/module/plugins/crypter/EmbeduploadCom.py +++ b/module/plugins/crypter/EmbeduploadCom.py @@ -53,7 +53,7 @@ class EmbeduploadCom(Crypter): for link in tmp_links: try: header = self.load(link, just_header=True) - if "location" in header: + if 'location' in header: new_links.append(header['location']) except BadHeader: pass diff --git a/module/plugins/crypter/SafelinkingNet.py b/module/plugins/crypter/SafelinkingNet.py index 1fbb6e137..9bb6c3229 100644 --- a/module/plugins/crypter/SafelinkingNet.py +++ b/module/plugins/crypter/SafelinkingNet.py @@ -14,7 +14,7 @@ from module.plugins.internal.CaptchaService import SolveMedia class SafelinkingNet(Crypter): __name__ = "SafelinkingNet" __type__ = "crypter" - __version__ = "0.1" + __version__ = "0.11" __pattern__ = r'https?://(?:www\.)?safelinking\.net/([pd])/\w+' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), @@ -30,20 +30,18 @@ class SafelinkingNet(Crypter): def decrypt(self, pyfile): url = pyfile.url + if re.match(self.__pattern__, url).group(1) == "d": - self.req.http.c.setopt(FOLLOWLOCATION, 0) - self.load(url) - m = re.search("^Location: (.+)$", self.req.http.header, re.M) - if m: - self.urls = [m.group(1)] + + header = self.load(url, just_header=True) + if 'location' in header: + self.urls = [header['location']] else: - self.fail(_("Couldn't find forwarded Link")) + self.error(_("Couldn't find forwarded Link")) else: postData = {"post-protect": "1"} - self.html = self.load(url) - if "link-password" in self.html: postData['link-password'] = self.getPassword() diff --git a/module/plugins/hoster/GigapetaCom.py b/module/plugins/hoster/GigapetaCom.py index 8e5d184c9..111493338 100644 --- a/module/plugins/hoster/GigapetaCom.py +++ b/module/plugins/hoster/GigapetaCom.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class GigapetaCom(SimpleHoster): __name__ = "GigapetaCom" __type__ = "hoster" - __version__ = "0.01" + __version__ = "0.02" __pattern__ = r'http://(?:www\.)?gigapeta\.com/dl/\w+' @@ -42,9 +42,9 @@ class GigapetaCom(SimpleHoster): "captcha": captcha, "download": "Download"}) - m = re.search(r"Location\s*:\s*(.*)", self.req.http.header, re.I) + m = re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I) if m: - download_url = m.group(1) + download_url = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 break elif "Entered figures don`t coincide with the picture" in self.html: self.invalidCaptcha() @@ -57,7 +57,7 @@ class GigapetaCom(SimpleHoster): def checkErrors(self): if "All threads for IP" in self.html: - self.logDebug("Your IP is already downloading a file - wait and retry") + self.logDebug("Your IP is already downloading a file") self.wait(5 * 60, True) self.retry() diff --git a/module/plugins/hoster/QuickshareCz.py b/module/plugins/hoster/QuickshareCz.py index 028f25102..e1e803e66 100644 --- a/module/plugins/hoster/QuickshareCz.py +++ b/module/plugins/hoster/QuickshareCz.py @@ -10,7 +10,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class QuickshareCz(SimpleHoster): __name__ = "QuickshareCz" __type__ = "hoster" - __version__ = "0.54" + __version__ = "0.55" __pattern__ = r'http://(?:[^/]*\.)?quickshare\.cz/stahnout-soubor/.*' @@ -65,10 +65,10 @@ class QuickshareCz(SimpleHoster): self.header = self.req.http.header self.req.http.c.setopt(FOLLOWLOCATION, 1) - m = re.search("Location\s*:\s*(.*)", self.header, re.I) + m = re.search(r'Location\s*:\s*(.+)', self.header, re.I) if m is None: self.fail(_("File not found")) - download_url = m.group(1) + download_url = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 self.logDebug("FREE URL2:" + download_url) # check errors diff --git a/module/plugins/hoster/StreamcloudEu.py b/module/plugins/hoster/StreamcloudEu.py index a6f34a34a..4f854a99d 100644 --- a/module/plugins/hoster/StreamcloudEu.py +++ b/module/plugins/hoster/StreamcloudEu.py @@ -2,16 +2,13 @@ import re -from time import sleep - -from module.network.HTTPRequest import HTTPRequest from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo class StreamcloudEu(XFSHoster): __name__ = "StreamcloudEu" __type__ = "hoster" - __version__ = "0.08" + __version__ = "0.09" __pattern__ = r'http://(?:www\.)?streamcloud\.eu/\w{12}' @@ -31,98 +28,4 @@ class StreamcloudEu(XFSHoster): self.resumeDownload = self.premium - def getDownloadLink(self): - m = re.search(self.LINK_PATTERN, self.html, re.S) - if m: - return m.group(1) - - for i in xrange(5): - self.logDebug("Getting download link: #%d" % i) - data = self.getPostParameters() - httpRequest = HTTPRequest(options=self.req.options) - httpRequest.cj = self.req.cj - sleep(10) - self.html = httpRequest.load(self.pyfile.url, post=data, referer=False, cookies=True, decode=True) - self.header = httpRequest.header - - m = re.search("Location\s*:\s*(.*)", self.header, re.I) - if m: - break - - m = re.search(self.LINK_PATTERN, self.html, re.S) - if m: - break - - else: - if self.errmsg and 'captcha' in self.errmsg: - self.fail(_("No valid captcha code entered")) - else: - self.fail(_("Download link not found")) - - return m.group(1) - - - def getPostParameters(self): - for i in xrange(3): - if not self.errmsg: - self.checkErrors() - - if hasattr(self, "FORM_PATTERN"): - action, inputs = self.parseHtmlForm(self.FORM_PATTERN) - else: - action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) - - if not inputs: - action, inputs = self.parseHtmlForm('F1') - if not inputs: - if self.errmsg: - self.retry() - else: - self.error(_("Form not found")) - - self.logDebug(inputs) - - if 'op' in inputs and inputs['op'] in ("download1", "download2", "download3"): - if "password" in inputs: - if self.passwords: - inputs['password'] = self.passwords.pop(0) - else: - self.fail(_("No or invalid passport")) - - if not self.premium: - m = re.search(self.WAIT_PATTERN, self.html) - if m: - wait_time = int(m.group(1)) - self.setWait(wait_time, False) - else: - wait_time = 0 - - self.captcha = self.handleCaptcha(inputs) - - if wait_time: - self.wait() - - self.errmsg = None - self.logDebug("getPostParameters {0}".format(i)) - return inputs - - else: - inputs['referer'] = self.pyfile.url - - if self.premium: - inputs['method_premium'] = "Premium Download" - if 'method_free' in inputs: - del inputs['method_free'] - else: - inputs['method_free'] = "Free Download" - if 'method_premium' in inputs: - del inputs['method_premium'] - - self.html = self.load(self.pyfile.url, post=inputs, ref=False) - self.errmsg = None - - else: - self.error(_("FORM: %s") % (inputs['op'] if 'op' in inputs else _("UNKNOWN"))) - - getInfo = create_getInfo(StreamcloudEu) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 87a348367..6a8a6ff6f 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -200,7 +200,7 @@ def timestamp(): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "0.52" + __version__ = "0.53" __pattern__ = r'^unmatchable$' @@ -318,7 +318,7 @@ class SimpleHoster(Hoster): if parseFileInfo(self, url, html)[2] is not 2: try: - return re.search(r"Location\s*:\s*(.+)", self.req.http.header, re.I).group(1).strip().lower() #@TODO: Remove .strip().lower() in 0.4.10 + return re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I).group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 except: pass diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py index 94c5d9595..ecf1f9f97 100644 --- a/module/plugins/internal/XFSHoster.py +++ b/module/plugins/internal/XFSHoster.py @@ -3,20 +3,20 @@ import re from random import random +from time import sleep from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME from module.plugins.hoster.UnrestrictLi import secondsToMidnight from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia -from module.plugins.internal.SimpleHoster import create_getInfo, replace_patterns, set_cookies, SimpleHoster -from module.plugins.Plugin import Fail +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.utils import html_unescape class XFSHoster(SimpleHoster): __name__ = "XFSHoster" __type__ = "hoster" - __version__ = "0.13" + __version__ = "0.14" __pattern__ = r'^unmatchable$' @@ -96,11 +96,14 @@ class XFSHoster(SimpleHoster): self.download(link, ref=True, cookies=True, disposition=True) - elif self.errmsg and "captcha" in self.errmsg: - self.error(_("No valid captcha code entered")) + elif self.errmsg: + if 'captcha' in self.errmsg: + self.fail(_("No valid captcha code entered")) + else: + self.fail(self.errmsg) else: - self.error(_("Download link not found")) + self.fail(_("Download link not found")) def handlePremium(self): @@ -111,8 +114,16 @@ class XFSHoster(SimpleHoster): for i in xrange(1, 5): self.logDebug("Getting download link: #%d" % i) + self.checkErrors() + + m = re.search(self.LINK_PATTERN, self.html, re.S) + if m: + break + data = self.getPostParameters() + # sleep(10) + self.req.http.c.setopt(FOLLOWLOCATION, 0) self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True) @@ -120,15 +131,19 @@ class XFSHoster(SimpleHoster): self.req.http.c.setopt(FOLLOWLOCATION, 1) - m = re.search(r"Location\s*:\s*(.+)", self.header, re.I) + m = re.search(r'Location\s*:\s*(.+)', self.header, re.I) if m: break m = re.search(self.LINK_PATTERN, self.html, re.S) if m: break + else: + return - return m.group(1) + self.errmsg = None + + return m.group(1).strip() #@TODO: Remove .strip() in 0.4.10 def handleOverriden(self): @@ -158,13 +173,13 @@ class XFSHoster(SimpleHoster): stmsg = inputs['st'] - if stmsg == "OK": + if stmsg == 'OK': self.html = self.load(action, post=inputs) - elif "Can not leech file" in stmsg: + elif 'Can not leech file' in stmsg: self.retry(20, 3 * 60, _("Can not leech file")) - elif "all Leech traffic today" in stmsg: + elif 'today' in stmsg: self.retry(wait_time=secondsToMidnight(gmt=2), reason=_("You've used all Leech traffic today")) else: @@ -175,19 +190,21 @@ class XFSHoster(SimpleHoster): if m is None: self.error(_("OVR_LINK_PATTERN not found")) - self.pyfile.url = m.group(1) - - header = self.load(self.pyfile.url, just_header=True, decode=True) + header = self.load(m.group(1).strip(), just_header=True, decode=True) #@TODO: Remove .strip() in 0.4.10 if 'location' in header: #: Direct download link self.download(header['location'], ref=True, cookies=True, disposition=True) else: - self.fail(_("No download link found")) + self.fail(_("Download link not found")) def checkErrors(self): m = re.search(self.ERROR_PATTERN, self.html) - if m: + + if m is None: + self.errmsg = None + else: self.errmsg = m.group(1) + self.logWarning(re.sub(r"<.*?>", " ", self.errmsg)) if 'wait' in self.errmsg: @@ -223,16 +240,12 @@ class XFSHoster(SimpleHoster): else: self.fail(self.errmsg) - else: - self.errmsg = None return self.errmsg def getPostParameters(self): for _i in xrange(3): - self.checkErrors() - if hasattr(self, "FORM_PATTERN"): action, inputs = self.parseHtmlForm(self.FORM_PATTERN) else: @@ -268,9 +281,7 @@ class XFSHoster(SimpleHoster): if wait_time: self.wait() - self.errmsg = None return inputs - else: inputs['referer'] = self.pyfile.url @@ -284,8 +295,6 @@ class XFSHoster(SimpleHoster): del inputs['method_premium'] self.html = self.load(self.pyfile.url, post=inputs, ref=True) - self.errmsg = None - else: self.error(_("FORM: %s") % (inputs['op'] if 'op' in inputs else _("UNKNOWN"))) |