diff options
Diffstat (limited to 'module/plugins/hoster/FilepostCom.py')
-rw-r--r-- | module/plugins/hoster/FilepostCom.py | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index 1f3de6717..d8c626ef2 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -4,14 +4,15 @@ import re import time from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FilepostCom(SimpleHoster): __name__ = "FilepostCom" __type__ = "hoster" - __version__ = "0.34" + __version__ = "0.35" + __status__ = "testing" __pattern__ = r'https?://(?:www\.)?(?:filepost\.com/files|fp\.io)/(?P<ID>[^/]+)' __config__ = [("use_premium", "bool", "Use premium account if available", True)] @@ -29,7 +30,7 @@ class FilepostCom(SimpleHoster): FLP_TOKEN_PATTERN = r'set_store_options\({token: \'(.+?)\'' - def handleFree(self, pyfile): + def handle_free(self, pyfile): m = re.search(self.FLP_TOKEN_PATTERN, self.html) if m is None: self.error(_("Token")) @@ -40,27 +41,27 @@ class FilepostCom(SimpleHoster): self.error(_("Captcha key")) captcha_key = m.group(1) - # Get wait time + #: Get wait time get_dict = {'SID': self.req.cj.getCookie('SID'), 'JsHttpRequest': str(int(time.time() * 10000)) + '-xml'} post_dict = {'action': 'set_download', 'token': flp_token, 'code': self.info['pattern']['ID']} - wait_time = int(self.getJsonResponse(get_dict, post_dict, 'wait_time')) + wait_time = int(self.get_json_response(get_dict, post_dict, 'wait_time')) if wait_time > 0: self.wait(wait_time) - post_dict = {"token": flp_token, "code": self.info['pattern']['ID'], "file_pass": ''} + post_dict = {'token': flp_token, 'code': self.info['pattern']['ID'], 'file_pass': ''} if 'var is_pass_exists = true;' in self.html: - # Solve password - password = self.getPassword() + #: Solve password + password = self.get_password() if password: - self.logInfo(_("Password protected link, trying ") + file_pass) + self.log_info(_("Password protected link, trying ") + file_pass) get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml' post_dict['file_pass'] = file_pass - self.link = self.getJsonResponse(get_dict, post_dict, 'link') + self.link = self.get_json_response(get_dict, post_dict, 'link') if not self.link: self.fail(_("Incorrect password")) @@ -68,7 +69,7 @@ class FilepostCom(SimpleHoster): self.fail(_("No password found")) else: - # Solve recaptcha + #: Solve recaptcha recaptcha = ReCaptcha(self) for i in xrange(5): @@ -76,32 +77,32 @@ class FilepostCom(SimpleHoster): if i: post_dict['recaptcha_response_field'], post_dict['recaptcha_challenge_field'] = recaptcha.challenge( captcha_key) - self.logDebug(u"RECAPTCHA: %s : %s : %s" % ( + self.log_debug(u"RECAPTCHA: %s : %s : %s" % ( captcha_key, post_dict['recaptcha_challenge_field'], post_dict['recaptcha_response_field'])) - self.link = self.getJsonResponse(get_dict, post_dict, 'link') + self.link = self.get_json_response(get_dict, post_dict, 'link') else: self.fail(_("Invalid captcha")) - def getJsonResponse(self, get_dict, post_dict, field): + def get_json_response(self, get_dict, post_dict, field): res = json_loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict)) - self.logDebug(res) + self.log_debug(res) if not 'js' in res: self.error(_("JSON %s 1") % field) - # i changed js_answer to res['js'] since js_answer is nowhere set. - # i don't know the JSON-HTTP specs in detail, but the previous author - # accessed res['js']['error'] as well as js_answer['error']. - # see the two lines commented out with "# ~?". + #: I changed js_answer to res['js'] since js_answer is nowhere set. + #: I don't know the JSON-HTTP specs in detail, but the previous author + #: Accessed res['js']['error'] as well as js_answer['error']. + #: See the two lines commented out with "# ~?". if 'error' in res['js']: - if res['js']['error'] == 'download_delay': + if res['js']['error'] == "download_delay": self.retry(wait_time=res['js']['params']['next_download']) - # ~? self.retry(wait_time=js_answer['params']['next_download']) + #: ~? self.retry(wait_time=js_answer['params']['next_download']) elif 'Wrong file password' in res['js']['error'] \ or 'You entered a wrong CAPTCHA code' in res['js']['error'] \ @@ -109,7 +110,7 @@ class FilepostCom(SimpleHoster): return None elif 'CAPTCHA' in res['js']['error']: - self.logDebug("Error response is unknown, but mentions CAPTCHA") + self.log_debug("Error response is unknown, but mentions CAPTCHA") return None else: |