summaryrefslogtreecommitdiffstats
path: root/pyload/plugin/internal/SimpleHoster.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-13 09:22:01 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-13 09:22:01 +0200
commit2432ade6c9bd7284a5bf0d760796638eef634be9 (patch)
tree877cfd29c6e5117a974377ead73cbbc150f6544d /pyload/plugin/internal/SimpleHoster.py
parentPrepare hook plugins to merging from stable (diff)
parent[LolabitsEs] Cleanup (diff)
downloadpyload-2432ade6c9bd7284a5bf0d760796638eef634be9.tar.xz
Merge branch 'stable' into 0.4.10
Conflicts: module/plugins/hooks/MultihostersComHook.py module/plugins/hooks/PutdriveComHook.py module/plugins/internal/CaptchaService.py pyload/plugin/account/OboomCom.py pyload/plugin/account/SmoozedCom.py pyload/plugin/addon/AntiVirus.py pyload/plugin/addon/ExternalScripts.py pyload/plugin/addon/ExtractArchive.py pyload/plugin/addon/RestartSlow.py pyload/plugin/crypter/CrockoCom.py pyload/plugin/crypter/DepositfilesCom.py pyload/plugin/crypter/FshareVn.py pyload/plugin/crypter/LinkdecrypterCom.py pyload/plugin/crypter/MegaRapidCz.py pyload/plugin/crypter/PastebinCom.py pyload/plugin/hoster/CatShareNet.py pyload/plugin/hoster/EdiskCz.py pyload/plugin/hoster/ExtabitCom.py pyload/plugin/hoster/GigapetaCom.py pyload/plugin/hoster/GooIm.py pyload/plugin/hoster/IfolderRu.py pyload/plugin/hoster/LuckyShareNet.py pyload/plugin/hoster/MegasharesCom.py pyload/plugin/hoster/MovReelCom.py pyload/plugin/hoster/NarodRu.py pyload/plugin/hoster/NowDownloadSx.py pyload/plugin/hoster/NowVideoSx.py pyload/plugin/hoster/QuickshareCz.py pyload/plugin/hoster/RemixshareCom.py pyload/plugin/hoster/RgHostNet.py pyload/plugin/hoster/SendspaceCom.py pyload/plugin/hoster/UlozTo.py pyload/plugin/hoster/UnibytesCom.py pyload/plugin/hoster/UploadingCom.py pyload/plugin/hoster/WrzucTo.py pyload/plugin/internal/MultiHook.py pyload/plugin/internal/SimpleHoster.py
Diffstat (limited to 'pyload/plugin/internal/SimpleHoster.py')
-rw-r--r--pyload/plugin/internal/SimpleHoster.py46
1 files changed, 22 insertions, 24 deletions
diff --git a/pyload/plugin/internal/SimpleHoster.py b/pyload/plugin/internal/SimpleHoster.py
index d83bbb625..56170a4fd 100644
--- a/pyload/plugin/internal/SimpleHoster.py
+++ b/pyload/plugin/internal/SimpleHoster.py
@@ -5,10 +5,8 @@ import mimetypes
import os
import re
import time
-
-from inspect import isclass
-from urllib import unquote
-from urlparse import urljoin, urlparse
+import urllib
+import urlparse
from pyload.datatype.File import statusMap as _statusMap
from pyload.network.CookieJar import CookieJar
@@ -29,7 +27,7 @@ def _error(self, reason, type):
type = "unknown"
msg = _("%s error") % type.strip().capitalize() if type else _("Error")
- msg += ": %s" % reason.strip() if reason else ""
+ msg += (": %s" % reason.strip()) if reason else ""
msg += _(" | Plugin may be out of date")
raise Fail(msg)
@@ -108,8 +106,8 @@ def parseFileInfo(plugin, url="", html=""):
info = plugin.getInfo(url, html)
res = info['name'], info['size'], info['status'], info['url']
else:
- url = unquote(url)
- url_p = urlparse(url)
+ url = urllib.unquote(url)
+ url_p = urlparse.urlparse(url)
res = ((url_p.path.split('/')[-1]
or url_p.query.split('=', 1)[::-1][0].split('&', 1)[0]
or url_p.netloc.split('.', 1)[0]),
@@ -185,10 +183,10 @@ def getFileURL(self, url, follow_location=None):
elif 'location' in header and header['location'].strip():
location = header['location']
- if not urlparse(location).scheme:
- url_p = urlparse(url)
+ if not urlparse.urlparse(location).scheme:
+ url_p = urlparse.urlparse(url)
baseurl = "%s://%s" % (url_p.scheme, url_p.netloc)
- location = urljoin(baseurl, location)
+ location = urlparse.urljoin(baseurl, location)
if 'code' in header and header['code'] == 302:
link = location
@@ -198,7 +196,7 @@ def getFileURL(self, url, follow_location=None):
continue
else:
- extension = os.path.splitext(urlparse(url).path.split('/')[-1])[-1]
+ extension = os.path.splitext(urlparse.urlparse(url).path.split('/')[-1])[-1]
if 'content-type' in header and header['content-type'].strip():
mimetype = header['content-type'].split(';')[0].strip()
@@ -246,7 +244,7 @@ def secondsToMidnight(gmt=0):
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.31"
+ __version__ = "1.37"
__pattern__ = r'^unmatchable$'
__config__ = [("use_premium", "bool", "Use premium account if available", True)]
@@ -307,20 +305,21 @@ class SimpleHoster(Hoster):
DIRECT_LINK = None #: Set to True to looking for direct link (as defined in handleDirect method), set to None to do it if self.account is True else False
MULTI_HOSTER = False #: Set to True to leech other hoster link (as defined in handleMulti method)
LOGIN_ACCOUNT = False #: Set to True to require account login
- DISPOSITION = True #: Work-around to `filename*=UTF-8` bug; remove in 0.4.10
+ DISPOSITION = True #: Set to True to use any content-disposition value in http header as file name
directLink = getFileURL # @TODO: Remove in 0.4.10
+
@classmethod
- def parseInfos(cls, urls): # @TODO: Built-in in 0.4.10 core, then remove from plugins
+ def parseInfos(cls, urls): #@TODO: Built-in in 0.4.10 core (remove from plugins)
for url in urls:
url = replace_patterns(url, cls.URL_REPLACEMENTS)
yield cls.getInfo(url)
@classmethod
def apiInfo(cls, url="", get={}, post={}):
- url = unquote(url)
- url_p = urlparse(url)
+ url = urllib.unquote(url)
+ url_p = urlparse.urlparse(url)
return {'name': (url_p.path.split('/')[-1]
or url_p.query.split('=', 1)[::-1][0].split('&', 1)[0]
or url_p.netloc.split('.', 1)[0]),
@@ -386,7 +385,7 @@ class SimpleHoster(Hoster):
info['status'] = 2
if 'N' in info['pattern']:
- info['name'] = replace_patterns(unquote(info['pattern']['N'].strip()),
+ info['name'] = replace_patterns(urllib.unquote(info['pattern']['N'].strip()),
cls.NAME_REPLACEMENTS)
if 'S' in info['pattern']:
@@ -478,7 +477,7 @@ class SimpleHoster(Hoster):
self.logDebug("Handled as free download")
self.handleFree(pyfile)
- self.downloadLink(self.link, self.DISPOSITION) #: Remove `self.DISPOSITION` in 0.4.10
+ self.downloadLink(self.link, self.DISPOSITION)
self.checkFile()
except Fail, e: # @TODO: Move to PluginThread in 0.4.10
@@ -492,10 +491,10 @@ class SimpleHoster(Hoster):
if link and isinstance(link, basestring):
self.correctCaptcha()
- if not urlparse(link).scheme:
- url_p = urlparse(self.pyfile.url)
+ if not urlparse.urlparse(link).scheme:
+ url_p = urlparse.urlparse(self.pyfile.url)
baseurl = "%s://%s" % (url_p.scheme, url_p.netloc)
- link = urljoin(baseurl, link)
+ link = urlparse.urljoin(baseurl, link)
self.download(link, ref=False, disposition=disposition)
@@ -577,8 +576,8 @@ class SimpleHoster(Hoster):
except Exception:
waitmsg = m.group(0).strip()
- wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1}[u.lower()] for v, u in
- re.findall(r'(\d+)\s*(hr|hour|min|sec)', waitmsg, re.I))
+ wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1, "": 1}[u.lower()] for v, u in
+ re.findall(r'(\d+)\s*(hr|hour|min|sec|)', waitmsg, re.I))
self.wait(wait_time, wait_time > 300)
self.info.pop('error', None)
@@ -652,7 +651,6 @@ class SimpleHoster(Hoster):
if link:
self.logInfo(_("Direct download link detected"))
-
self.link = link
else:
self.logDebug("Direct download link not found")