summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/plugins/internal/Addon.py4
-rw-r--r--module/plugins/internal/Captcha.py2
-rw-r--r--module/plugins/internal/Container.py18
-rw-r--r--module/plugins/internal/Hoster.py36
-rw-r--r--module/plugins/internal/OCR.py4
-rw-r--r--module/plugins/internal/Plugin.py22
-rw-r--r--module/plugins/internal/SimpleCrypter.py2
-rw-r--r--module/plugins/internal/SimpleHoster.py8
-rw-r--r--module/plugins/internal/XFSAccount.py4
-rw-r--r--module/plugins/internal/XFSCrypter.py4
-rw-r--r--module/plugins/internal/XFSHoster.py10
11 files changed, 49 insertions, 65 deletions
diff --git a/module/plugins/internal/Addon.py b/module/plugins/internal/Addon.py
index 2609c6033..5150e88f6 100644
--- a/module/plugins/internal/Addon.py
+++ b/module/plugins/internal/Addon.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-import traceback
-
from module.plugins.internal.Plugin import Plugin
@@ -103,8 +101,6 @@ class Addon(Plugin):
except Exception, e:
self.log_error(_("Error executing periodical task: %s") % e)
- if self.pyload.debug:
- traceback.print_exc()
self.cb = self.pyload.scheduler.addJob(self.interval, self._periodical, [threaded], threaded=threaded)
diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py
index dd5493ce9..d2be21a58 100644
--- a/module/plugins/internal/Captcha.py
+++ b/module/plugins/internal/Captcha.py
@@ -4,7 +4,6 @@ from __future__ import with_statement
import os
import time
-import traceback
from module.plugins.internal.Plugin import Plugin
@@ -117,7 +116,6 @@ class Captcha(Plugin):
except OSError, e:
self.log_warning(_("Error removing: %s") % tmp_img.name, e)
- traceback.print_exc()
#self.log_info(_("Captcha result: ") + result) #@TODO: Remove from here?
diff --git a/module/plugins/internal/Container.py b/module/plugins/internal/Container.py
index 66e1ad904..430590421 100644
--- a/module/plugins/internal/Container.py
+++ b/module/plugins/internal/Container.py
@@ -4,7 +4,6 @@ from __future__ import with_statement
import os
import re
-import traceback
from module.plugins.internal.Crypter import Crypter
from module.plugins.internal.Plugin import exists
@@ -14,7 +13,7 @@ from module.utils import save_join as fs_join
class Container(Crypter):
__name__ = "Container"
__type__ = "container"
- __version__ = "0.06"
+ __version__ = "0.07"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -44,11 +43,6 @@ class Container(Crypter):
self._create_packages()
- #: Deprecated method, use `_load2disk` instead (Remove in 0.4.10)
- def loadToDisk(self, *args, **kwargs):
- return self._load2disk(*args, **kwargs)
-
-
def _load2disk(self):
"""
Loads container to disk if its stored remotely and overwrite url,
@@ -67,16 +61,14 @@ class Container(Crypter):
else:
self.pyfile.name = os.path.basename(self.pyfile.url)
+
if not exists(self.pyfile.url):
if exists(fs_join(pypath, self.pyfile.url)):
self.pyfile.url = fs_join(pypath, self.pyfile.url)
else:
self.fail(_("File not exists"))
-
-
- #: Deprecated method, use `delete_tmp` instead (Remove in 0.4.10)
- def deleteTmp(self, *args, **kwargs):
- return self.delete_tmp(*args, **kwargs)
+ else:
+ self.data = self.pyfile.url
def delete_tmp(self):
@@ -87,5 +79,3 @@ class Container(Crypter):
os.remove(self.pyfile.url)
except OSError, e:
self.log_warning(_("Error removing: %s") % self.pyfile.url, e)
- if self.pyload.debug:
- traceback.print_exc()
diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py
index 6ac1e95f6..a77ef05dd 100644
--- a/module/plugins/internal/Hoster.py
+++ b/module/plugins/internal/Hoster.py
@@ -7,12 +7,11 @@ import mimetypes
import os
import random
import time
-import traceback
import urlparse
from module.plugins.internal.Captcha import Captcha
from module.plugins.internal.Plugin import (Plugin, Abort, Fail, Reconnect, Retry, Skip,
- chunks, encode, exists, parse_html_form,
+ chunks, decode, encode, exists, parse_html_form,
parse_html_tag_attr_value, parse_name,
replace_patterns, seconds_to_midnight,
set_cookie, set_cookies, timestamp)
@@ -45,7 +44,7 @@ def create_getInfo(klass):
class Hoster(Plugin):
__name__ = "Hoster"
__type__ = "hoster"
- __version__ = "0.24"
+ __version__ = "0.26"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -75,7 +74,6 @@ class Hoster(Plugin):
#: Account handler instance, see :py:class:`Account`
self.account = None
- self.user = None
self.req = None #: Browser instance, see `network.Browser`
#: Associated pyfile instance, see `PyFile`
@@ -108,7 +106,7 @@ class Hoster(Plugin):
def _log(self, level, plugintype, pluginname, messages):
log = getattr(self.pyload.log, level)
- msg = " | ".join(encode(a).strip() for a in messages if a)
+ msg = " | ".join(decode(a).strip() for a in messages if a)
log("%(plugintype)s %(pluginname)s[%(id)s]: %(msg)s"
% {'plugintype': plugintype.upper(),
'pluginname': pluginname,
@@ -145,10 +143,10 @@ class Hoster(Plugin):
self.pyfile.error = ""
if self.account:
- self.req = self.pyload.requestFactory.getRequest(self.__name__, self.user)
+ self.req = self.pyload.requestFactory.getRequest(self.__name__, self.account.user)
self.chunk_limit = -1 #: -1 for unlimited
self.resume_download = True
- self.premium = self.account.is_premium(self.user)
+ self.premium = self.account.premium
else:
self.req = self.pyload.requestFactory.getRequest(self.__name__)
self.chunk_limit = 1
@@ -194,10 +192,10 @@ class Hoster(Plugin):
self.account = self.pyload.accountManager.getAccountPlugin(self.__name__)
if self.account:
- if not self.user:
- self.user = self.account.select()[0]
+ if not self.account.user: #@TODO: Move to `Account` in 0.4.10
+ self.account.user = self.account.select()[0]
- if not self.user or not self.account.is_logged(self.user, True):
+ if not self.account.logged:
self.account = False
@@ -333,22 +331,22 @@ class Hoster(Plugin):
self.fail("temp. offline")
- def retry(self, max_tries=5, wait_time=1, msg=""):
+ def retry(self, attemps=5, delay=1, msg=""):
"""
Retries and begin again from the beginning
- :param max_tries: number of maximum retries
- :param wait_time: time to wait in seconds
- :param msg: msg for retrying, will be passed to fail if max_tries reached
+ :param attemps: number of maximum retries
+ :param delay: time to wait in seconds
+ :param msg: msg for retrying, will be passed to fail if attemps value was reached
"""
id = inspect.currentframe().f_back.f_lineno
if id not in self.retries:
self.retries[id] = 0
- if 0 < max_tries <= self.retries[id]:
+ if 0 < attemps <= self.retries[id]:
self.fail(msg or _("Max retries reached"))
- self.wait(wait_time, False)
+ self.wait(delay, False)
self.retries[id] += 1
raise Retry(encode(msg)) #@TODO: Remove `encode` in 0.4.10
@@ -550,8 +548,6 @@ class Hoster(Plugin):
except OSError, e:
self.log_warning(_("Error removing: %s") % last_download, e)
- if self.pyload.debug:
- traceback.print_exc()
else:
self.log_info(_("File deleted: ") + self.last_download)
@@ -648,7 +644,7 @@ class Hoster(Plugin):
if not self.account:
return True
- traffic = self.account.get_data(self.user, True)['trafficleft']
+ traffic = self.account.get_data(self.account.user, True)['trafficleft']
if traffic is None:
return False
@@ -658,7 +654,7 @@ class Hoster(Plugin):
else:
size = self.pyfile.size / 1024
- self.log_info(_("Filesize: %s KiB, Traffic left for user %s: %s KiB") % (size, self.user, traffic))
+ self.log_info(_("Filesize: %s KiB, Traffic left for user %s: %s KiB") % (size, self.account.user, traffic))
return size <= traffic
diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py
index 5913e604d..3e5afae69 100644
--- a/module/plugins/internal/OCR.py
+++ b/module/plugins/internal/OCR.py
@@ -12,7 +12,6 @@ import logging
import os
import subprocess
# import tempfile
-import traceback
from module.plugins.internal.Plugin import Plugin
from module.utils import save_join as fs_join
@@ -138,10 +137,9 @@ class OCR(Plugin):
os.remove(tmpTxt.name)
if subset and (digits or lowercase or uppercase):
os.remove(tmpSub.name)
+
except OSError, e:
self.log_warning(e)
- if self.pyload.debug:
- traceback.print_exc()
def recognize(self, name):
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index 118b68812..e9964b11d 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -7,9 +7,8 @@ import inspect
import os
import re
import sys
-import unicodedata
+import traceback
import urllib
-import urlparse
if os.name != "nt":
import grp
@@ -180,7 +179,7 @@ def chunks(iterable, size):
class Plugin(object):
__name__ = "Plugin"
__type__ = "plugin"
- __version__ = "0.34"
+ __version__ = "0.35"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -227,24 +226,31 @@ class Plugin(object):
def log_debug(self, *args):
- if self.pyload.debug:
- return self._log("debug", self.__type__, self.__name__, args)
+ if not self.pyload.debug:
+ return
+ self._log("debug", self.__type__, self.__name__, args)
def log_info(self, *args):
- return self._log("info", self.__type__, self.__name__, args)
+ self._log("info", self.__type__, self.__name__, args)
def log_warning(self, *args):
- return self._log("warning", self.__type__, self.__name__, args)
+ self._log("warning", self.__type__, self.__name__, args)
+ if self.pyload.debug:
+ traceback.print_exc()
def log_error(self, *args):
- return self._log("error", self.__type__, self.__name__, args)
+ self._log("error", self.__type__, self.__name__, args)
+ if self.pyload.debug:
+ traceback.print_exc()
def log_critical(self, *args):
return self._log("critical", self.__type__, self.__name__, args)
+ if self.pyload.debug:
+ traceback.print_exc()
def set_permissions(self, path):
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index d5a5ce2d7..8c5d3599d 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -137,7 +137,7 @@ class SimpleCrypter(Crypter, SimpleHoster):
try:
pages = int(re.search(self.PAGES_PATTERN, self.html).group(1))
- except Exception:
+ except AttributeError:
pages = 1
for p in xrange(2, pages + 1):
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 2a83389b6..fb55ef762 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -21,7 +21,7 @@ statusMap = dict((v, k) for k, v in _statusMap.items())
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.84"
+ __version__ = "1.85"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -124,7 +124,7 @@ class SimpleHoster(Hoster):
try:
info['pattern'] = re.match(cls.__pattern__, url).groupdict() #: Pattern groups will be saved here
- except Exception:
+ except AttributeError:
info['pattern'] = {}
if not html and not online:
@@ -329,7 +329,7 @@ class SimpleHoster(Hoster):
self.log_warning(_("Check result: ") + errmsg, _("Waiting 1 minute and retry"))
self.wantReconnect = True
- self.retry(wait_time=60, msg=errmsg)
+ self.retry(delay=60, msg=errmsg)
else:
if self.CHECK_FILE:
self.log_debug("Using custom check rules...")
@@ -428,7 +428,7 @@ class SimpleHoster(Hoster):
else:
self.wantReconnect = True
- self.retry(wait_time=60, msg=errmsg)
+ self.retry(delay=60, msg=errmsg)
elif hasattr(self, 'WAIT_PATTERN'):
m = re.search(self.WAIT_PATTERN, self.html)
diff --git a/module/plugins/internal/XFSAccount.py b/module/plugins/internal/XFSAccount.py
index 392d9503c..bb5cbcf50 100644
--- a/module/plugins/internal/XFSAccount.py
+++ b/module/plugins/internal/XFSAccount.py
@@ -12,7 +12,7 @@ from module.plugins.internal.Plugin import parse_html_form, set_cookie
class XFSAccount(Account):
__name__ = "XFSAccount"
__type__ = "account"
- __version__ = "0.45"
+ __version__ = "0.46"
__status__ = "testing"
__description__ = """XFileSharing account plugin"""
@@ -145,7 +145,7 @@ class XFSAccount(Account):
self.HOSTER_URL = "http://www.%s/" % self.HOSTER_DOMAIN
if self.COOKIES:
- if isinstance(self.COOKIES, list) and not self.COOKIES.count((self.HOSTER_DOMAIN, "lang", "english")):
+ if isinstance(self.COOKIES, list) and (self.HOSTER_DOMAIN, "lang", "english") not in self.COOKIES:
self.COOKIES.insert((self.HOSTER_DOMAIN, "lang", "english"))
else:
set_cookie(self.req.cj, self.HOSTER_DOMAIN, "lang", "english")
diff --git a/module/plugins/internal/XFSCrypter.py b/module/plugins/internal/XFSCrypter.py
index 4c059d647..12a48d4a3 100644
--- a/module/plugins/internal/XFSCrypter.py
+++ b/module/plugins/internal/XFSCrypter.py
@@ -7,7 +7,7 @@ from module.plugins.internal.SimpleCrypter import SimpleCrypter, create_getInfo
class XFSCrypter(SimpleCrypter):
__name__ = "XFSCrypter"
__type__ = "crypter"
- __version__ = "0.13"
+ __version__ = "0.14"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -42,7 +42,7 @@ class XFSCrypter(SimpleCrypter):
self.fail(_("Missing HOSTER_DOMAIN"))
if self.COOKIES:
- if isinstance(self.COOKIES, list) and not self.COOKIES.count((self.HOSTER_DOMAIN, "lang", "english")):
+ if isinstance(self.COOKIES, list) and (self.HOSTER_DOMAIN, "lang", "english") not in self.COOKIES:
self.COOKIES.insert((self.HOSTER_DOMAIN, "lang", "english"))
else:
set_cookie(self.req.cj, self.HOSTER_DOMAIN, "lang", "english")
diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py
index 1f0bd3a44..145efcd8e 100644
--- a/module/plugins/internal/XFSHoster.py
+++ b/module/plugins/internal/XFSHoster.py
@@ -14,7 +14,7 @@ from module.utils import html_unescape
class XFSHoster(SimpleHoster):
__name__ = "XFSHoster"
__type__ = "hoster"
- __version__ = "0.58"
+ __version__ = "0.59"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -73,7 +73,7 @@ class XFSHoster(SimpleHoster):
self.fail(_("Missing HOSTER_DOMAIN"))
if self.COOKIES:
- if isinstance(self.COOKIES, list) and not self.COOKIES.count((self.HOSTER_DOMAIN, "lang", "english")):
+ if isinstance(self.COOKIES, list) and (self.HOSTER_DOMAIN, "lang", "english") not in self.COOKIES:
self.COOKIES.insert((self.HOSTER_DOMAIN, "lang", "english"))
else:
set_cookie(self.req.cj, self.HOSTER_DOMAIN, "lang", "english")
@@ -163,7 +163,7 @@ class XFSHoster(SimpleHoster):
self.retry(20, 3 * 60, _("Can not leech file"))
elif 'today' in stmsg:
- self.retry(wait_time=seconds_to_midnight(gmt=2), msg=_("You've used all Leech traffic today"))
+ self.retry(delay=seconds_to_midnight(gmt=2), msg=_("You've used all Leech traffic today"))
else:
self.fail(stmsg)
@@ -244,7 +244,7 @@ class XFSHoster(SimpleHoster):
try:
captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1)
- except Exception:
+ except AttributeError:
captcha_key = recaptcha.detect_key()
else:
@@ -258,7 +258,7 @@ class XFSHoster(SimpleHoster):
try:
captcha_key = re.search(self.SOLVEMEDIA_PATTERN, self.html).group(1)
- except Exception:
+ except AttributeError:
captcha_key = solvemedia.detect_key()
else: