summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/XFileSharingPro.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/XFileSharingPro.py')
-rw-r--r--module/plugins/hoster/XFileSharingPro.py67
1 files changed, 39 insertions, 28 deletions
diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharingPro.py
index 2103b0c20..9df843678 100644
--- a/module/plugins/hoster/XFileSharingPro.py
+++ b/module/plugins/hoster/XFileSharingPro.py
@@ -22,10 +22,10 @@ from urllib import unquote
from urlparse import urlparse
from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, PluginParseError
-from module.plugins.ReCaptcha import ReCaptcha
-from module.plugins.internal.CaptchaService import SolveMedia
+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...
@@ -74,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
@@ -82,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)
@@ -106,12 +107,12 @@ 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)
location = None
- found = re.search("Location\s*:\s*(.*)", self.header, re.I)
+ found = re.search(r"Location\s*:\s*(.*)", self.header, re.I)
if found and re.match(self.DIRECT_LINK_PATTERN, found.group(1)):
location = found.group(1).strip()
@@ -128,11 +129,11 @@ 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)
- found = re.search("Location\s*:\s*(.*)", self.header, re.I)
+ found = re.search(r"Location\s*:\s*(.*)", self.header, re.I)
if found:
break
@@ -149,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')
@@ -158,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
@@ -168,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:
@@ -182,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
@@ -192,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)
@@ -200,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(r'(\d+)\s*(hour|minute|second)?', self.errmsg)])
self.setWait(wait_time, True)
self.wait()
elif 'captcha' in self.errmsg:
@@ -229,10 +234,11 @@ class XFileSharingPro(SimpleHoster):
return self.errmsg
def getPostParameters(self):
- for i in range(3):
- if not self.errmsg: self.checkErrors()
+ for _ in range(3):
+ 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")})
@@ -264,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
@@ -274,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,8 +313,8 @@ class XFileSharingPro(SimpleHoster):
if found:
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]))])
+ numerals = re.findall(r'<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]))])
self.logDebug("CAPTCHA", inputs['code'], numerals)
return 3
else:
@@ -316,4 +326,5 @@ class XFileSharingPro(SimpleHoster):
return 4
return 0
+
getInfo = create_getInfo(XFileSharingPro)