summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-12-28 16:04:35 +0100
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-12-28 16:04:35 +0100
commit58a00607a64cc26820c8a995f5f7863e2465911d (patch)
tree8d25c0afe8b1115b00ffdc5cda036fb95063ea16 /module
parentSpare code fixes (diff)
downloadpyload-58a00607a64cc26820c8a995f5f7863e2465911d.tar.xz
Spare code fixes (2)
Diffstat (limited to 'module')
-rw-r--r--module/plugins/hooks/AntiVirus.py26
-rw-r--r--module/plugins/hooks/Checksum.py24
-rw-r--r--module/plugins/hooks/ExtractArchive.py52
-rw-r--r--module/plugins/hooks/MergeFiles.py10
-rw-r--r--module/plugins/hooks/UpdateManager.py24
-rw-r--r--module/plugins/hooks/XFileSharing.py10
-rw-r--r--module/plugins/hoster/XDCC.py (renamed from module/plugins/hoster/Xdcc.py)2
-rw-r--r--module/plugins/internal/MultiAccount.py251
-rw-r--r--module/plugins/internal/Plugin.py5
-rw-r--r--module/plugins/internal/misc.py8
10 files changed, 85 insertions, 327 deletions
diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py
index 049e92ab8..55b883684 100644
--- a/module/plugins/hooks/AntiVirus.py
+++ b/module/plugins/hooks/AntiVirus.py
@@ -10,13 +10,13 @@ except ImportError:
pass
from module.plugins.internal.Addon import Addon, Expose, threaded
-from module.plugins.internal.utils import encode, exists, fs_join
+from module.plugins.internal.misc import encode, exists, fsjoin
class AntiVirus(Addon):
__name__ = "AntiVirus"
__type__ = "hook"
- __version__ = "0.15"
+ __version__ = "0.16"
__status__ = "testing"
#@TODO: add trash option (use Send2Trash lib)
@@ -38,18 +38,18 @@ class AntiVirus(Addon):
@Expose
@threaded
def scan(self, pyfile, thread):
- avfile = encode(self.get_config('avfile'))
- avargs = encode(self.get_config('avargs').strip())
+ avfile = encode(self.config.get('avfile'))
+ avargs = encode(self.config.get('avargs').strip())
if not os.path.isfile(avfile):
self.fail(_("Antivirus executable not found"))
- scanfolder = self.get_config('avtarget') is "folder"
+ scanfolder = self.config.get('avtarget') is "folder"
if scanfolder:
dl_folder = self.pyload.config.get("general", "download_folder")
package_folder = pyfile.package().folder if self.pyload.config.get("general", "folder_per_package") else ""
- target = fs_join(dl_folder, package_folder, pyfile.name)
+ target = fsjoin(dl_folder, package_folder, pyfile.name)
target_repr = "Folder: " + package_folder or dl_folder
else:
target = encode(pyfile.plugin.last_download)
@@ -75,12 +75,12 @@ class AntiVirus(Addon):
if err:
self.log_warning(target_repr, err)
- if not self.get_config('ignore-err'):
+ if not self.config.get('ignore-err'):
self.log_debug("Delete/Quarantine task aborted due scan error")
return
if p.returncode:
- action = self.get_config('action')
+ action = self.config.get('action')
if scanfolder:
if action is "Antivirus default":
@@ -91,7 +91,7 @@ class AntiVirus(Addon):
try:
if action is "Delete":
- if not self.get_config('deltotrash'):
+ if not self.config.get('deltotrash'):
os.remove(file)
else:
@@ -101,19 +101,19 @@ class AntiVirus(Addon):
except NameError:
self.log_warning(_("Send2Trash lib not found, moving to quarantine instead"))
pyfile.setCustomStatus(_("file moving"))
- shutil.move(file, self.get_config('quardir'))
+ shutil.move(file, self.config.get('quardir'))
except Exception, e:
self.log_warning(_("Unable to move file to trash: %s, moving to quarantine instead") % e.message)
pyfile.setCustomStatus(_("file moving"))
- shutil.move(file, self.get_config('quardir'))
+ shutil.move(file, self.config.get('quardir'))
else:
self.log_debug("Successfully moved file to trash")
elif action is "Quarantine":
pyfile.setCustomStatus(_("file moving"))
- shutil.move(file, self.get_config('quardir'))
+ shutil.move(file, self.config.get('quardir'))
except (IOError, shutil.Error), e:
self.log_error(target_repr, action + " action failed!", e)
@@ -132,5 +132,5 @@ class AntiVirus(Addon):
def download_failed(self, pyfile):
#: Check if pyfile is still "failed", maybe might has been restarted in meantime
- if pyfile.status is 8 and self.get_config('scanfailed'):
+ if pyfile.status is 8 and self.config.get('scanfailed'):
return self.scan(pyfile)
diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py
index cf5ed2147..28fdeafee 100644
--- a/module/plugins/hooks/Checksum.py
+++ b/module/plugins/hooks/Checksum.py
@@ -8,7 +8,7 @@ import re
import zlib
from module.plugins.internal.Addon import Addon
-from module.plugins.internal.utils import encode, fs_join
+from module.plugins.internal.misc import encode, fsjoin
def compute_checksum(local_file, algorithm):
@@ -38,7 +38,7 @@ def compute_checksum(local_file, algorithm):
class Checksum(Addon):
__name__ = "Checksum"
__type__ = "hook"
- __version__ = "0.23"
+ __version__ = "0.24"
__status__ = "testing"
__config__ = [("activated" , "bool" , "Activated" , False ),
@@ -65,7 +65,7 @@ class Checksum(Addon):
def activate(self):
- if not self.get_config('check_checksum'):
+ if not self.config.get('check_checksum'):
self.log_info(_("Checksum validation is disabled in plugin configuration"))
@@ -105,7 +105,7 @@ class Checksum(Addon):
local_file = encode(pyfile.plugin.last_download)
# dl_folder = self.pyload.config.get("general", "download_folder")
- # local_file = encode(fs_join(dl_folder, pyfile.package().folder, pyfile.name))
+ # local_file = encode(fsjoin(dl_folder, pyfile.package().folder, pyfile.name))
if not os.path.isfile(local_file):
self.check_failed(pyfile, None, "File does not exist")
@@ -122,7 +122,7 @@ class Checksum(Addon):
data.pop('size', None)
#: Validate checksum
- if data and self.get_config('check_checksum'):
+ if data and self.config.get('check_checksum'):
if not 'md5' in data:
for type in ("checksum", "hashsum", "hash"):
@@ -149,14 +149,14 @@ class Checksum(Addon):
def check_failed(self, pyfile, local_file, msg):
- check_action = self.get_config('check_action')
+ check_action = self.config.get('check_action')
if check_action == "retry":
- max_tries = self.get_config('max_tries')
- retry_action = self.get_config('retry_action')
+ max_tries = self.config.get('max_tries')
+ retry_action = self.config.get('retry_action')
if pyfile.plugin.retries < max_tries:
if local_file:
os.remove(local_file)
- pyfile.plugin.retry(max_tries, self.get_config('wait_time'), msg)
+ pyfile.plugin.retry(max_tries, self.config.get('wait_time'), msg)
elif retry_action == "nothing":
return
elif check_action == "nothing":
@@ -166,7 +166,7 @@ class Checksum(Addon):
def package_finished(self, pypack):
- dl_folder = fs_join(self.pyload.config.get("general", "download_folder"), pypack.folder, "")
+ dl_folder = fsjoin(self.pyload.config.get("general", "download_folder"), pypack.folder, "")
for link in pypack.getChildren().values():
file_type = os.path.splitext(link['name'])[1][1:].lower()
@@ -174,7 +174,7 @@ class Checksum(Addon):
if file_type not in self.formats:
continue
- hash_file = encode(fs_join(dl_folder, link['name']))
+ hash_file = encode(fsjoin(dl_folder, link['name']))
if not os.path.isfile(hash_file):
self.log_warning(_("File not found"), link['name'])
continue
@@ -186,7 +186,7 @@ class Checksum(Addon):
data = m.groupdict()
self.log_debug(link['name'], data)
- local_file = encode(fs_join(dl_folder, data['NAME']))
+ local_file = encode(fsjoin(dl_folder, data['NAME']))
algorithm = self.methods.get(file_type, file_type)
checksum = compute_checksum(local_file, algorithm)
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index c001000c8..96c8d7ed3 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -51,7 +51,7 @@ except ImportError:
from module.plugins.internal.Addon import Addon, Expose, threaded
from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError
-from module.plugins.internal.utils import encode, exists, fs_join, replace_patterns, uniqify
+from module.plugins.internal.misc import encode, exists, fsjoin, replace_patterns, uniqify
class ArchiveQueue(object):
@@ -98,7 +98,7 @@ class ArchiveQueue(object):
class ExtractArchive(Addon):
__name__ = "ExtractArchive"
__type__ = "hook"
- __version__ = "1.53"
+ __version__ = "1.54"
__status__ = "testing"
__config__ = [("activated" , "bool" , "Activated" , True ),
@@ -149,7 +149,7 @@ class ExtractArchive(Addon):
if klass.find():
self.extractors.append(klass)
if klass.REPAIR:
- self.repair = self.get_config('repair')
+ self.repair = self.config.get('repair')
except OSError, e:
if e.errno == 2:
@@ -206,7 +206,7 @@ class ExtractArchive(Addon):
"""
for id in ids:
self.queue.add(id)
- if not self.get_config('waitall') and not self.extracting:
+ if not self.config.get('waitall') and not self.extracting:
self.extract_queued()
@@ -216,13 +216,13 @@ class ExtractArchive(Addon):
def package_finished(self, pypack):
self.queue.add(pypack.id)
- if not self.get_config('waitall') and not self.extracting:
+ if not self.config.get('waitall') and not self.extracting:
self.extract_queued()
def all_downloads_processed(self):
self.last_package = True
- if self.get_config('waitall') and not self.extracting:
+ if self.config.get('waitall') and not self.extracting:
self.extract_queued()
@@ -237,16 +237,16 @@ class ExtractArchive(Addon):
toList = lambda string: string.replace(' ', '').replace(',', '|').replace(';', '|').split('|')
- destination = self.get_config('destination')
- subfolder = self.get_config('subfolder')
- fullpath = self.get_config('fullpath')
- overwrite = self.get_config('overwrite')
- priority = self.get_config('priority')
- recursive = self.get_config('recursive')
- keepbroken = self.get_config('keepbroken')
+ destination = self.config.get('destination')
+ subfolder = self.config.get('subfolder')
+ fullpath = self.config.get('fullpath')
+ overwrite = self.config.get('overwrite')
+ priority = self.config.get('priority')
+ recursive = self.config.get('recursive')
+ keepbroken = self.config.get('keepbroken')
- extensions = [x.lstrip('.').lower() for x in toList(self.get_config('extensions'))]
- excludefiles = toList(self.get_config('excludefiles'))
+ extensions = [x.lstrip('.').lower() for x in toList(self.config.get('extensions'))]
+ excludefiles = toList(self.config.get('excludefiles'))
if extensions:
self.log_debug("Use for extensions: %s" % "|.".join(extensions))
@@ -267,17 +267,17 @@ class ExtractArchive(Addon):
self.log_info(_("Check package: %s") % pypack.name)
#: Determine output folder
- out = fs_join(dl_folder, pypack.folder, destination, "") #: Force trailing slash
+ out = fsjoin(dl_folder, pypack.folder, destination, "") #: Force trailing slash
if subfolder:
- out = fs_join(out, pypack.folder)
+ out = fsjoin(out, pypack.folder)
if not exists(out):
os.makedirs(out)
matched = False
success = True
- files_ids = dict((pylink['name'], ((fs_join(dl_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \
+ files_ids = dict((pylink['name'], ((fsjoin(dl_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \
in sorted(pypack.getChildren().values(), key=lambda k: k['name'])).values() #: Remove duplicates
#: Check as long there are unseen files
@@ -338,7 +338,7 @@ class ExtractArchive(Addon):
self.set_permissions(file)
for filename in new_files:
- file = encode(fs_join(os.path.dirname(archive.filename), filename))
+ file = encode(fsjoin(os.path.dirname(archive.filename), filename))
if not exists(file):
self.log_debug("New file %s does not exists" % filename)
continue
@@ -383,7 +383,7 @@ class ExtractArchive(Addon):
encrypted = False
try:
self.log_debug("Password: %s" % (password or "None provided"))
- passwords = uniqify([password] + self.get_passwords(False)) if self.get_config('usepasswordfile') else [password]
+ passwords = uniqify([password] + self.get_passwords(False)) if self.config.get('usepasswordfile') else [password]
for pw in passwords:
try:
pyfile.setCustomStatus(_("archive testing"))
@@ -410,7 +410,7 @@ class ExtractArchive(Addon):
repaired = archive.repair()
pyfile.setProgress(100)
- if not repaired and not self.get_config('keepbroken'):
+ if not repaired and not self.config.get('keepbroken'):
raise CRCError("Archive damaged")
else:
@@ -427,7 +427,7 @@ class ExtractArchive(Addon):
pyfile.setCustomStatus(_("archive extracting"))
pyfile.setProgress(0)
- if not encrypted or not self.get_config('usepasswordfile'):
+ if not encrypted or not self.config.get('usepasswordfile'):
self.log_debug("Extracting using password: %s" % (password or "None"))
archive.extract(password)
else:
@@ -450,10 +450,10 @@ class ExtractArchive(Addon):
delfiles = archive.items()
self.log_debug("Would delete: " + ", ".join(delfiles))
- if self.get_config('delete'):
+ if self.config.get('delete'):
self.log_info(_("Deleting %s files") % len(delfiles))
- deltotrash = self.get_config('deltotrash')
+ deltotrash = self.config.get('deltotrash')
for f in delfiles:
file = encode(f)
if not exists(file):
@@ -523,7 +523,7 @@ class ExtractArchive(Addon):
try:
passwords = []
- file = encode(self.get_config('passwordfile'))
+ file = encode(self.config.get('passwordfile'))
with open(file) as f:
for pw in f.read().splitlines():
passwords.append(pw)
@@ -552,7 +552,7 @@ class ExtractArchive(Addon):
try:
self.passwords = uniqify([password] + self.passwords)
- file = encode(self.get_config('passwordfile'))
+ file = encode(self.config.get('passwordfile'))
with open(file, "wb") as f:
for pw in self.passwords:
f.write(pw + '\n')
diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py
index dbe7b1f5f..963f8c15b 100644
--- a/module/plugins/hooks/MergeFiles.py
+++ b/module/plugins/hooks/MergeFiles.py
@@ -6,13 +6,13 @@ import os
import re
from module.plugins.internal.Addon import Addon, threaded
-from module.plugins.internal.utils import fs_join
+from module.plugins.internal.misc import fsjoin
class MergeFiles(Addon):
__name__ = "MergeFiles"
__type__ = "hook"
- __version__ = "0.18"
+ __version__ = "0.19"
__status__ = "testing"
__config__ = [("activated", "bool", "Activated", True)]
@@ -40,12 +40,12 @@ class MergeFiles(Addon):
dl_folder = self.pyload.config.get("general", "download_folder")
if self.pyload.config.get("general", "folder_per_package"):
- dl_folder = fs_join(dl_folder, pack.folder)
+ dl_folder = fsjoin(dl_folder, pack.folder)
for name, file_list in files.items():
self.log_info(_("Starting merging of"), name)
- with open(fs_join(dl_folder, name), "wb") as final_file:
+ with open(fsjoin(dl_folder, name), "wb") as final_file:
for splitted_file in file_list:
self.log_debug("Merging part", splitted_file)
@@ -54,7 +54,7 @@ class MergeFiles(Addon):
pyfile.setStatus("processing")
try:
- with open(fs_join(dl_folder, splitted_file), "rb") as s_file:
+ with open(fsjoin(dl_folder, splitted_file), "rb") as s_file:
size_written = 0
s_file_size = int(os.path.getsize(os.path.join(dl_folder, splitted_file)))
while True:
diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py
index e235b0e47..cf36a6d40 100644
--- a/module/plugins/hooks/UpdateManager.py
+++ b/module/plugins/hooks/UpdateManager.py
@@ -9,13 +9,13 @@ import sys
import time
from module.plugins.internal.Addon import Expose, Addon, threaded
-from module.plugins.internal.utils import encode, exists, fs_join
+from module.plugins.internal.misc import encode, exists, fsjoin
class UpdateManager(Addon):
__name__ = "UpdateManager"
__type__ = "hook"
- __version__ = "1.04"
+ __version__ = "1.05"
__status__ = "testing"
__config__ = [("activated" , "bool", "Activated" , True ),
@@ -45,7 +45,7 @@ class UpdateManager(Addon):
if self.do_restart is False:
self.pyload.api.unpauseServer()
- self.start_periodical(10)
+ self.periodical.start(10)
def init(self):
@@ -53,7 +53,7 @@ class UpdateManager(Addon):
self.mtimes = {} #: Store modification time for each plugin
self.event_map = {'allDownloadsProcessed': "all_downloads_processed"}
- if self.get_config('checkonstart'):
+ if self.config.get('checkonstart'):
self.pyload.api.pauseServer()
self.checkonstart = True
else:
@@ -67,16 +67,16 @@ class UpdateManager(Addon):
self.pyload.api.restart()
- def periodical(self):
+ def periodical_task(self):
if self.pyload.debug:
- if self.get_config('reloadplugins'):
+ if self.config.get('reloadplugins'):
self.autoreload_plugins()
- if self.get_config('nodebugupdate'):
+ if self.config.get('nodebugupdate'):
return
- if self.get_config('checkperiod') and \
- time.time() - max(self.CHECK_INTERVAL, self.get_config('checkinterval') * 60 * 60) > self.info['last_check']:
+ if self.config.get('checkperiod') and \
+ time.time() - max(self.CHECK_INTERVAL, self.config.get('checkinterval') * 60 * 60) > self.info['last_check']:
self.update()
@@ -146,7 +146,7 @@ class UpdateManager(Addon):
"""
Check for updates
"""
- if self._update() is not 2 or not self.get_config('autorestart'):
+ if self._update() is not 2 or not self.config.get('autorestart'):
return
if not self.pyload.api.statusDownloads():
@@ -304,7 +304,7 @@ class UpdateManager(Addon):
m = self._VERSION.search(content)
if m and m.group(2) == plugin_version:
- with open(fs_join("userplugins", plugin_type, plugin_name + ".py"), "wb") as f:
+ with open(fsjoin("userplugins", plugin_type, plugin_name + ".py"), "wb") as f:
f.write(encode(content))
updated.append((plugin_type, plugin_name))
@@ -342,7 +342,7 @@ class UpdateManager(Addon):
rootplugins = os.path.join(pypath, "module", "plugins")
for basedir in ("userplugins", rootplugins):
- py_filename = fs_join(basedir, plugin_type, plugin_name + ".py")
+ py_filename = fsjoin(basedir, plugin_type, plugin_name + ".py")
pyc_filename = py_filename + "c"
if plugin_type is "hook":
diff --git a/module/plugins/hooks/XFileSharing.py b/module/plugins/hooks/XFileSharing.py
index e2f25e13f..201cbab53 100644
--- a/module/plugins/hooks/XFileSharing.py
+++ b/module/plugins/hooks/XFileSharing.py
@@ -9,7 +9,7 @@ from module.plugins.internal.Addon import Addon
class XFileSharing(Addon):
__name__ = "XFileSharing"
__type__ = "hook"
- __version__ = "0.53"
+ __version__ = "0.54"
__status__ = "testing"
__config__ = [("activated" , "bool", "Activated" , True ),
@@ -91,7 +91,13 @@ class XFileSharing(Addon):
isXFS = lambda klass: any(k.__name__.startswith("XFS") for k in inspect.getmro(klass))
for p in self.pyload.pluginManager.plugins[type].values():
- klass = self.pyload.pluginManager.loadClass(type, p['name'])
+ try:
+ klass = self.pyload.pluginManager.loadClass(type, p['name'])
+
+ except AttributeError, e:
+ self.log_debug(e, trace=True)
+ continue
+
if hasattr(klass, "PLUGIN_DOMAIN") and klass.PLUGIN_DOMAIN and isXFS(klass):
plugin_list.append(klass.PLUGIN_DOMAIN)
diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/XDCC.py
index 4e29e2ea9..3985a050c 100644
--- a/module/plugins/hoster/Xdcc.py
+++ b/module/plugins/hoster/XDCC.py
@@ -14,7 +14,7 @@ from module.plugins.internal.misc import fsjoin
class XDCC(Hoster):
__name__ = "XDCC"
__type__ = "hoster"
- __version__ = "0.37"
+ __version__ = "0.38"
__status__ = "testing"
__config__ = [("nick", "str", "Nickname", "pyload"),
diff --git a/module/plugins/internal/MultiAccount.py b/module/plugins/internal/MultiAccount.py
index f9252cc10..90cb0e748 100644
--- a/module/plugins/internal/MultiAccount.py
+++ b/module/plugins/internal/MultiAccount.py
@@ -1,16 +1,12 @@
# -*- coding: utf-8 -*-
-import re
-import time
-
from module.plugins.internal.Account import Account
-from module.plugins.internal.utils import decode, remove_chars, uniqify
class MultiAccount(Account):
__name__ = "MultiAccount"
__type__ = "account"
- __version__ = "0.04"
+ __version__ = "0.05"
__status__ = "broken"
__config__ = [("activated" , "bool" , "Activated" , True ),
@@ -22,248 +18,3 @@ class MultiAccount(Account):
__description__ = """Multi-hoster account plugin"""
__license__ = "GPLv3"
__authors__ = [("Walter Purcaro", "vuolter@gmail.com")]
-
-
- # PERIODICAL_INTERVAL = 1 * 60 * 60 #: 1 hour
- PERIODICAL_LOGIN = False
-
- DOMAIN_REPLACEMENTS = [(r'180upload\.com' , "hundredeightyupload.com"),
- (r'bayfiles\.net' , "bayfiles.com" ),
- (r'cloudnator\.com' , "shragle.com" ),
- (r'dfiles\.eu' , "depositfiles.com" ),
- (r'easy-share\.com' , "crocko.com" ),
- (r'freakshare\.net' , "freakshare.com" ),
- (r'hellshare\.com' , "hellshare.cz" ),
- (r'ifile\.it' , "filecloud.io" ),
- (r'nowdownload\.\w+', "nowdownload.sx" ),
- (r'nowvideo\.\w+' , "nowvideo.sx" ),
- (r'putlocker\.com' , "firedrive.com" ),
- (r'share-?rapid\.cz', "multishare.cz" ),
- (r'ul\.to' , "uploaded.to" ),
- (r'uploaded\.net' , "uploaded.to" ),
- (r'uploadhero\.co' , "uploadhero.com" ),
- (r'zshares\.net' , "zshare.net" ),
- (r'^1' , "one" ),
- (r'^2' , "two" ),
- (r'^3' , "three" ),
- (r'^4' , "four" ),
- (r'^5' , "five" ),
- (r'^6' , "six" ),
- (r'^7' , "seven" ),
- (r'^8' , "eight" ),
- (r'^9' , "nine" ),
- (r'^0' , "zero" )]
-
-
- def init(self):
- self.plugins = []
- self.supported = []
- self.newsupported = []
-
- self.pluginclass = None
- self.pluginmodule = None
- self.plugintype = None
-
- self.init_plugin()
-
-
- def init_plugin(self):
- plugin, self.plugintype = self.pyload.pluginManager.findPlugin(self.classname)
-
- if plugin:
- self.pluginmodule = self.pyload.pluginManager.loadModule(self.plugintype, self.classname)
- self.pluginclass = self.pyload.pluginManager.loadClass(self.plugintype, self.classname)
- else:
- self.log_warning(_("Multi-hoster feature will be deactivated due missing plugin reference"))
- self.set_config('multi', False)
-
-
- def activate(self):
- interval = self.get_config('multi_interval') * 60 * 60
- self.start_periodical(interval, threaded=True)
-
-
- def replace_domains(self, list):
- for r in self.DOMAIN_REPLACEMENTS:
- pattern, repl = r
- regex = re.compile(pattern, re.I | re.U)
- domains = [regex.sub(repl, domain) if regex.match(domain) else domain for domain in list]
-
- return domains
-
-
- def parse_domains(self, list):
- regexp = re.compile(r'^(?:https?://)?(?:www\.)?(?:\w+\.)*((?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)',
- re.I | re.U)
-
- r'^(?:https?://)?(?:www\.)?(?:\w+\.)*((?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)'
-
- domains = [decode(domain).strip().lower() for url in list for domain in regexp.findall(url)]
- return self.replace_domains(uniqify(domains))
-
-
- def _grab_hosters(self):
- try:
- hosterlist = self.grab_hosters(self.user, self.info['login']['password'], self.info['data'])
-
- if hosterlist and isinstance(hosterlist, list):
- domains = self.parse_domains(hosterlist)
- self.info['data']['hosters'] = sorted(domains)
-
- except Exception, e:
- self.log_warning(_("Error loading hoster list for user `%s`") % self.user, e, trace=True)
-
- finally:
- return self.info['data']['hosters']
-
-
- def grab_hosters(self, user, password, data):
- """
- Load list of supported hoster
- :return: List of domain names
- """
- raise NotImplementedError
-
-
- def periodical(self):
- if not self.info['data'].get('hosters'):
- self.log_info(_("Loading hoster list for user `%s`...") % self.user)
- else:
- self.log_info(_("Reloading hoster list for user `%s`...") % self.user)
-
- if self.PERIODICAL_LOGIN and not self.logged:
- self.relogin()
-
- hosters = self._grab_hosters()
-
- self.log_debug("Hoster list for user `%s`: %s" % (self.user, hosters))
-
- old_supported = self.supported
-
- self.supported = []
- self.newsupported = []
- self.plugins = []
-
- self._override()
-
- old_supported = [plugin for plugin in old_supported if plugin not in self.supported]
-
- if old_supported:
- self.log_debug("Unload: %s" % ", ".join(old_supported))
- for plugin in old_supported:
- self.unload_plugin(plugin)
-
- self.set_interval(self.get_config('multi_interval') * 60 * 60)
-
-
- def _override(self):
- excludedList = []
-
- if self.plugintype == "hoster":
- pluginMap = dict((name.lower(), name) for name in self.pyload.pluginManager.hosterPlugins.keys())
- accountList = [account.type.lower() for account in self.pyload.api.getAccounts(False) if account.valid and account.premium]
- else:
- pluginMap = {}
- accountList = [name[::-1].replace("Folder"[::-1], "", 1).lower()[::-1] for name in self.pyload.pluginManager.crypterPlugins.keys()]
-
- for plugin in self.plugins_cached():
- name = remove_chars(plugin, "-.")
-
- if name in accountList:
- excludedList.append(plugin)
- else:
- if name in pluginMap:
- self.supported.append(pluginMap[name])
- else:
- self.newsupported.append(plugin)
-
- if not self.supported and not self.newsupported:
- self.log_error(_("No %s loaded") % self.plugintype)
- return
-
- #: Inject plugin plugin
- self.log_debug("Overwritten %ss: %s" % (self.plugintype, ", ".join(sorted(self.supported))))
-
- for plugin in self.supported:
- hdict = self.pyload.pluginManager.plugins[self.plugintype][plugin]
- hdict['new_module'] = self.pluginmodule
- hdict['new_name'] = self.classname
-
- if excludedList:
- self.log_info(_("%ss not overwritten: %s") % (self.plugintype.capitalize(), ", ".join(sorted(excludedList))))
-
- if self.newsupported:
- plugins = sorted(self.newsupported)
-
- self.log_debug("New %ss: %s" % (self.plugintype, ", ".join(plugins)))
-
- #: Create new regexp
- regexp = r'.*(?P<DOMAIN>%s).*' % "|".join(x.replace('.', '\.') for x in plugins)
- if hasattr(self.pluginclass, "__pattern__") and isinstance(self.pluginclass.__pattern__, basestring) and "://" in self.pluginclass.__pattern__:
- regexp = r'%s|%s' % (self.pluginclass.__pattern__, regexp)
-
- self.log_debug("Regexp: %s" % regexp)
-
- hdict = self.pyload.pluginManager.plugins[self.plugintype][self.classname]
- hdict['pattern'] = regexp
- hdict['re'] = re.compile(regexp)
-
-
- def plugins_cached(self):
- if self.plugins:
- return self.plugins
-
- for _i in xrange(5):
- try:
- pluginset = self._plugin_set(self.grab_hosters())
- break
-
- except Exception, e:
- self.log_warning(e, _("Waiting 1 minute and retry"), trace=True)
- time.sleep(60)
- else:
- self.log_warning(_("No hoster list retrieved"))
- self.interval = self.PERIODICAL_INTERVAL
- return list()
-
- try:
- configmode = self.get_config('pluginmode', 'all')
- if configmode in ("listed", "unlisted"):
- pluginlist = self.get_config('pluginlist', '').replace('|', ',').replace(';', ',').split(',')
- configset = self._plugin_set(pluginlist)
-
- if configmode == "listed":
- pluginset &= configset
- else:
- pluginset -= configset
-
- except Exception, e:
- self.log_error(e)
-
- self.plugins = list(pluginset)
-
- return self.plugins
-
-
- # def unload_plugin(self, plugin):
- # hdict = self.pyload.pluginManager.plugins[self.plugintype][plugin]
- # if "module" in hdict:
- # hdict.pop('module', None)
-
- # if "new_module" in hdict:
- # hdict.pop('new_module', None)
- # hdict.pop('new_name', None)
-
-
- # def deactivate(self):
- # """
- # Remove override for all plugins. Scheduler job is removed by hookmanager
- # """
- # for plugin in self.supported:
- # self.unload_plugin(plugin)
-
- #: Reset pattern
- # hdict = self.pyload.pluginManager.plugins[self.plugintype][self.classname]
-
- # hdict['pattern'] = getattr(self.pluginclass, "__pattern__", r'^unmatchable$')
- # hdict['re'] = re.compile(hdict['pattern'])
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index aa6e90db3..79370a975 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -20,13 +20,14 @@ import module.plugins.internal.misc as utils
from module.network.RequestFactory import getRequest as get_request
from module.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload as Skip #@TODO: Remove in 0.4.10
-from module.plugins.internal.misc import Config, DB, decode, encode, fixurl, format_exc, parse_html_header
+from module.plugins.internal.misc import (Config, DB, decode, encode, exists, fixurl, fsjoin,
+ format_exc, html_unescape, parse_html_header)
class Plugin(object):
__name__ = "Plugin"
__type__ = "plugin"
- __version__ = "0.61"
+ __version__ = "0.62"
__status__ = "stable"
__config__ = [] #: [("name", "type", "desc", "default")]
diff --git a/module/plugins/internal/misc.py b/module/plugins/internal/misc.py
index ed5fb8693..2cd843109 100644
--- a/module/plugins/internal/misc.py
+++ b/module/plugins/internal/misc.py
@@ -32,7 +32,7 @@ except ImportError:
class misc(object):
__name__ = "misc"
__type__ = "plugin"
- __version__ = "0.10"
+ __version__ = "0.11"
__status__ = "stable"
__pattern__ = r'^unmatchable$'
@@ -60,7 +60,7 @@ class Config(object):
self.plugin.pyload.api.setConfigValue(self.plugin.classname, option, value, section="plugin")
- def get(self, option, default=""):
+ def get(self, option, default=None):
"""
Returns config value for current plugin
@@ -71,7 +71,7 @@ class Config(object):
return self.plugin.pyload.config.getPlugin(self.plugin.classname, option)
except KeyError:
- self.plugin.log_debug("Config option `%s` not found, use default `%s`" % (option, default or None)) #@TODO: Restore to `log_warning` in 0.4.10
+ self.plugin.log_debug("Config option `%s` not found, use default `%s`" % (option, default)) #@TODO: Restore to `log_warning` in 0.4.10
return default
@@ -698,7 +698,7 @@ def set_cookies(cj, cookies):
set_cookie(cj, *cookie)
-def parse_html_header(self, header):
+def parse_html_header(header):
hdict = {}
regexp = r'[ ]*(?P<key>.+?)[ ]*:[ ]*(?P<value>.+?)[ ]*\r?\n'