summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-07-17 03:03:26 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-07-17 03:03:26 +0200
commitd2e2b127651a5a44b56337eb6d9ca246c97a208a (patch)
tree46f34e2102fd44ed2f719727eb07a445e7baa77d /module/plugins/internal
parentNo camelCase style anymore (diff)
downloadpyload-d2e2b127651a5a44b56337eb6d9ca246c97a208a.tar.xz
Spare fixes and code cosmetics
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/Account.py25
-rw-r--r--module/plugins/internal/Hoster.py16
-rw-r--r--module/plugins/internal/MultiHook.py2
-rw-r--r--module/plugins/internal/MultiHoster.py8
-rw-r--r--module/plugins/internal/Plugin.py4
-rw-r--r--module/plugins/internal/SevenZip.py2
-rw-r--r--module/plugins/internal/SimpleCrypter.py8
-rw-r--r--module/plugins/internal/SimpleHoster.py11
-rw-r--r--module/plugins/internal/UnRar.py4
-rw-r--r--module/plugins/internal/XFSAccount.py4
-rw-r--r--module/plugins/internal/XFSHoster.py4
11 files changed, 48 insertions, 40 deletions
diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py
index 9e0efaee6..8fd16bba9 100644
--- a/module/plugins/internal/Account.py
+++ b/module/plugins/internal/Account.py
@@ -60,9 +60,9 @@ class Account(Plugin):
#: set timestamp for login
self.timestamps[user] = time.time()
- req = self.get_account_request(user)
+ self.req = self.get_account_request(user)
try:
- self.login(user, data, req)
+ self.login(user, data, self.req)
except WrongPassword:
self.log_warning(
@@ -82,8 +82,10 @@ class Account(Plugin):
success = True
finally:
- if req:
- req.close()
+ if hasattr(self, "req"):
+ if self.req:
+ self.req.close()
+ del self.req
return success
@@ -158,26 +160,31 @@ class Account(Plugin):
if force or name not in self.infos:
self.log_debug("Get Account Info for %s" % name)
- req = self.get_account_request(name)
+ self.req = self.get_account_request(name)
try:
- infos = self.load_account_info(name, req)
+ infos = self.load_account_info(name, self.req)
if not type(infos) == dict:
raise Exception("Wrong return format")
+
except Exception, e:
- infos = super(self.__class__, self).load_account_info(name, req)
+ infos = super(self.__class__, self).load_account_info(name, self.req)
infos['error'] = str(e)
if self.core.debug:
traceback.print_exc()
- if req:
- req.close()
+ finally:
+ if hasattr(self, "req"):
+ if self.req:
+ self.req.close()
+ del self.req
self.log_debug("Account Info: %s" % infos)
infos['timestamp'] = time.time()
self.infos[name] = infos
+
elif "timestamp" in self.infos[name] and self.infos[name]['timestamp'] + self.info_threshold * 60 < time.time():
self.log_debug("Reached timeout for account data")
self.schedule_refresh(name)
diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py
index 09672f6f0..722fae2e0 100644
--- a/module/plugins/internal/Hoster.py
+++ b/module/plugins/internal/Hoster.py
@@ -12,7 +12,7 @@ if os.name != "nt":
import grp
import pwd
-from module.plugins.internal.Plugin import Plugin, Abort, Fail, Reconnect, Retry, Skip, parseHtmlForm
+from module.plugins.internal.Plugin import Plugin, Abort, Fail, Reconnect, Retry, Skip, parse_html_form
from module.utils import fs_decode, fs_encode, save_join as fs_join
@@ -67,21 +67,21 @@ class Hoster(Plugin):
#: username/login
self.user = None
- if self.account and not self.account.canUse():
+ if self.account and not self.account.can_use():
self.account = None
if self.account:
- self.user, data = self.account.selectAccount()
+ self.user, data = self.account.select_account()
#: Browser instance, see `network.Browser`
- self.req = self.account.getAccountRequest(self.user)
+ self.req = self.account.get_account_request(self.user)
self.chunk_limit = -1 #: chunk limit, -1 for unlimited
#: enables resume (will be ignored if server dont accept chunks)
self.resume_download = True
#: premium status
- self.premium = self.account.isPremium(self.user)
+ self.premium = self.account.is_premium(self.user)
else:
self.req = pyfile.m.core.requestFactory.getRequest(self.__name__)
@@ -132,7 +132,7 @@ class Hoster(Plugin):
self.thread = thread
if self.account:
- self.account.checkLogin(self.user)
+ self.account.check_login(self.user)
else:
self.req.clearCookies()
@@ -626,14 +626,14 @@ class Hoster(Plugin):
def parse_html_form(self, attr_str="", input_names={}):
- return parseHtmlForm(attr_str, self.html, input_names)
+ return parse_html_form(attr_str, self.html, input_names)
def check_traffic_left(self):
if not self.account:
return True
- traffic = self.account.getAccountInfo(self.user, True)['trafficleft']
+ traffic = self.account.get_account_info(self.user, True)['trafficleft']
if traffic is None:
return False
diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py
index 623836cdc..2e99afa1c 100644
--- a/module/plugins/internal/MultiHook.py
+++ b/module/plugins/internal/MultiHook.py
@@ -83,7 +83,7 @@ class MultiHook(Hook):
def load_account(self):
self.account = self.core.accountManager.getAccountPlugin(self.pluginname)
- if self.account and not self.account.canUse():
+ if self.account and not self.account.can_use():
self.account = None
if not self.account and hasattr(self.pluginclass, "LOGIN_ACCOUNT") and self.pluginclass.LOGIN_ACCOUNT:
diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py
index 8360d871e..363d46739 100644
--- a/module/plugins/internal/MultiHoster.py
+++ b/module/plugins/internal/MultiHoster.py
@@ -33,7 +33,7 @@ class MultiHoster(SimpleHoster):
self.info = {}
self.html = ""
self.link = "" #@TODO: Move to Hoster in 0.4.10
- self.direct_d_l = False #@TODO: Move to Hoster in 0.4.10
+ self.direct_dl = False #@TODO: Move to Hoster in 0.4.10
if not self.get_config('use_premium', True):
self.retry_free()
@@ -47,9 +47,9 @@ class MultiHoster(SimpleHoster):
set_cookies(self.req.cj, self.COOKIES)
if self.DIRECT_LINK is None:
- self.direct_d_l = self.__pattern__ != r'^unmatchable$' and re.match(self.__pattern__, self.pyfile.url)
+ self.direct_dl = self.__pattern__ != r'^unmatchable$' and re.match(self.__pattern__, self.pyfile.url)
else:
- self.direct_d_l = self.DIRECT_LINK
+ self.direct_dl = self.DIRECT_LINK
self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS)
@@ -58,7 +58,7 @@ class MultiHoster(SimpleHoster):
try:
self.prepare()
- if self.direct_d_l:
+ if self.direct_dl:
self.check_info()
self.log_debug("Looking for direct download link...")
self.handle_direct(pyfile)
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index 0b08858f3..01294ea92 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -236,7 +236,7 @@ class Plugin(object):
return html_unescape(urllib.unquote(url.decode('unicode-escape'))).strip()
- def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, decode=True, req=None):
+ def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, decode=True, multipart=True, req=None):
"""
Load content at url and returns it
@@ -266,7 +266,7 @@ class Plugin(object):
else:
req = self.core.requestFactory.getRequest(self.__name__)
- res = req.load(url, get, post, ref, cookies, just_header, True, bool(decode))
+ res = req.load(url, get, post, ref, cookies, just_header, multipart, bool(decode))
if decode:
res = html_unescape(res).decode(decode if isinstance(decode, basestring) else 'utf8')
diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py
index 86ff5156e..d067468dd 100644
--- a/module/plugins/internal/SevenZip.py
+++ b/module/plugins/internal/SevenZip.py
@@ -147,7 +147,7 @@ class SevenZip(UnRar):
#@NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue
call = [self.CMD, command] + args + list(xargs)
- self.manager.logDebug(" ".join(call))
+ self.manager.log_debug(" ".join(call))
p = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return p
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index fe47178e3..82f5ef332 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -55,10 +55,10 @@ class SimpleCrypter(Crypter, SimpleHoster):
account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "")
account = self.core.accountManager.getAccountPlugin(account_name)
- if account and account.canUse():
- self.user, data = account.selectAccount()
- self.req = account.getAccountRequest(self.user)
- self.premium = account.isPremium(self.user)
+ if account and account.can_use():
+ self.user, data = account.select_account()
+ self.req = account.get_account_request(self.user)
+ self.premium = account.is_premium(self.user)
self.account = account
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 2e31c1176..0e4b94534 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -266,7 +266,7 @@ class SimpleHoster(Hoster):
self.info = {}
self.html = "" #@TODO: Recheck in 0.4.10
self.link = "" #@TODO: Recheck in 0.4.10
- self.direct_d_l = False
+ self.direct_dl = False
self.multihost = False
if not self.get_config('use_premium', True):
@@ -297,9 +297,9 @@ class SimpleHoster(Hoster):
return
if self.DIRECT_LINK is None:
- self.direct_d_l = bool(self.account)
+ self.direct_dl = bool(self.account)
else:
- self.direct_d_l = self.DIRECT_LINK
+ self.direct_dl = self.DIRECT_LINK
self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS)
@@ -316,7 +316,7 @@ class SimpleHoster(Hoster):
self.prepare()
self.check_info()
- if self.direct_d_l:
+ if self.direct_dl:
self.log_debug("Looking for direct download link...")
self.handle_direct(pyfile)
@@ -364,7 +364,8 @@ class SimpleHoster(Hoster):
self.invalid_captcha()
self.retry(10, reason=_("Wrong captcha"))
- elif self.check_download({'Empty file': re.compile(r'\A((.|)(\2|\s)*)\Z')}, file_size=self.info['size']):
+ elif self.check_download({'Empty file': re.compile(r'\A((.|)(\2|\s)*)\Z')},
+ file_size=self.info['size']):
self.error(_("Empty file"))
else:
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index 4494b98c6..50c421e8d 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -191,7 +191,7 @@ class UnRar(Extractor):
raise ArchiveError(_("Cannot open file"))
if err.strip(): #: only log error at this point
- self.manager.logError(err.strip())
+ self.manager.log_error(err.strip())
result = set()
if not self.fullpath and self.VERSION.startswith('5'):
@@ -237,7 +237,7 @@ class UnRar(Extractor):
#@NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue
call = [self.CMD, command] + args + list(xargs)
- self.manager.logDebug(" ".join(call))
+ self.manager.log_debug(" ".join(call))
p = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return p
diff --git a/module/plugins/internal/XFSAccount.py b/module/plugins/internal/XFSAccount.py
index fb2302f4c..23759f6d3 100644
--- a/module/plugins/internal/XFSAccount.py
+++ b/module/plugins/internal/XFSAccount.py
@@ -5,7 +5,7 @@ import time
import urlparse
from module.plugins.internal.Account import Account
-from module.plugins.internal.Plugin import parseHtmlForm, set_cookies
+from module.plugins.internal.Plugin import parse_html_form, set_cookies
class XFSAccount(Account):
@@ -157,7 +157,7 @@ class XFSAccount(Account):
self.LOGIN_URL = urlparse.urljoin(self.HOSTER_URL, "login.html")
html = self.load(self.LOGIN_URL, req=req)
- action, inputs = parseHtmlForm('name="FL"', html)
+ action, inputs = parse_html_form('name="FL"', html)
if not inputs:
inputs = {'op' : "login",
'redirect': self.HOSTER_URL}
diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py
index 68cf25f14..9f8728512 100644
--- a/module/plugins/internal/XFSHoster.py
+++ b/module/plugins/internal/XFSHoster.py
@@ -47,7 +47,7 @@ class XFSHoster(SimpleHoster):
SOLVEMEDIA_PATTERN = None
FORM_PATTERN = None
- FORM_INPUTS_MAP = None #: dict passed as input_names to parseHtmlForm
+ FORM_INPUTS_MAP = None #: dict passed as input_names to parse_html_form
def setup(self):
@@ -80,7 +80,7 @@ class XFSHoster(SimpleHoster):
super(XFSHoster, self).prepare()
if self.DIRECT_LINK is None:
- self.direct_d_l = self.premium
+ self.direct_dl = self.premium
def handle_free(self, pyfile):