summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/internal/SimpleHoster.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-26 22:19:01 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-26 22:19:01 +0100
commit4a7f6177152d3c59c92291aa76fd7a36a1c8b044 (patch)
tree9796b6c6f4be98dd29dba0d9f92cc44756da8b3a /pyload/plugins/internal/SimpleHoster.py
parentMerge branch 'stable' into 0.4.10 (diff)
parent[XFSHoster] Code improvements (diff)
downloadpyload-4a7f6177152d3c59c92291aa76fd7a36a1c8b044.tar.xz
Merge branch 'stable' into 0.4.10
Conflicts: module/PluginThread.py module/plugins/hoster/XFileSharingPro.py module/plugins/internal/CaptchaService.py pyload/api/__init__.py pyload/manager/AccountManager.py pyload/manager/AddonManager.py pyload/manager/CaptchaManager.py pyload/manager/PluginManager.py pyload/network/HTTPRequest.py pyload/network/XDCCRequest.py pyload/plugins/Plugin.py pyload/plugins/account/EasybytezCom.py pyload/plugins/crypter/C1neonCom.py pyload/plugins/crypter/CryptItCom.py pyload/plugins/crypter/DuploadOrg.py pyload/plugins/crypter/FilebeerInfo.py pyload/plugins/crypter/FilesonicCom.py pyload/plugins/crypter/FiredriveCom.py pyload/plugins/crypter/HotfileCom.py pyload/plugins/crypter/ILoadTo.py pyload/plugins/crypter/LofCc.py pyload/plugins/crypter/MBLinkInfo.py pyload/plugins/crypter/MegauploadCom.py pyload/plugins/crypter/Movie2kTo.py pyload/plugins/crypter/MultiuploadCom.py pyload/plugins/crypter/OronCom.py pyload/plugins/crypter/RSLayerCom.py pyload/plugins/crypter/SecuredIn.py pyload/plugins/crypter/SharingmatrixCom.py pyload/plugins/crypter/SpeedLoadOrg.py pyload/plugins/crypter/StealthTo.py pyload/plugins/crypter/TrailerzoneInfo.py pyload/plugins/crypter/WiiReloadedOrg.py pyload/plugins/crypter/WuploadCom.py pyload/plugins/internal/Account.py pyload/plugins/internal/Addon.py pyload/plugins/internal/BasePlugin.py pyload/plugins/internal/Container.py pyload/plugins/internal/Crypter.py pyload/plugins/internal/DeadCrypter.py pyload/plugins/internal/DeadHoster.py pyload/plugins/internal/Hoster.py pyload/plugins/internal/SimpleCrypter.py pyload/utils/__init__.py
Diffstat (limited to 'pyload/plugins/internal/SimpleHoster.py')
-rw-r--r--pyload/plugins/internal/SimpleHoster.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/pyload/plugins/internal/SimpleHoster.py b/pyload/plugins/internal/SimpleHoster.py
index 4e9db7f73..a33e48bdf 100644
--- a/pyload/plugins/internal/SimpleHoster.py
+++ b/pyload/plugins/internal/SimpleHoster.py
@@ -37,12 +37,13 @@ def parseHtmlTagAttrValue(attr_name, tag):
return m.group(2) if m else None
-def parseHtmlForm(attr_str, html, input_names=None):
- for form in re.finditer(r"(?P<tag><form[^>]*%s[^>]*>)(?P<content>.*?)</?(form|body|html)[^>]*>" % attr_str,
+def parseHtmlForm(attr_str, html, input_names={}):
+ for form in re.finditer(r"(?P<TAG><form[^>]*%s[^>]*>)(?P<CONTENT>.*?)</?(form|body|html)[^>]*>" % attr_str,
html, re.S | re.I):
inputs = {}
- action = parseHtmlTagAttrValue("action", form.group('tag'))
- for inputtag in re.finditer(r'(<(input|textarea)[^>]*>)([^<]*(?=</\2)|)', form.group('content'), re.S | re.I):
+ action = parseHtmlTagAttrValue("action", form.group('TAG'))
+
+ for inputtag in re.finditer(r'(<(input|textarea)[^>]*>)([^<]*(?=</\2)|)', form.group('CONTENT'), re.S | re.I):
name = parseHtmlTagAttrValue("name", inputtag.group(1))
if name:
value = parseHtmlTagAttrValue("value", inputtag.group(1))
@@ -51,7 +52,7 @@ def parseHtmlForm(attr_str, html, input_names=None):
else:
inputs[name] = value
- if isinstance(input_names, dict):
+ if input_names:
# check input attributes
for key, val in input_names.iteritems():
if key in inputs:
@@ -80,6 +81,7 @@ def parseFileInfo(plugin, url="", html=""):
#@TODO: Remove in 0.4.10
+#@NOTE: Every plugin must have own parseInfo classmethod to work with 0.4.10
def create_getInfo(plugin):
return lambda urls: [(info['name'], info['size'], info['status'], info['url']) for info in plugin.parseInfo(urls)]
@@ -90,23 +92,21 @@ def timestamp():
#@TODO: Move to hoster class in 0.4.10
def _getDirectLink(self, url):
- self.req.http.c.setopt(FOLLOWLOCATION, 0)
+ header = self.load(url, ref=True, just_header=True, decode=True)
- html = self.load(url, ref=True, decode=True)
+ if not 'location' in header or not header['location']:
+ return ""
- self.req.http.c.setopt(FOLLOWLOCATION, 1)
+ if header['code'] != 302 or 'content-type' not in header or header['content-type'] != "text/plain":
+ return ""
- if self.getInfo(url, html)['status'] is not 2:
- try:
- 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
+ return header['location']
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "0.60"
+ __version__ = "0.62"
__pattern__ = r'^unmatchable$'
@@ -177,7 +177,7 @@ class SimpleHoster(Hoster):
@classmethod
def getInfo(cls, url="", html=""):
- info = {'name': url or _("Unknown"), 'size': 0, 'status': 3, 'url': url}
+ info = {'name': urlparse(url).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3, 'url': url or ""}
if not html:
if url:
@@ -391,14 +391,15 @@ class SimpleHoster(Hoster):
def handleDirect(self):
- self.link = _getDirectLink(self, self.pyfile.url)
+ link = _getDirectLink(self, self.pyfile.url)
- if self.link:
+ if link:
self.logInfo(_("Direct download link detected"))
+ self.link = link
+
self._updateInfo(self.getInfo(self.pyfile.url))
self.checkNameSize()
-
else:
self.logDebug(_("Direct download link not found"))
@@ -452,7 +453,7 @@ class SimpleHoster(Hoster):
self.retry(max_tries=max_tries, reason=_("Download limit reached"))
- def parseHtmlForm(self, attr_str='', input_names=None):
+ def parseHtmlForm(self, attr_str="", input_names={}):
return parseHtmlForm(attr_str, self.html, input_names)