summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/FilepostCom.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/FilepostCom.py')
-rw-r--r--module/plugins/hoster/FilepostCom.py35
1 files changed, 13 insertions, 22 deletions
diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py
index 66c040770..2a9e3dc26 100644
--- a/module/plugins/hoster/FilepostCom.py
+++ b/module/plugins/hoster/FilepostCom.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
import re
-
-from time import time
+import time
from module.common.json_layer import json_loads
from module.plugins.internal.CaptchaService import ReCaptcha
@@ -12,16 +11,17 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class FilepostCom(SimpleHoster):
__name__ = "FilepostCom"
__type__ = "hoster"
- __version__ = "0.31"
+ __version__ = "0.33"
__pattern__ = r'https?://(?:www\.)?(?:filepost\.com/files|fp\.io)/(?P<ID>[^/]+)'
+ __config__ = [("use_premium", "bool", "Use premium account if available", True)]
__description__ = """Filepost.com hoster plugin"""
__license__ = "GPLv3"
__authors__ = [("zoidberg", "zoidberg@mujmail.cz")]
- INFO_PATTERN = r'<input type="text" id="url" value=\'<a href[^>]*>(?P<N>[^>]+?) - (?P<S>[\d.,]+) (?P<U>[\w^_]+)</a>\' class="inp_text"/>'
+ INFO_PATTERN = r'<input type="text" id="url" value=\'<a href.*?>(?P<N>[^>]+?) - (?P<S>[\d.,]+) (?P<U>[\w^_]+)</a>\' class="inp_text"/>'
OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. </div>|<div class="file_info file_info_deleted">'
PREMIUM_ONLY_PATTERN = r'members only. Please upgrade to premium|a premium membership is required to download this file'
@@ -29,7 +29,7 @@ class FilepostCom(SimpleHoster):
FLP_TOKEN_PATTERN = r'set_store_options\({token: \'(.+?)\''
- def handleFree(self):
+ def handleFree(self, pyfile):
m = re.search(self.FLP_TOKEN_PATTERN, self.html)
if m is None:
self.error(_("Token"))
@@ -41,7 +41,7 @@ class FilepostCom(SimpleHoster):
captcha_key = m.group(1)
# Get wait time
- get_dict = {'SID': self.req.cj.getCookie('SID'), 'JsHttpRequest': str(int(time() * 10000)) + '-xml'}
+ 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'))
@@ -57,7 +57,7 @@ class FilepostCom(SimpleHoster):
if password:
self.logInfo(_("Password protected link, trying ") + file_pass)
- get_dict['JsHttpRequest'] = str(int(time() * 10000)) + '-xml'
+ get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml'
post_dict['file_pass'] = file_pass
self.link = self.getJsonResponse(get_dict, post_dict, 'link')
@@ -72,27 +72,18 @@ class FilepostCom(SimpleHoster):
recaptcha = ReCaptcha(self)
for i in xrange(5):
- get_dict['JsHttpRequest'] = str(int(time() * 10000)) + '-xml'
+ get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml'
if i:
- post_dict['recaptcha_challenge_field'], post_dict['recaptcha_response_field'] = recaptcha.challenge(
+ post_dict['recaptcha_response_field'], post_dict['recaptcha_challenge_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 i:
- self.correctCaptcha()
- break
- elif i:
- self.invalidCaptcha()
+ self.link = self.getJsonResponse(get_dict, post_dict, 'link')
else:
self.fail(_("Invalid captcha"))
- # Download
- self.download(download_url)
-
def getJsonResponse(self, get_dict, post_dict, field):
res = json_loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict))
@@ -112,9 +103,9 @@ class FilepostCom(SimpleHoster):
self.retry(wait_time=res['js']['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']
- or 'CAPTCHA Code nicht korrekt' in res['js']['error']):
+ elif 'Wrong file password' in res['js']['error'] \
+ or 'You entered a wrong CAPTCHA code' in res['js']['error'] \
+ or 'CAPTCHA Code nicht korrekt' in res['js']['error']:
return None
elif 'CAPTCHA' in res['js']['error']: