summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-02 04:22:19 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-02 04:22:19 +0200
commitab695d17397e101447102877cdd282d825051035 (patch)
tree28f9f62ffc57888b76ca32540dbf5af3a4cfc8d0 /module
parent[UptoboxCom] Fix https://github.com/pyload/pyload/issues/1530 and https://git... (diff)
downloadpyload-ab695d17397e101447102877cdd282d825051035.tar.xz
[Account] Improve parse_traffic method + code cosmetics
Diffstat (limited to 'module')
-rw-r--r--module/plugins/accounts/CzshareCom.py4
-rw-r--r--module/plugins/accounts/FreeWayMe.py4
-rw-r--r--module/plugins/accounts/FshareVn.py4
-rw-r--r--module/plugins/accounts/HellshareCz.py4
-rw-r--r--module/plugins/accounts/LinksnappyCom.py4
-rw-r--r--module/plugins/accounts/MultishareCz.py4
-rw-r--r--module/plugins/accounts/NitroflareCom.py4
-rw-r--r--module/plugins/accounts/RehostTo.py4
-rw-r--r--module/plugins/hooks/AntiStandby.py4
-rw-r--r--module/plugins/hooks/ExtractArchive.py2
-rw-r--r--module/plugins/hoster/ShareonlineBiz.py10
-rw-r--r--module/plugins/internal/Account.py14
-rw-r--r--module/plugins/internal/OCR.py2
-rw-r--r--module/plugins/internal/Plugin.py10
-rw-r--r--module/plugins/internal/SevenZip.py2
-rw-r--r--module/plugins/internal/SimpleHoster.py10
-rw-r--r--module/plugins/internal/UnRar.py6
17 files changed, 45 insertions, 47 deletions
diff --git a/module/plugins/accounts/CzshareCom.py b/module/plugins/accounts/CzshareCom.py
index 448722dd9..209a94f60 100644
--- a/module/plugins/accounts/CzshareCom.py
+++ b/module/plugins/accounts/CzshareCom.py
@@ -9,7 +9,7 @@ from module.plugins.internal.Account import Account
class CzshareCom(Account):
__name__ = "CzshareCom"
__type__ = "account"
- __version__ = "0.22"
+ __version__ = "0.23"
__status__ = "testing"
__description__ = """Czshare.com account plugin, now Sdilej.cz"""
@@ -30,7 +30,7 @@ class CzshareCom(Account):
try:
m = re.search(self.CREDIT_LEFT_PATTERN, html)
- trafficleft = self.parse_traffic(m.group(1).replace(' ', '').replace(',', '.')) + m.group(2)
+ trafficleft = self.parse_traffic(m.group(1), m.group(2)
validuntil = time.mktime(time.strptime(m.group(3), '%d.%m.%y %H:%M'))
except Exception, e:
diff --git a/module/plugins/accounts/FreeWayMe.py b/module/plugins/accounts/FreeWayMe.py
index b554f592a..5e214db35 100644
--- a/module/plugins/accounts/FreeWayMe.py
+++ b/module/plugins/accounts/FreeWayMe.py
@@ -7,7 +7,7 @@ from module.common.json_layer import json_loads
class FreeWayMe(Account):
__name__ = "FreeWayMe"
__type__ = "account"
- __version__ = "0.18"
+ __version__ = "0.19"
__status__ = "testing"
__config__ = [("mh_mode" , "all;listed;unlisted", "Filter hosters to use" , "all"),
@@ -32,7 +32,7 @@ class FreeWayMe(Account):
account_info = {'validuntil': -1, 'premium': False}
if status['premium'] == "Free":
- account_info['trafficleft'] = self.parse_traffic(status['guthaben'] + "MB")
+ account_info['trafficleft'] = self.parse_traffic(status['guthaben'], "MB")
elif status['premium'] == "Spender":
account_info['trafficleft'] = -1
elif status['premium'] == "Flatrate":
diff --git a/module/plugins/accounts/FshareVn.py b/module/plugins/accounts/FshareVn.py
index 24a858274..e692394ef 100644
--- a/module/plugins/accounts/FshareVn.py
+++ b/module/plugins/accounts/FshareVn.py
@@ -9,7 +9,7 @@ from module.plugins.internal.Account import Account
class FshareVn(Account):
__name__ = "FshareVn"
__type__ = "account"
- __version__ = "0.13"
+ __version__ = "0.14"
__status__ = "testing"
__description__ = """Fshare.vn account plugin"""
@@ -58,4 +58,4 @@ class FshareVn(Account):
def get_traffic_left(self):
m = re.search(self.TRAFFIC_LEFT_PATTERN, html)
- return self.parse_traffic(m.group(1) + m.group(2)) if m else 0
+ return self.parse_traffic(m.group(1), m.group(2)) if m else 0
diff --git a/module/plugins/accounts/HellshareCz.py b/module/plugins/accounts/HellshareCz.py
index 3031c26b6..cdfa9937a 100644
--- a/module/plugins/accounts/HellshareCz.py
+++ b/module/plugins/accounts/HellshareCz.py
@@ -9,7 +9,7 @@ from module.plugins.internal.Account import Account
class HellshareCz(Account):
__name__ = "HellshareCz"
__type__ = "account"
- __version__ = "0.20"
+ __version__ = "0.21"
__status__ = "testing"
__description__ = """Hellshare.cz account plugin"""
@@ -42,7 +42,7 @@ class HellshareCz(Account):
trafficleft = -1
else:
#: Traffic-based account
- trafficleft = self.parse_traffic(credit + "MB")
+ trafficleft = self.parse_traffic(credit, "MB")
validuntil = -1
except Exception, e:
diff --git a/module/plugins/accounts/LinksnappyCom.py b/module/plugins/accounts/LinksnappyCom.py
index cf69791e7..6953f311c 100644
--- a/module/plugins/accounts/LinksnappyCom.py
+++ b/module/plugins/accounts/LinksnappyCom.py
@@ -9,7 +9,7 @@ from module.common.json_layer import json_loads
class LinksnappyCom(Account):
__name__ = "LinksnappyCom"
__type__ = "account"
- __version__ = "0.09"
+ __version__ = "0.10"
__status__ = "testing"
__config__ = [("mh_mode" , "all;listed;unlisted", "Filter hosters to use" , "all"),
@@ -55,7 +55,7 @@ class LinksnappyCom(Account):
if 'trafficleft' not in j['return'] or isinstance(j['return']['trafficleft'], str):
trafficleft = -1
else:
- trafficleft = self.parse_traffic("%d MB" % j['return']['trafficleft'])
+ trafficleft = self.parse_traffic(j['return']['trafficleft'], "MB")
return {'premium' : True ,
'validuntil' : validuntil ,
diff --git a/module/plugins/accounts/MultishareCz.py b/module/plugins/accounts/MultishareCz.py
index 58d3367c2..77facb308 100644
--- a/module/plugins/accounts/MultishareCz.py
+++ b/module/plugins/accounts/MultishareCz.py
@@ -8,7 +8,7 @@ from module.plugins.internal.Account import Account
class MultishareCz(Account):
__name__ = "MultishareCz"
__type__ = "account"
- __version__ = "0.09"
+ __version__ = "0.10"
__status__ = "testing"
__config__ = [("mh_mode" , "all;listed;unlisted", "Filter hosters to use" , "all"),
@@ -36,7 +36,7 @@ class MultishareCz(Account):
html = self.load("http://www.multishare.cz/profil/")
m = re.search(self.TRAFFIC_LEFT_PATTERN, html)
- trafficleft = self.parse_traffic(m.group('S') + m.group('U')) if m else 0
+ trafficleft = self.parse_traffic(m.group('S'), m.group('U')) if m else 0
self.premium = True if trafficleft else False
html = self.load("http://www.multishare.cz/")
diff --git a/module/plugins/accounts/NitroflareCom.py b/module/plugins/accounts/NitroflareCom.py
index 70804d4e9..af71b1321 100644
--- a/module/plugins/accounts/NitroflareCom.py
+++ b/module/plugins/accounts/NitroflareCom.py
@@ -9,7 +9,7 @@ from module.plugins.internal.Account import Account
class NitroflareCom(Account):
__name__ = "NitroflareCom"
__type__ = "account"
- __version__ = "0.08"
+ __version__ = "0.09"
__status__ = "testing"
__description__ = """Nitroflare.com account plugin"""
@@ -56,7 +56,7 @@ class NitroflareCom(Account):
m = re.search(self.TRAFFIC_LEFT_PATTERN, html)
if m is not None:
try:
- trafficleft = self.parse_traffic(str(max(0, 50 - float(m.group(1)))) + " GB")
+ trafficleft = self.parse_traffic(str(max(0, 50 - float(m.group(1)))), "GB")
except Exception, e:
self.log_error(e)
diff --git a/module/plugins/accounts/RehostTo.py b/module/plugins/accounts/RehostTo.py
index 2ad4cdceb..4ff3f15a8 100644
--- a/module/plugins/accounts/RehostTo.py
+++ b/module/plugins/accounts/RehostTo.py
@@ -6,7 +6,7 @@ from module.plugins.internal.Account import Account
class RehostTo(Account):
__name__ = "RehostTo"
__type__ = "account"
- __version__ = "0.20"
+ __version__ = "0.21"
__status__ = "testing"
__config__ = [("mh_mode" , "all;listed;unlisted", "Filter hosters to use" , "all"),
@@ -48,7 +48,7 @@ class RehostTo(Account):
traffic, valid = html.split(",")
premium = True
- trafficleft = self.parse_traffic(traffic + "MB")
+ trafficleft = self.parse_traffic(traffic, "MB")
validuntil = float(valid)
finally:
diff --git a/module/plugins/hooks/AntiStandby.py b/module/plugins/hooks/AntiStandby.py
index 48b86fa55..fbb7f6760 100644
--- a/module/plugins/hooks/AntiStandby.py
+++ b/module/plugins/hooks/AntiStandby.py
@@ -59,7 +59,7 @@ class AntiStandby(Addon):
self.interval = max(self.get_config('interval'), self.MIN_INTERVAL)
self.init_periodical(threaded=True)
- if os.name == "nt":
+ if os.name is "nt":
self.win_standby(system, display)
elif sys.platform == "darwin":
@@ -76,7 +76,7 @@ class AntiStandby(Addon):
except OSError:
pass
- if os.name == "nt":
+ if os.name is "nt":
self.win_standby(True)
elif sys.platform == "darwin":
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index b5a714533..9c662a897 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -7,7 +7,7 @@ import sys
# monkey patch bug in python 2.6 and lower
# http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717
-if sys.version_info < (2, 7) and os.name != "nt":
+if sys.version_info < (2, 7) and os.name is not "nt":
import errno
import subprocess
diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py
index a8f4a5c8b..2223068e5 100644
--- a/module/plugins/hoster/ShareonlineBiz.py
+++ b/module/plugins/hoster/ShareonlineBiz.py
@@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class ShareonlineBiz(SimpleHoster):
__name__ = "ShareonlineBiz"
__type__ = "hoster"
- __version__ = "0.57"
+ __version__ = "0.58"
__status__ = "testing"
__pattern__ = r'https?://(?:www\.)?(share-online\.biz|egoshare\.com)/(download\.php\?id=|dl/)(?P<ID>\w+)'
@@ -169,12 +169,12 @@ class ShareonlineBiz(SimpleHoster):
self.retry(10, 600, _("Server is full"))
elif 'slot' in errmsg:
- self.wantReconnect = True
- self.retry(24, 3600, errmsg)
+ self.wait(3600, reconnect=True)
+ self.restart(errmsg, premium=True)
else:
- self.wantReconnect = True
- self.retry(wait=60, msg=errmsg)
+ self.wait(60, reconnect=True)
+ self.restart(errmsg, premium=True)
getInfo = create_getInfo(ShareonlineBiz)
diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py
index 123241be3..ad78403de 100644
--- a/module/plugins/internal/Account.py
+++ b/module/plugins/internal/Account.py
@@ -5,14 +5,14 @@ import time
import threading
from module.plugins.Plugin import SkipDownload as Skip
-from module.plugins.internal.Plugin import Plugin
-from module.utils import compare_time, lock, parseFileSize as parse_size
+from module.plugins.internal.Plugin import Plugin, parse_size
+from module.utils import compare_time, lock
class Account(Plugin):
__name__ = "Account"
__type__ = "account"
- __version__ = "0.52"
+ __version__ = "0.53"
__status__ = "testing"
__description__ = """Base account plugin"""
@@ -391,11 +391,9 @@ class Account(Plugin):
###########################################################################
- def parse_traffic(self, value, unit=None): #@NOTE: Returns kilobytes in 0.4.9
- if not isinstance(unit, basestring):
- unit = "KB"
-
- return parse_size(value, unit) / 1024 #@TODO: Remove `/ 1024` in 0.4.10
+ def parse_traffic(self, size, unit="KB"): #@NOTE: Returns kilobytes in 0.4.9
+ size = re.search(r'(\d*[\.,]?\d+)', size).group(1) #@TODO: Recjeck in 0.4.10
+ return parse_size(size, unit) / 1024 #@TODO: Remove `/ 1024` in 0.4.10
def fail_login(self, msg=_("Login handshake has failed")):
diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py
index 3e5afae69..884639b6b 100644
--- a/module/plugins/internal/OCR.py
+++ b/module/plugins/internal/OCR.py
@@ -94,7 +94,7 @@ class OCR(Plugin):
self.pyload.log_debug("Saving tiff...")
self.image.save(tmpTif.name, 'TIFF')
- if os.name == "nt":
+ if os.name is "nt":
tessparams = [os.path.join(pypath, "tesseract", "tesseract.exe")]
else:
tessparams = ["tesseract"]
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index 24cff70c3..6d94ca1e4 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -11,12 +11,12 @@ import traceback
import urllib
import urlparse
-if os.name != "nt":
+if os.name is not "nt":
import grp
import pwd
from module.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload as Skip #@TODO: Remove in 0.4.10
-from module.utils import fs_encode, fs_decode, html_unescape, save_join as fs_join
+from module.utils import fs_encode, fs_decode, html_unescape, parseFileSize as parse_size, save_join as fs_join
#@TODO: Move to utils in 0.4.10
@@ -45,7 +45,7 @@ def encode(string, encoding='utf8'):
#@TODO: Move to utils in 0.4.10
def exists(path):
if os.path.exists(path):
- if os.name == "nt":
+ if os.name is "nt":
dir, name = os.path.split(path.rstrip(os.sep))
return name in os.listdir(dir)
else:
@@ -228,7 +228,7 @@ def chunks(iterable, size):
class Plugin(object):
__name__ = "Plugin"
__type__ = "plugin"
- __version__ = "0.43"
+ __version__ = "0.44"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -314,7 +314,7 @@ class Plugin(object):
self.log_warning(_("Setting path mode failed"), e)
try:
- if os.name != "nt" and self.pyload.config.get("permission", "change_dl"):
+ if os.name is not "nt" and self.pyload.config.get("permission", "change_dl"):
uid = pwd.getpwnam(self.pyload.config.get("permission", "user"))[2]
gid = grp.getgrnam(self.pyload.config.get("permission", "group"))[2]
os.chown(path, uid, gid)
diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py
index 7ed64ecdf..f73e935e8 100644
--- a/module/plugins/internal/SevenZip.py
+++ b/module/plugins/internal/SevenZip.py
@@ -38,7 +38,7 @@ class SevenZip(UnRar):
@classmethod
def find(cls):
try:
- if os.name == "nt":
+ if os.name is "nt":
cls.CMD = os.path.join(pypath, "7z.exe")
p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 5d6892ec5..e5526a7bd 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -16,7 +16,7 @@ from module.utils import fixup, fs_encode, parseFileSize as parse_size
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.92"
+ __version__ = "1.93"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -314,8 +314,8 @@ class SimpleHoster(Hoster):
pass
self.log_warning(_("Check result: ") + errmsg, _("Waiting 1 minute and retry"))
- self.wantReconnect = True
- self.retry(wait=60, msg=errmsg)
+ self.wait(60, reconnect=True)
+ self.restart(errmsg, premium=True)
else:
if self.CHECK_FILE:
self.log_debug("Using custom check rules...")
@@ -401,8 +401,8 @@ class SimpleHoster(Hoster):
self.fail(_("File can be downloaded by premium users only"))
else:
- self.wantReconnect = True
- self.retry(wait=60, msg=errmsg)
+ self.wait(60, reconnect=True)
+ self.restart(errmsg, premium=True)
elif self.WAIT_PATTERN:
m = re.search(self.WAIT_PATTERN, self.html)
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index 7efecc5ef..908689109 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -12,7 +12,7 @@ from module.utils import fs_decode, save_join as fs_join
def renice(pid, value):
- if value and os.name != "nt":
+ if value and os.name is not "nt":
try:
subprocess.Popen(["renice", str(value), str(pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=-1)
@@ -49,7 +49,7 @@ class UnRar(Extractor):
@classmethod
def find(cls):
try:
- if os.name == "nt":
+ if os.name is "nt":
cls.CMD = os.path.join(pypath, "RAR.exe")
else:
cls.CMD = "rar"
@@ -61,7 +61,7 @@ class UnRar(Extractor):
except OSError:
try:
- if os.name == "nt":
+ if os.name is "nt":
cls.CMD = os.path.join(pypath, "UnRAR.exe")
else:
cls.CMD = "unrar"