diff options
Diffstat (limited to 'module/plugins/hoster/FilepostCom.py')
-rw-r--r-- | module/plugins/hoster/FilepostCom.py | 91 |
1 files changed, 51 insertions, 40 deletions
diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index 8e9df3f17..0c3cb925b 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -22,10 +22,12 @@ """ import re +from time import time + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.plugins.internal.CaptchaService import ReCaptcha from module.common.json_layer import json_loads -from time import time + class FilepostCom(SimpleHoster): __name__ = "FilepostCom" @@ -47,65 +49,73 @@ class FilepostCom(SimpleHoster): file_id = re.search(self.__pattern__, self.pyfile.url).group(1) found = re.search(self.FLP_TOKEN_PATTERN, self.html) - if not found: self.parseError("Token") + if not found: + self.parseError("Token") flp_token = found.group(1) found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html) - if not found: self.parseError("Captcha key") + if not found: + self.parseError("Captcha key") captcha_key = found.group(1) # Get wait time - get_dict = {'SID' : self.req.cj.getCookie('SID'), 'JsHttpRequest' : str(int(time()*10000)) + '-xml'} - post_dict = {'action' : 'set_download', 'token' : flp_token, 'code' : file_id} - wait_time = int(self.getJsonResponse(get_dict, post_dict, 'wait_time')) + get_dict = {'SID': self.req.cj.getCookie('SID'), 'JsHttpRequest': str(int(time() * 10000)) + '-xml'} + post_dict = {'action': 'set_download', 'token': flp_token, 'code': file_id} + wait_time = int(self.getJsonResponse(get_dict, post_dict, 'wait_time')) if wait_time > 0: self.setWait(wait_time) - self.wait() - - post_dict = {"token" : flp_token, "code" : file_id, "file_pass" : ''} - + self.wait() + + post_dict = {"token": flp_token, "code": file_id, "file_pass": ''} + if 'var is_pass_exists = true;' in self.html: # Solve password for file_pass in self.getPassword().splitlines(): - get_dict['JsHttpRequest'] = str(int(time()*10000)) + '-xml' + get_dict['JsHttpRequest'] = str(int(time() * 10000)) + '-xml' post_dict['file_pass'] = file_pass - self.logInfo("Password protected link, trying " + file_pass) - - download_url = self.getJsonResponse(get_dict, post_dict, 'link') - if download_url: + self.logInfo("Password protected link, trying " + file_pass) + + download_url = self.getJsonResponse(get_dict, post_dict, 'link') + if download_url: break - - else: self.fail("No or incorrect password") - + + else: + self.fail("No or incorrect password") + else: # Solve recaptcha recaptcha = ReCaptcha(self) - + for pokus in range(5): - get_dict['JsHttpRequest'] = str(int(time()*10000)) + '-xml' + get_dict['JsHttpRequest'] = str(int(time() * 10000)) + '-xml' if pokus: - post_dict["recaptcha_challenge_field"], post_dict["recaptcha_response_field"] = recaptcha.challenge(captcha_key) - self.logDebug(u"RECAPTCHA: %s : %s : %s" % (captcha_key, post_dict["recaptcha_challenge_field"], post_dict["recaptcha_response_field"])) - + post_dict["recaptcha_challenge_field"], post_dict["recaptcha_response_field"] = recaptcha.challenge( + captcha_key) + self.logDebug(u"RECAPTCHA: %s : %s : %s" % ( + captcha_key, post_dict["recaptcha_challenge_field"], post_dict["recaptcha_response_field"])) + download_url = self.getJsonResponse(get_dict, post_dict, 'link') if download_url: - if pokus: self.correctCaptcha() + if pokus: + self.correctCaptcha() break elif pokus: self.invalidCaptcha() - - else: self.fail("Invalid captcha") - + + else: + self.fail("Invalid captcha") + # Download - self.download(download_url) - - def getJsonResponse(self, get_dict, post_dict, field): - json_response = json_loads(self.load('https://filepost.com/files/get/', get = get_dict, post = post_dict)) + self.download(download_url) + + def getJsonResponse(self, get_dict, post_dict, field): + json_response = json_loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict)) self.logDebug(json_response) - - if not 'js' in json_response: self.parseError('JSON %s 1' % field) - + + if not 'js' in json_response: + self.parseError('JSON %s 1' % field) + # i changed js_answer to json_response['js'] since js_answer is nowhere set. # i don't know the JSON-HTTP specs in detail, but the previous author # accessed json_response['js']['error'] as well as js_answer['error']. @@ -115,9 +125,9 @@ class FilepostCom(SimpleHoster): self.retry(json_response['js']['params']['next_download']) # ~? self.retry(js_answer['params']['next_download']) elif 'Wrong file password' in json_response['js']['error']: - return None + return None elif 'You entered a wrong CAPTCHA code' in json_response['js']['error']: - return None + return None elif 'CAPTCHA Code nicht korrekt' in json_response['js']['error']: return None elif 'CAPTCHA' in json_response['js']['error']: @@ -126,10 +136,11 @@ class FilepostCom(SimpleHoster): else: self.fail(json_response['js']['error']) # ~? self.fail(js_answer['error']) - - if not 'answer' in json_response['js'] or not field in json_response['js']['answer']: + + if not 'answer' in json_response['js'] or not field in json_response['js']['answer']: self.parseError('JSON %s 2' % field) - + return json_response['js']['answer'][field] - + + getInfo = create_getInfo(FilepostCom) |