summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-10 12:24:47 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-10 12:24:47 +0200
commit491dc6943323232f3d06003c950718c89316616d (patch)
tree9a7b3b890ce8815835378deb12e36dc40924958e
parent[Addon] Persistent self.info (diff)
downloadpyload-491dc6943323232f3d06003c950718c89316616d.tar.xz
Spare code cosmetics
-rw-r--r--module/plugins/crypter/EmbeduploadCom.py2
-rw-r--r--module/plugins/crypter/SafelinkingNet.py2
-rw-r--r--module/plugins/crypter/ShSt.py2
-rw-r--r--module/plugins/crypter/XupPl.py2
-rw-r--r--module/plugins/hooks/ExtractArchive.py16
-rw-r--r--module/plugins/hoster/BitshareCom.py2
-rw-r--r--module/plugins/hoster/DlFreeFr.py8
-rw-r--r--module/plugins/hoster/FreeWayMe.py4
-rw-r--r--module/plugins/hoster/OneFichierCom.py2
-rw-r--r--module/plugins/hoster/SmoozedCom.py2
-rw-r--r--module/plugins/internal/Base.py11
-rw-r--r--module/plugins/internal/SimpleCrypter.py12
-rw-r--r--module/plugins/internal/XFSCrypter.py6
-rw-r--r--module/plugins/internal/XFSHoster.py2
14 files changed, 33 insertions, 40 deletions
diff --git a/module/plugins/crypter/EmbeduploadCom.py b/module/plugins/crypter/EmbeduploadCom.py
index e4a9387ae..957e1efb2 100644
--- a/module/plugins/crypter/EmbeduploadCom.py
+++ b/module/plugins/crypter/EmbeduploadCom.py
@@ -55,7 +55,7 @@ class EmbeduploadCom(Crypter):
try:
header = self.load(link, just_header=True)
if 'location' in header:
- new_links.append(header['location'])
+ new_links.append(header.get('location'))
except BadHeader:
pass
return new_links
diff --git a/module/plugins/crypter/SafelinkingNet.py b/module/plugins/crypter/SafelinkingNet.py
index c5fac837a..a11ae2cd8 100644
--- a/module/plugins/crypter/SafelinkingNet.py
+++ b/module/plugins/crypter/SafelinkingNet.py
@@ -34,7 +34,7 @@ class SafelinkingNet(Crypter):
header = self.load(url, just_header=True)
if 'location' in header:
- self.urls = [header['location']]
+ self.urls = [header.get('location')]
else:
self.error(_("Couldn't find forwarded Link"))
diff --git a/module/plugins/crypter/ShSt.py b/module/plugins/crypter/ShSt.py
index 43cc4e779..429d3f3e2 100644
--- a/module/plugins/crypter/ShSt.py
+++ b/module/plugins/crypter/ShSt.py
@@ -27,5 +27,5 @@ class ShSt(Crypter):
self.req.http.c.setopt(pycurl.USERAGENT, "curl/7.42.1")
#: Fetch the target URL
header = self.load(self.pyfile.url, just_header = True, decode = False)
- target_url = header['location']
+ target_url = header.get('location')
self.urls.append(target_url)
diff --git a/module/plugins/crypter/XupPl.py b/module/plugins/crypter/XupPl.py
index ac918a6de..458372d13 100644
--- a/module/plugins/crypter/XupPl.py
+++ b/module/plugins/crypter/XupPl.py
@@ -21,6 +21,6 @@ class XupPl(Crypter):
def decrypt(self, pyfile):
header = self.load(pyfile.url, just_header=True)
if 'location' in header:
- self.urls = [header['location']]
+ self.urls = [header.get('location')]
else:
self.fail(_("Unable to find link"))
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index 47ed708be..034a4b81a 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -63,23 +63,15 @@ class ArchiveQueue(object):
def get(self):
- try:
- return [int(pid) for pid in self.plugin.retrieve("ExtractArchive:%s" % self.storage, "").decode('base64').split()]
-
- except Exception:
- return []
+ return self.plugin.retrieve(self.storage, default=[])
def set(self, value):
- if isinstance(value, list):
- item = str(value)[1:-1].replace(' ', '').replace(',', ' ')
- else:
- item = str(value).strip()
- return self.plugin.store("ExtractArchive:%s" % self.storage, item.encode('base64')[:-1])
+ return self.plugin.store(self.storage, value)
def delete(self):
- return self.plugin.delete("ExtractArchive:%s" % self.storage)
+ return self.plugin.delete(self.storage)
def add(self, item):
@@ -107,7 +99,7 @@ class ArchiveQueue(object):
class ExtractArchive(Addon):
__name__ = "ExtractArchive"
__type__ = "hook"
- __version__ = "1.51"
+ __version__ = "1.52"
__status__ = "testing"
__config__ = [("activated" , "bool" , "Activated" , True ),
diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py
index e426de092..5b9abe7cc 100644
--- a/module/plugins/hoster/BitshareCom.py
+++ b/module/plugins/hoster/BitshareCom.py
@@ -84,7 +84,7 @@ class BitshareCom(SimpleHoster):
if self.premium:
header = self.load(self.pyfile.url, just_header=True)
if 'location' in header:
- return header['location']
+ return header.get('location')
#: Get download info
self.log_debug("Getting download info")
diff --git a/module/plugins/hoster/DlFreeFr.py b/module/plugins/hoster/DlFreeFr.py
index f77b9596a..6c094636e 100644
--- a/module/plugins/hoster/DlFreeFr.py
+++ b/module/plugins/hoster/DlFreeFr.py
@@ -125,12 +125,14 @@ class DlFreeFr(SimpleHoster):
value = value.strip()
if key in header:
- if type(header[key]) is list:
- header[key].append(value)
+ header_key = header.get(key)
+ if type(header_key) is list:
+ header_key.append(value)
else:
- header[key] = [header[key], value]
+ header[key] = [header_key, value]
else:
header[key] = value
+
return header
diff --git a/module/plugins/hoster/FreeWayMe.py b/module/plugins/hoster/FreeWayMe.py
index c0053fc76..501b544c6 100644
--- a/module/plugins/hoster/FreeWayMe.py
+++ b/module/plugins/hoster/FreeWayMe.py
@@ -38,13 +38,13 @@ class FreeWayMe(MultiHoster):
just_header=True)
if 'location' in header:
- headers = self.load(header['location'], just_header=True)
+ headers = self.load(header.get('location'), just_header=True)
if headers['code'] == 500:
#: Error on 2nd stage
self.log_error(_("Error [stage2]"))
else:
#: Seems to work..
- self.download(header['location'])
+ self.download(header.get('location'))
break
else:
#: Error page first stage
diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py
index a8e7f6dc8..6c1d4ab82 100644
--- a/module/plugins/hoster/OneFichierCom.py
+++ b/module/plugins/hoster/OneFichierCom.py
@@ -99,7 +99,7 @@ class OneFichierCom(SimpleHoster):
def handle_free(self, pyfile):
self.check_errors()
- url, inputs = self.parse_html_form('action="https://1fichier.com/\?[a-zA-Z0-9]+')
+ url, inputs = self.parse_html_form('action="https://1fichier.com/\?[\w^_]+')
if not url:
return
diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py
index e864bb2c0..29768d50b 100644
--- a/module/plugins/hoster/SmoozedCom.py
+++ b/module/plugins/hoster/SmoozedCom.py
@@ -59,4 +59,4 @@ class SmoozedCom(MultiHoster):
if not "location" in header:
self.fail(_("Unable to initialize download"))
else:
- self.link = header['location'][-1] if isinstance(header['location'], list) else header['location']
+ self.link = header.get('location')[-1] if isinstance(header.get('location'), list) else header.get('location')
diff --git a/module/plugins/internal/Base.py b/module/plugins/internal/Base.py
index 28b648994..052fc228f 100644
--- a/module/plugins/internal/Base.py
+++ b/module/plugins/internal/Base.py
@@ -463,10 +463,11 @@ class Base(Plugin):
value = value.strip()
if key in header:
- if type(header[key]) is list:
- header[key].append(value)
+ header_key = header.get(key)
+ if type(header_key) is list:
+ header_key.append(value)
else:
- header[key] = [header[key], value]
+ header[key] = [header_key, value]
else:
header[key] = value
@@ -474,7 +475,7 @@ class Base(Plugin):
link = url
elif header.get('location'):
- location = self.fixurl(header['location'], url)
+ location = self.fixurl(header.get('location'), url)
if header.get('code') == 302:
link = location
@@ -487,7 +488,7 @@ class Base(Plugin):
extension = os.path.splitext(parse_name(url))[-1]
if header.get('content-type'):
- mimetype = header['content-type'].split(';')[0].strip()
+ mimetype = header.get('content-type').split(';')[0].strip()
elif extension:
mimetype = mimetypes.guess_type(extension, False)[0] or "application/octet-stream"
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index d4ecd3117..ba4235072 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -10,7 +10,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class SimpleCrypter(Crypter, SimpleHoster):
__name__ = "SimpleCrypter"
__type__ = "crypter"
- __version__ = "0.66"
+ __version__ = "0.67"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -82,20 +82,16 @@ class SimpleCrypter(Crypter, SimpleHoster):
#@TODO: Remove in 0.4.10
def _setup(self):
orig_name = self.__name__
- self.__name__ = (orig_name + ".py").replace("Folder.py", "").replace(".py", "")
-
+ self.__name__ = re.sub(r'Folder$', "", self.__name__)
super(SimpleCrypter, self)._setup()
-
self.__name__ = orig_name
#@TODO: Remove in 0.4.10
def load_account(self):
orig_name = self.__name__
- self.__name__ = (orig_name + ".py").replace("Folder.py", "").replace(".py", "")
-
+ self.__name__ = re.sub(r'Folder$', "", self.__name__)
super(SimpleCrypter, self).load_account()
-
self.__name__ = orig_name
@@ -106,7 +102,7 @@ class SimpleCrypter(Crypter, SimpleHoster):
header = self.load(redirect, just_header=True)
if header.get('location'):
- self.link = header['location']
+ self.link = header.get('location')
else:
break
else:
diff --git a/module/plugins/internal/XFSCrypter.py b/module/plugins/internal/XFSCrypter.py
index dd2fba568..7ec9f3895 100644
--- a/module/plugins/internal/XFSCrypter.py
+++ b/module/plugins/internal/XFSCrypter.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+import re
+
from module.plugins.internal.Plugin import set_cookie
from module.plugins.internal.SimpleCrypter import SimpleCrypter, create_getInfo
@@ -7,7 +9,7 @@ from module.plugins.internal.SimpleCrypter import SimpleCrypter, create_getInfo
class XFSCrypter(SimpleCrypter):
__name__ = "XFSCrypter"
__type__ = "crypter"
- __version__ = "0.17"
+ __version__ = "0.18"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -49,7 +51,7 @@ class XFSCrypter(SimpleCrypter):
if self.account:
account = self.account
else:
- account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "")
+ account_name = re.sub(r'Folder$', "", self.__name__)
account = self.pyload.accountManager.getAccountPlugin(account_name)
if account and hasattr(account, "PLUGIN_DOMAIN") and account.PLUGIN_DOMAIN:
diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py
index 80ef9a977..3373c08d8 100644
--- a/module/plugins/internal/XFSHoster.py
+++ b/module/plugins/internal/XFSHoster.py
@@ -184,7 +184,7 @@ class XFSHoster(SimpleHoster):
header = self.load(m.group(1), just_header=True)
if 'location' in header: #: Direct download link
- self.link = header['location']
+ self.link = header.get('location')
def get_post_parameters(self):