diff options
author | Stefano <l.stickell@yahoo.it> | 2013-07-22 20:50:34 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2013-07-22 20:50:34 +0200 |
commit | 2edeee0532ec6d6b4b26fd045a5971f67ca455da (patch) | |
tree | 8d656afc9c18f7dba7c05d6635f898fdf58d66d6 /module/plugins/hoster/BayfilesCom.py | |
parent | Fixed PEP 8 violations in Crypters (diff) | |
download | pyload-2edeee0532ec6d6b4b26fd045a5971f67ca455da.tar.xz |
Fixed PEP 8 violations in Hosters
Diffstat (limited to 'module/plugins/hoster/BayfilesCom.py')
-rw-r--r-- | module/plugins/hoster/BayfilesCom.py | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/module/plugins/hoster/BayfilesCom.py b/module/plugins/hoster/BayfilesCom.py index 8473468ba..bb1e78bb3 100644 --- a/module/plugins/hoster/BayfilesCom.py +++ b/module/plugins/hoster/BayfilesCom.py @@ -17,9 +17,11 @@ """ import re +from time import time + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.common.json_layer import json_loads -from time import time + class BayfilesCom(SimpleHoster): __name__ = "BayfilesCom" @@ -32,50 +34,53 @@ class BayfilesCom(SimpleHoster): FILE_INFO_PATTERN = r'<p title="(?P<N>[^"]+)">[^<]*<strong>(?P<S>[0-9., ]+)(?P<U>[kKMG])i?B</strong></p>' FILE_OFFLINE_PATTERN = r'(<p>The requested file could not be found.</p>|<title>404 Not Found</title>)' - + WAIT_PATTERN = r'>Your IP [0-9.]* has recently downloaded a file\. Upgrade to premium or wait (\d+) minutes\.<' VARS_PATTERN = r'var vfid = (\d+);\s*var delay = (\d+);' LINK_PATTERN = r"javascript:window.location.href = '([^']+)';" PREMIUM_LINK_PATTERN = r'(?:<a class="highlighted-btn" href="|(?=http://s\d+\.baycdn\.com/dl/))(.*?)"' - + def handleFree(self): found = re.search(self.WAIT_PATTERN, self.html) if found: self.setWait(int(found.group(1)) * 60) self.wait() self.retry() - + # Get download token found = re.search(self.VARS_PATTERN, self.html) - if not found: self.parseError('VARS') + if not found: + self.parseError('VARS') vfid, delay = found.groups() - - response = json_loads(self.load('http://bayfiles.com/ajax_download', get = { + + response = json_loads(self.load('http://bayfiles.com/ajax_download', get={ "_": time() * 1000, "action": "startTimer", - "vfid": vfid}, decode = True)) - - if not "token" in response or not response['token']: - self.fail('No token') - + "vfid": vfid}, decode=True)) + + if not "token" in response or not response['token']: + self.fail('No token') + self.setWait(int(delay)) self.wait() - - self.html = self.load('http://bayfiles.com/ajax_download', get = { + + self.html = self.load('http://bayfiles.com/ajax_download', get={ "token": response['token'], "action": "getLink", "vfid": vfid}) # Get final link and download found = re.search(self.LINK_PATTERN, self.html) - if not found: self.parseError("Free link") + if not found: + self.parseError("Free link") self.startDownload(found.group(1)) - - def handlePremium(self): + + def handlePremium(self): found = re.search(self.PREMIUM_LINK_PATTERN, self.html) - if not found: self.parseError("Premium link") + if not found: + self.parseError("Premium link") self.startDownload(found.group(1)) - + def startDownload(self, url): self.logDebug("%s URL: %s" % ("Premium" if self.premium else "Free", url)) self.download(url) @@ -83,10 +88,11 @@ class BayfilesCom(SimpleHoster): check = self.checkDownload({ "waitforfreeslots": re.compile(r"<title>BayFiles</title>"), "notfound": re.compile(r"<title>404 Not Found</title>") - }) + }) if check == "waitforfreeslots": self.retry(60, 300, "Wait for free slot") elif check == "notfound": self.retry(60, 300, "404 Not found") - + + getInfo = create_getInfo(BayfilesCom) |