summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-09-03 20:37:17 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-09-03 20:37:17 +0200
commit4cd2b7390dd97dc2016ab71f954f191de12f2f46 (patch)
tree774c8ae6c6e49d87034d9b697e140914b318db4d
parentMerge pull request #1801 from Nippey/patch-1 (diff)
downloadpyload-4cd2b7390dd97dc2016ab71f954f191de12f2f46.tar.xz
Spare fixes (2)
-rw-r--r--module/plugins/accounts/OboomCom.py9
-rw-r--r--module/plugins/accounts/RapiduNet.py2
-rw-r--r--module/plugins/crypter/GoogledriveComFolder.py4
-rw-r--r--module/plugins/crypter/LinkCryptWs.py2
-rw-r--r--module/plugins/crypter/TNTVillageScambioeticoOrg.py4
-rw-r--r--module/plugins/hooks/ExtractArchive.py12
-rw-r--r--module/plugins/hooks/TransmissionRPC.py32
-rw-r--r--module/plugins/hoster/ShareonlineBiz.py4
-rw-r--r--module/plugins/internal/Addon.py8
-rw-r--r--module/plugins/internal/Hoster.py53
-rw-r--r--module/plugins/internal/Plugin.py6
-rw-r--r--module/plugins/internal/SimpleCrypter.py2
-rw-r--r--module/plugins/internal/SimpleHoster.py22
13 files changed, 90 insertions, 70 deletions
diff --git a/module/plugins/accounts/OboomCom.py b/module/plugins/accounts/OboomCom.py
index 380368b70..a792848ea 100644
--- a/module/plugins/accounts/OboomCom.py
+++ b/module/plugins/accounts/OboomCom.py
@@ -40,7 +40,7 @@ class OboomCom(Account):
get={'auth': user,
'pass': pbkdf2}))
- if not result[0] == 200:
+ if result[0] != 200:
self.log_warning(_("Failed to log in: %s") % result[1])
self.login_fail()
@@ -52,10 +52,7 @@ class OboomCom(Account):
userData = account_data['user']
- if userData['premium'] == "null":
- premium = False
- else:
- premium = True
+ premium = userData['premium'] != "null"
if userData['premium_unix'] == "null":
validUntil = -1
@@ -65,7 +62,7 @@ class OboomCom(Account):
traffic = userData['traffic']
trafficLeft = traffic['current'] / 1024 #@TODO: Remove `/ 1024` in 0.4.10
- maxTraffic = traffic['max'] / 1024 #@TODO: Remove `/ 1024` in 0.4.10
+ maxTraffic = traffic['max'] / 1024 #@TODO: Remove `/ 1024` in 0.4.10
session = account_data['session']
diff --git a/module/plugins/accounts/RapiduNet.py b/module/plugins/accounts/RapiduNet.py
index 1ec29bd77..2033d377f 100644
--- a/module/plugins/accounts/RapiduNet.py
+++ b/module/plugins/accounts/RapiduNet.py
@@ -62,5 +62,5 @@ class RapiduNet(Account):
self.log_debug(json)
- if not json['message'] == "success":
+ if json['message'] != "success":
self.login_fail()
diff --git a/module/plugins/crypter/GoogledriveComFolder.py b/module/plugins/crypter/GoogledriveComFolder.py
index 88c7ebab2..e7a5bae2c 100644
--- a/module/plugins/crypter/GoogledriveComFolder.py
+++ b/module/plugins/crypter/GoogledriveComFolder.py
@@ -6,11 +6,11 @@ from module.plugins.internal.SimpleCrypter import SimpleCrypter, create_getInfo
class GoogledriveComFolder(SimpleCrypter):
__name__ = "GoogledriveCom"
__type__ = "crypter"
- __version__ = "0.02"
+ __version__ = "0.03"
__status__ = "testing"
__pattern__ = r'https?://(?:www\.)?drive\.google\.com/folderview\?.*id=\w+'
- __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True), #: Overrides pyload.config['general']['folder_per_package']
+ __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True),
("subfolder_per_pack", "bool", "Create a subfolder for each package", True)]
__description__ = """Drive.google.com folder decrypter plugin"""
diff --git a/module/plugins/crypter/LinkCryptWs.py b/module/plugins/crypter/LinkCryptWs.py
index 557a63cbd..095ca0158 100644
--- a/module/plugins/crypter/LinkCryptWs.py
+++ b/module/plugins/crypter/LinkCryptWs.py
@@ -152,7 +152,7 @@ class LinkCryptWs(Crypter):
unrarpw = sitein[indexi:indexe]
- if not (unrarpw == "Password" or "Dateipasswort") :
+ if unrarpw not in ("Password", "Dateipasswort"):
self.log_debug("File password set to: [%s]"% unrarpw)
self.pyfile.package().password = unrarpw
diff --git a/module/plugins/crypter/TNTVillageScambioeticoOrg.py b/module/plugins/crypter/TNTVillageScambioeticoOrg.py
index 6ba1ee19b..e85a8fbb7 100644
--- a/module/plugins/crypter/TNTVillageScambioeticoOrg.py
+++ b/module/plugins/crypter/TNTVillageScambioeticoOrg.py
@@ -6,11 +6,11 @@ from module.plugins.internal.SimpleCrypter import SimpleCrypter, create_getInfo
class TNTVillageScambioeticoOrg(SimpleCrypter):
__name__ = "TNTVillageScambioeticoOrg"
__type__ = "crypter"
- __version__ = "0.02"
+ __version__ = "0.03"
__status__ = "testing"
__pattern__ = r'http://(?:www\.)?forum\.tntvillage\.scambioetico\.org/index\.php\?.*showtopic=\d+'
- __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True), #: Overrides pyload.config['general']['folder_per_package']
+ __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True),
("subfolder_per_pack", "bool", "Create a subfolder for each package", True)]
__description__ = """TNTVillage.scambioetico.org decrypter plugin"""
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index eab196160..87cd38ade 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -51,7 +51,7 @@ except ImportError:
pass
from module.plugins.internal.Addon import Addon, Expose, threaded
-from module.plugins.internal.Plugin import replace_patterns
+from module.plugins.internal.Plugin import exists, replace_patterns
from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError
from module.utils import fs_encode, save_join as fs_join, uniqify
@@ -107,7 +107,7 @@ class ArchiveQueue(object):
class ExtractArchive(Addon):
__name__ = "ExtractArchive"
__type__ = "hook"
- __version__ = "1.49"
+ __version__ = "1.50"
__status__ = "testing"
__config__ = [("activated" , "bool" , "Activated" , True ),
@@ -288,7 +288,7 @@ class ExtractArchive(Addon):
if subfolder:
out = fs_join(out, pypack.folder)
- if not os.path.exists(out):
+ if not exists(out):
os.makedirs(out)
matched = False
@@ -313,7 +313,7 @@ class ExtractArchive(Addon):
for fname, fid, fout in targets:
name = os.path.basename(fname)
- if not os.path.exists(fname):
+ if not exists(fname):
self.log_debug(name, "File not found")
continue
@@ -356,7 +356,7 @@ class ExtractArchive(Addon):
for filename in new_files:
file = fs_encode(fs_join(os.path.dirname(archive.filename), filename))
- if not os.path.exists(file):
+ if not exists(file):
self.log_debug("New file %s does not exists" % filename)
continue
@@ -476,7 +476,7 @@ class ExtractArchive(Addon):
deltotrash = self.get_config('deltotrash')
for f in delfiles:
file = fs_encode(f)
- if not os.path.exists(file):
+ if not exists(file):
continue
if not deltotrash:
diff --git a/module/plugins/hooks/TransmissionRPC.py b/module/plugins/hooks/TransmissionRPC.py
index 3d10b90c4..9a9ee04b7 100644
--- a/module/plugins/hooks/TransmissionRPC.py
+++ b/module/plugins/hooks/TransmissionRPC.py
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
-import re
import random
+import re
+
import pycurl
from module.common.json_layer import json_loads, json_dumps
@@ -9,17 +10,19 @@ from module.network.HTTPRequest import BadHeader
from module.network.RequestFactory import getRequest as get_request
from module.plugins.internal.Addon import Addon
+
class TransmissionRPC(Addon):
- __name__ = "TransmissionRPC"
- __type__ = "hook"
+ __name__ = "TransmissionRPC"
+ __type__ = "hook"
+ __version__ = "0.11"
__status__ = "testing"
__pattern__ = r"https?://.+\.torrent|magnet:\?.+"
- __config__ = [("transmissionrpcurl" , "string" , "Transmission RPC URL" , "http://127.0.0.1:9091/transmission/rpc")]
+ __config__ = [("rpc_url", "str", "Transmission RPC URL", "http://127.0.0.1:9091/transmission/rpc")]
- __version__ = "0.1"
__description__ = """Send torrent and magnet URLs to Transmission Bittorent daemon via RPC"""
- __authors__ = [("GammaC0de", None)]
+ __license__ = "GPLv3"
+ __authors__ = [("GammaC0de", None)]
def init(self):
@@ -27,16 +30,17 @@ class TransmissionRPC(Addon):
def links_added(self, links, pid):
- for link in links:
- m = re.search(self.__pattern__, link)
- if m:
- self.log_debug("sending link: %s" % link)
- self.SendToTransmission(link)
- links.remove(link)
+ pattern = re.compile(self.__pattern__)
+ urls = [link for link in links if pattern.match(link)]
+
+ for url in urls:
+ self.log_debug("Sending link: %s" % url)
+ self.SendToTransmission(url)
+ links.remove(url)
def SendToTransmission(self, url):
- transmission_rpc_url = self.get_config('transmissionrpcurl')
+ transmission_rpc_url = self.get_config('rpc_url')
client_request_id = self.__name__ + "".join(random.choice('0123456789ABCDEF') for _i in xrange(4))
req = get_request()
@@ -67,7 +71,7 @@ class TransmissionRPC(Addon):
try:
res = json_loads(response)
if "result" in res:
- self.log_debug("result: %s" % res['result'])
+ self.log_debug("Result: %s" % res['result'])
except Exception, e:
self.log_error(e)
diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py
index b5af3ea35..dbe7fe401 100644
--- a/module/plugins/hoster/ShareonlineBiz.py
+++ b/module/plugins/hoster/ShareonlineBiz.py
@@ -79,7 +79,7 @@ class ShareonlineBiz(SimpleHoster):
post={'dl_free' : "1",
'recaptcha_challenge_field': challenge,
'recaptcha_response_field' : response})
- if not res == "0":
+ if res != "0":
self.captcha.correct()
return res
else:
@@ -136,7 +136,7 @@ class ShareonlineBiz(SimpleHoster):
self.log_debug(dlinfo)
- if not dlinfo['status'] == "online":
+ if dlinfo['status'] != "online":
self.offline()
else:
pyfile.name = dlinfo['name']
diff --git a/module/plugins/internal/Addon.py b/module/plugins/internal/Addon.py
index 45ca98eac..4ccaaba8b 100644
--- a/module/plugins/internal/Addon.py
+++ b/module/plugins/internal/Addon.py
@@ -25,7 +25,7 @@ def threaded(fn):
class Addon(Plugin):
__name__ = "Addon"
__type__ = "hook" #@TODO: Change to `addon` in 0.4.10
- __version__ = "0.04"
+ __version__ = "0.05"
__status__ = "testing"
__config__ = [] #: [("name", "type", "desc", "default")]
@@ -57,6 +57,12 @@ class Addon(Plugin):
self.init_events()
+ #@TODO: Remove in 0.4.10
+ def _log(self, level, plugintype, pluginname, messages):
+ plugintype = "addon" if plugintype is "hook" else plugintype
+ return super(Addon, self)._log(level, plugintype, pluginname, messages)
+
+
def init_events(self):
if self.event_map:
for event, funcs in self.event_map.items():
diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py
index 924672acf..e6bd14329 100644
--- a/module/plugins/internal/Hoster.py
+++ b/module/plugins/internal/Hoster.py
@@ -44,7 +44,7 @@ def create_getInfo(klass):
class Hoster(Plugin):
__name__ = "Hoster"
__type__ = "hoster"
- __version__ = "0.21"
+ __version__ = "0.22"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -432,9 +432,35 @@ class Hoster(Plugin):
return self.last_download
- def check_download(self, rules, delete=False, file_size=0, size_tolerance=1024, read_size=1048576):
+ def check_filesize(self, file_size, size_tolerance=1024):
"""
- Checks the content of the last downloaded file, re match is saved to `lastCheck`
+ Checks the file size of the last downloaded file
+
+ :param file_size: expected file size
+ :param size_tolerance: size check tolerance
+ """
+ if not self.last_download:
+ return
+
+ download_size = os.stat(fs_encode(self.last_download)).st_size
+
+ if download_size < 1:
+ self.fail(_("Empty file"))
+
+ elif file_size > 0:
+ diff = abs(file_size - download_size)
+
+ if diff > size_tolerance:
+ self.fail(_("File size mismatch | Expected file size: %s | Downloaded file size: %s")
+ % (file_size, download_size))
+
+ elif diff != 0:
+ self.log_warning(_("File size is not equal to expected size"))
+
+
+ def check_download(self, rules, delete=False, read_size=1048576, file_size=0, size_tolerance=1024):
+ """
+ Checks the content of the last downloaded file, re match is saved to `last_check`
:param rules: dict with names and rules to match (compiled regexp or strings)
:param delete: delete if matched
@@ -447,26 +473,11 @@ class Hoster(Plugin):
last_download = fs_encode(self.last_download)
if not self.last_download or not exists(last_download):
- self.last_download = ""
+ self.last_download = "" #@NOTE: Bad place...
self.fail(self.pyfile.error or _("No file downloaded"))
try:
- download_size = os.stat(last_download).st_size
-
- if download_size < 1:
- do_delete = True
- self.fail(_("Empty file"))
-
- elif file_size > 0:
- diff = abs(file_size - download_size)
-
- if diff > size_tolerance:
- do_delete = True
- self.fail(_("File size mismatch | Expected file size: %s | Downloaded file size: %s")
- % (file_size, download_size))
-
- elif diff != 0:
- self.log_warning(_("File size is not equal to expected size"))
+ self.check_filesize(file_size, size_tolerance)
with open(last_download, "rb") as f:
content = f.read(read_size)
@@ -496,8 +507,8 @@ class Hoster(Plugin):
traceback.print_exc()
else:
+ self.log_info(_("File deleted: ") + self.last_download)
self.last_download = ""
- self.log_info(_("File deleted"))
def direct_link(self, url, follow_location=None):
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index 1e04d388e..b0c0bb66e 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -54,9 +54,9 @@ def fixurl(url):
#@TODO: Move to utils in 0.4.10
def timestamp():
return int(time.time() * 1000)
-
-
-#@TODO: Move to utils in 0.4.10
+
+
+#@TODO: Move to utils in 0.4.10
def which(program):
"""
Works exactly like the unix command which
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index 9597116cc..d348f92e2 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -14,7 +14,7 @@ class SimpleCrypter(Crypter, SimpleHoster):
__status__ = "testing"
__pattern__ = r'^unmatchable$'
- __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True), #: Overrides pyload.config['general']['folder_per_package']
+ __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True),
("subfolder_per_pack", "bool", "Create a subfolder for each package", True)]
__description__ = """Simple decrypter plugin"""
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 69f88081a..968a80b63 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -22,12 +22,13 @@ statusMap = dict((v, k) for k, v in _statusMap.items())
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.81"
+ __version__ = "1.82"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
- __config__ = [("use_premium", "bool", "Use premium account if available" , True),
- ("fallback" , "bool", "Fallback to free download if premium fails", True)]
+ __config__ = [("use_premium" , "bool", "Use premium account if available" , True),
+ ("premium_fallback", "bool", "Fallback to free download if premium fails", True),
+ ("chk_filesize" , "bool", "Check file size" , True)]
__description__ = """Simple hoster plugin"""
__license__ = "GPLv3"
@@ -294,7 +295,7 @@ class SimpleHoster(Hoster):
self.check_file()
except Fail, e: #@TODO: Move to PluginThread in 0.4.10
- if self.get_config('fallback', True) and self.premium:
+ if self.get_config('premium_fallback', True) and self.premium:
self.log_warning(_("Premium download failed"), e)
self.restart(nopremium=True)
@@ -309,15 +310,16 @@ class SimpleHoster(Hoster):
self.captcha.invalid()
self.retry(10, reason=_("Wrong captcha"))
- # 10485760 is 10MB, tolerance is used when comparing displayed size on the hoster website to real size
- # For example displayed size can be 1.46GB for example, but real size can be 1.4649853GB
elif self.check_download({'Empty file': re.compile(r'\A((.|)(\2|\s)*)\Z')},
- file_size=self.info['size'] if 'size' in self.info else 0,
- size_tolerance=10485760,
- delete=False): #@TODO: Make `delete` settable in 0.4.10
+ delete=True):
self.error(_("Empty file"))
else:
+ if self.get_config('chk_filesize', False) and 'size' in self.info:
+ # 10485760 is 10MB, tolerance is used when comparing displayed size on the hoster website to real size
+ # For example displayed size can be 1.46GB for example, but real size can be 1.4649853GB
+ self.check_filesize(self.info['size'], size_tolerance=10485760)
+
self.log_debug("Using default check rules...")
for r, p in self.FILE_ERRORS:
errmsg = self.check_download({r: re.compile(p)})
@@ -340,7 +342,7 @@ class SimpleHoster(Hoster):
self.check_errors()
self.log_info(_("No errors found"))
- self.pyfile.error = ""
+ self.pyfile.error = "" #@TODO: Recheck in 0.4.10
def check_errors(self):