summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-07 17:08:21 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-07 17:08:21 +0100
commit58c9c8d78417ec6ccac5b6b117ea540033a09574 (patch)
tree38b4cef702d015cae371dc661e214d701ca8c5c4 /module/plugins/internal
parent[DataportCz][SendspaceCom] Fix missing getInfo (diff)
downloadpyload-58c9c8d78417ec6ccac5b6b117ea540033a09574.tar.xz
Fix download link formatting in some plugins
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/SimpleHoster.py4
-rw-r--r--module/plugins/internal/XFSHoster.py57
2 files changed, 35 insertions, 26 deletions
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 87a348367..6a8a6ff6f 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -200,7 +200,7 @@ def timestamp():
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "0.52"
+ __version__ = "0.53"
__pattern__ = r'^unmatchable$'
@@ -318,7 +318,7 @@ class SimpleHoster(Hoster):
if parseFileInfo(self, url, html)[2] is not 2:
try:
- return re.search(r"Location\s*:\s*(.+)", self.req.http.header, re.I).group(1).strip().lower() #@TODO: Remove .strip().lower() in 0.4.10
+ return re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I).group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10
except:
pass
diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py
index 94c5d9595..ecf1f9f97 100644
--- a/module/plugins/internal/XFSHoster.py
+++ b/module/plugins/internal/XFSHoster.py
@@ -3,20 +3,20 @@
import re
from random import random
+from time import sleep
from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME
from module.plugins.hoster.UnrestrictLi import secondsToMidnight
from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia
-from module.plugins.internal.SimpleHoster import create_getInfo, replace_patterns, set_cookies, SimpleHoster
-from module.plugins.Plugin import Fail
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
from module.utils import html_unescape
class XFSHoster(SimpleHoster):
__name__ = "XFSHoster"
__type__ = "hoster"
- __version__ = "0.13"
+ __version__ = "0.14"
__pattern__ = r'^unmatchable$'
@@ -96,11 +96,14 @@ class XFSHoster(SimpleHoster):
self.download(link, ref=True, cookies=True, disposition=True)
- elif self.errmsg and "captcha" in self.errmsg:
- self.error(_("No valid captcha code entered"))
+ elif self.errmsg:
+ if 'captcha' in self.errmsg:
+ self.fail(_("No valid captcha code entered"))
+ else:
+ self.fail(self.errmsg)
else:
- self.error(_("Download link not found"))
+ self.fail(_("Download link not found"))
def handlePremium(self):
@@ -111,8 +114,16 @@ class XFSHoster(SimpleHoster):
for i in xrange(1, 5):
self.logDebug("Getting download link: #%d" % i)
+ self.checkErrors()
+
+ m = re.search(self.LINK_PATTERN, self.html, re.S)
+ if m:
+ break
+
data = self.getPostParameters()
+ # sleep(10)
+
self.req.http.c.setopt(FOLLOWLOCATION, 0)
self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True)
@@ -120,15 +131,19 @@ class XFSHoster(SimpleHoster):
self.req.http.c.setopt(FOLLOWLOCATION, 1)
- m = re.search(r"Location\s*:\s*(.+)", self.header, re.I)
+ m = re.search(r'Location\s*:\s*(.+)', self.header, re.I)
if m:
break
m = re.search(self.LINK_PATTERN, self.html, re.S)
if m:
break
+ else:
+ return
- return m.group(1)
+ self.errmsg = None
+
+ return m.group(1).strip() #@TODO: Remove .strip() in 0.4.10
def handleOverriden(self):
@@ -158,13 +173,13 @@ class XFSHoster(SimpleHoster):
stmsg = inputs['st']
- if stmsg == "OK":
+ if stmsg == 'OK':
self.html = self.load(action, post=inputs)
- elif "Can not leech file" in stmsg:
+ elif 'Can not leech file' in stmsg:
self.retry(20, 3 * 60, _("Can not leech file"))
- elif "all Leech traffic today" in stmsg:
+ elif 'today' in stmsg:
self.retry(wait_time=secondsToMidnight(gmt=2), reason=_("You've used all Leech traffic today"))
else:
@@ -175,19 +190,21 @@ class XFSHoster(SimpleHoster):
if m is None:
self.error(_("OVR_LINK_PATTERN not found"))
- self.pyfile.url = m.group(1)
-
- header = self.load(self.pyfile.url, just_header=True, decode=True)
+ header = self.load(m.group(1).strip(), just_header=True, decode=True) #@TODO: Remove .strip() in 0.4.10
if 'location' in header: #: Direct download link
self.download(header['location'], ref=True, cookies=True, disposition=True)
else:
- self.fail(_("No download link found"))
+ self.fail(_("Download link not found"))
def checkErrors(self):
m = re.search(self.ERROR_PATTERN, self.html)
- if m:
+
+ if m is None:
+ self.errmsg = None
+ else:
self.errmsg = m.group(1)
+
self.logWarning(re.sub(r"<.*?>", " ", self.errmsg))
if 'wait' in self.errmsg:
@@ -223,16 +240,12 @@ class XFSHoster(SimpleHoster):
else:
self.fail(self.errmsg)
- else:
- self.errmsg = None
return self.errmsg
def getPostParameters(self):
for _i in xrange(3):
- self.checkErrors()
-
if hasattr(self, "FORM_PATTERN"):
action, inputs = self.parseHtmlForm(self.FORM_PATTERN)
else:
@@ -268,9 +281,7 @@ class XFSHoster(SimpleHoster):
if wait_time:
self.wait()
- self.errmsg = None
return inputs
-
else:
inputs['referer'] = self.pyfile.url
@@ -284,8 +295,6 @@ class XFSHoster(SimpleHoster):
del inputs['method_premium']
self.html = self.load(self.pyfile.url, post=inputs, ref=True)
- self.errmsg = None
-
else:
self.error(_("FORM: %s") % (inputs['op'] if 'op' in inputs else _("UNKNOWN")))