diff options
author | Stefano <l.stickell@yahoo.it> | 2013-07-22 20:50:34 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2013-07-22 21:20:06 +0200 |
commit | aaaf5a4cddec894aacd7400c59a9f2f5e710362f (patch) | |
tree | 9d9e89aff86598b3ffcc86117abd554b193e28b5 /pyload/plugins/hoster/XFileSharingPro.py | |
parent | implemented media type filter (diff) | |
download | pyload-aaaf5a4cddec894aacd7400c59a9f2f5e710362f.tar.xz |
Fixed PEP 8 violations in Hosters
(cherry picked from commit 2edeee0532ec6d6b4b26fd045a5971f67ca455da)
Conflicts:
pyload/plugins/hoster/BasePlugin.py
pyload/plugins/hoster/MultishareCz.py
pyload/plugins/hoster/NetloadIn.py
pyload/plugins/hoster/PremiumizeMe.py
pyload/plugins/hoster/RapidshareCom.py
Diffstat (limited to 'pyload/plugins/hoster/XFileSharingPro.py')
-rw-r--r-- | pyload/plugins/hoster/XFileSharingPro.py | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/pyload/plugins/hoster/XFileSharingPro.py b/pyload/plugins/hoster/XFileSharingPro.py index d5a32dd16..8885ba9ca 100644 --- a/pyload/plugins/hoster/XFileSharingPro.py +++ b/pyload/plugins/hoster/XFileSharingPro.py @@ -25,6 +25,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, P from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia from module.utils import html_unescape + class XFileSharingPro(SimpleHoster): """ Common base for XFileSharingPro hosters like EasybytezCom, CramitIn, FiledinoCom... @@ -73,7 +74,7 @@ class XFileSharingPro(SimpleHoster): self.fail("Only premium users can download from other hosters with %s" % self.HOSTER_NAME) else: try: - self.html = self.load(pyfile.url, cookies = False, decode = True) + self.html = self.load(pyfile.url, cookies=False, decode=True) self.file_info = self.getFileInfo() except PluginParseError: self.file_info = None @@ -81,7 +82,8 @@ class XFileSharingPro(SimpleHoster): self.location = self.getDirectDownloadLink() if not self.file_info: - pyfile.name = html_unescape(unquote(urlparse(self.location if self.location else pyfile.url).path.split("/")[-1])) + pyfile.name = html_unescape(unquote(urlparse( + self.location if self.location else pyfile.url).path.split("/")[-1])) if self.location: self.startDownload(self.location) @@ -105,7 +107,7 @@ class XFileSharingPro(SimpleHoster): self.req.http.lastURL = self.pyfile.url self.req.http.c.setopt(FOLLOWLOCATION, 0) - self.html = self.load(self.pyfile.url, cookies = True, decode = True) + self.html = self.load(self.pyfile.url, cookies=True, decode=True) self.header = self.req.http.header self.req.http.c.setopt(FOLLOWLOCATION, 1) @@ -127,7 +129,7 @@ class XFileSharingPro(SimpleHoster): data = self.getPostParameters() self.req.http.c.setopt(FOLLOWLOCATION, 0) - self.html = self.load(self.pyfile.url, post = data, ref = True, decode = True) + self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True) self.header = self.req.http.header self.req.http.c.setopt(FOLLOWLOCATION, 1) @@ -148,7 +150,7 @@ class XFileSharingPro(SimpleHoster): return found.group(1) def handlePremium(self): - self.html = self.load(self.pyfile.url, post = self.getPostParameters()) + self.html = self.load(self.pyfile.url, post=self.getPostParameters()) found = re.search(self.DIRECT_LINK_PATTERN, self.html) if not found: self.parseError('DIRECT LINK') @@ -157,8 +159,8 @@ class XFileSharingPro(SimpleHoster): def handleOverriden(self): #only tested with easybytez.com self.html = self.load("http://www.%s/" % self.HOSTER_NAME) - action, inputs = self.parseHtmlForm('') - upload_id = "%012d" % int(random()*10**12) + action, inputs = self.parseHtmlForm('') + upload_id = "%012d" % int(random() * 10 ** 12) action += upload_id + "&js_on=1&utype=prem&upload_type=url" inputs['tos'] = '1' inputs['url_mass'] = self.pyfile.url @@ -167,13 +169,14 @@ class XFileSharingPro(SimpleHoster): self.logDebug(self.HOSTER_NAME, action, inputs) #wait for file to upload to easybytez.com self.req.http.c.setopt(LOW_SPEED_TIME, 600) - self.html = self.load(action, post = inputs) + self.html = self.load(action, post=inputs) action, inputs = self.parseHtmlForm('F1') - if not inputs: self.parseError('TEXTAREA') + if not inputs: + self.parseError('TEXTAREA') self.logDebug(self.HOSTER_NAME, inputs) if inputs['st'] == 'OK': - self.html = self.load(action, post = inputs) + self.html = self.load(action, post=inputs) elif inputs['st'] == 'Can not leech file': self.retry(max_tries=20, wait_time=180, reason=inputs['st']) else: @@ -181,7 +184,8 @@ class XFileSharingPro(SimpleHoster): #get easybytez.com link for uploaded file found = re.search(self.OVR_DOWNLOAD_LINK_PATTERN, self.html) - if not found: self.parseError('DIRECT LINK (OVR)') + if not found: + self.parseError('DIRECT LINK (OVR)') self.pyfile.url = found.group(1) header = self.load(self.pyfile.url, just_header=True) if 'location' in header: # Direct link @@ -191,7 +195,8 @@ class XFileSharingPro(SimpleHoster): def startDownload(self, link): link = link.strip() - if self.captcha: self.correctCaptcha() + if self.captcha: + self.correctCaptcha() self.logDebug('DIRECT LINK: %s' % link) self.download(link, disposition=True) @@ -199,10 +204,11 @@ class XFileSharingPro(SimpleHoster): found = re.search(self.ERROR_PATTERN, self.html) if found: self.errmsg = found.group(1) - self.logWarning(re.sub(r"<.*?>"," ",self.errmsg)) + self.logWarning(re.sub(r"<.*?>", " ", self.errmsg)) if 'wait' in self.errmsg: - wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in re.findall('(\d+)\s*(hour|minute|second)?', self.errmsg)]) + wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in + re.findall('(\d+)\s*(hour|minute|second)?', self.errmsg)]) self.setWait(wait_time, True) self.wait() elif 'captcha' in self.errmsg: @@ -229,9 +235,10 @@ class XFileSharingPro(SimpleHoster): def getPostParameters(self): for i in range(3): - if not self.errmsg: self.checkErrors() + if not self.errmsg: + self.checkErrors() - if hasattr(self,"FORM_PATTERN"): + if hasattr(self, "FORM_PATTERN"): action, inputs = self.parseHtmlForm(self.FORM_PATTERN) else: action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) @@ -263,7 +270,8 @@ class XFileSharingPro(SimpleHoster): self.captcha = self.handleCaptcha(inputs) - if wait_time: self.wait() + if wait_time: + self.wait() self.errmsg = None return inputs @@ -273,15 +281,18 @@ class XFileSharingPro(SimpleHoster): if self.premium: inputs['method_premium'] = "Premium Download" - if 'method_free' in inputs: del inputs['method_free'] + if 'method_free' in inputs: + del inputs['method_free'] else: inputs['method_free'] = "Free Download" - if 'method_premium' in inputs: del inputs['method_premium'] + if 'method_premium' in inputs: + del inputs['method_premium'] - self.html = self.load(self.pyfile.url, post = inputs, ref = True) + self.html = self.load(self.pyfile.url, post=inputs, ref=True) self.errmsg = None - else: self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) + else: + self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) def handleCaptcha(self, inputs): found = re.search(self.RECAPTCHA_URL_PATTERN, self.html) @@ -303,7 +314,7 @@ class XFileSharingPro(SimpleHoster): captcha_div = found.group(1) self.logDebug(captcha_div) numerals = re.findall('<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', html_unescape(captcha_div)) - inputs['code'] = "".join([a[1] for a in sorted(numerals, key = lambda num: int(num[0]))]) + inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) self.logDebug("CAPTCHA", inputs['code'], numerals) return 3 else: @@ -315,4 +326,5 @@ class XFileSharingPro(SimpleHoster): return 4 return 0 + getInfo = create_getInfo(XFileSharingPro) |