summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-10 21:17:27 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-10 21:17:27 +0100
commit4747e1d7958c9fb1180da6f3a21f3093220a6655 (patch)
tree9c47a1355158bb2f3ef6a1f723f42634d8a20e6b /module/plugins
parent[RehostTo] Account fixup (diff)
downloadpyload-4747e1d7958c9fb1180da6f3a21f3093220a6655.tar.xz
Code improvements
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/accounts/ZeveraCom.py2
-rw-r--r--module/plugins/hooks/EasybytezCom.py17
-rw-r--r--module/plugins/internal/MultiHook.py49
-rw-r--r--module/plugins/internal/SimpleHoster.py4
4 files changed, 36 insertions, 36 deletions
diff --git a/module/plugins/accounts/ZeveraCom.py b/module/plugins/accounts/ZeveraCom.py
index 8c7ab161e..6c69a974f 100644
--- a/module/plugins/accounts/ZeveraCom.py
+++ b/module/plugins/accounts/ZeveraCom.py
@@ -28,7 +28,7 @@ class ZeveraCom(Account):
if not self.HOSTER_DOMAIN:
self.logError(_("Missing HOSTER_DOMAIN"))
- if not self.API_URL:
+ if not hasattr(self, "API_URL"):
self.API_URL = "http://api.%s/jDownloader.ashx" % (self.HOSTER_DOMAIN or "")
diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py
index c460de7b7..e08127514 100644
--- a/module/plugins/hooks/EasybytezCom.py
+++ b/module/plugins/hooks/EasybytezCom.py
@@ -26,18 +26,7 @@ class EasybytezCom(MultiHook):
def getHosters(self):
user, data = self.account.selectAccount()
- try:
- req = self.account.getAccountRequest(user)
- page = req.load("http://www.easybytez.com")
+ req = self.account.getAccountRequest(user)
+ page = req.load("http://www.easybytez.com")
- hosters = re.search(r'</textarea>\s*Supported sites:(.*)', page).group(1).split(',')
-
- except Exception, e:
- self.logWarning(_("Unable to load supported hoster list, using last known"))
- self.logDebug(e)
-
- hosters = ["bitshare.com", "crocko.com", "ddlstorage.com", "depositfiles.com", "extabit.com", "hotfile.com",
- "mediafire.com", "netload.in", "rapidgator.net", "rapidshare.com", "uploading.com", "uload.to",
- "uploaded.to"]
- finally:
- return hosters
+ return re.search(r'</textarea>\s*Supported sites:(.*)', page).group(1).split(',')
diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py
index 8bf72f21b..a3b266679 100644
--- a/module/plugins/internal/MultiHook.py
+++ b/module/plugins/internal/MultiHook.py
@@ -2,6 +2,8 @@
import re
+from time import sleep
+
from module.plugins.Hook import Hook
from module.utils import decode, remove_chars
@@ -9,7 +11,7 @@ from module.utils import decode, remove_chars
class MultiHook(Hook):
__name__ = "MultiHook"
__type__ = "hook"
- __version__ = "0.34"
+ __version__ = "0.35"
__config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"),
("pluginlist" , "str" , "Plugin list (comma separated)" , "" ),
@@ -114,34 +116,43 @@ class MultiHook(Hook):
def pluginsCached(self):
- if not self.plugins:
+ if self.plugins:
+ return self.plugins
+
+ for _i in xrange(3):
try:
pluginset = self._pluginSet(self.getHosters() if self.plugintype == "hoster" else self.getCrypters())
+
except Exception, e:
- self.logError(e)
- return []
+ self.logError(e, "Waiting 1 minute and retry")
+ sleep(60)
+
+ else:
+ break
+ else:
+ return list()
- try:
- configmode = self.getConfig("pluginmode", 'all')
- if configmode in ("listed", "unlisted"):
- pluginlist = self.getConfig("pluginlist", '').replace('|', ',').replace(';', ',').split(',')
- configset = self._pluginSet(pluginlist)
+ try:
+ configmode = self.getConfig("pluginmode", 'all')
+ if configmode in ("listed", "unlisted"):
+ pluginlist = self.getConfig("pluginlist", '').replace('|', ',').replace(';', ',').split(',')
+ configset = self._pluginSet(pluginlist)
- if configmode == "listed":
- pluginset &= configset
- else:
- pluginset -= configset
+ if configmode == "listed":
+ pluginset &= configset
+ else:
+ pluginset -= configset
- except Exception, e:
- self.logError(e)
+ except Exception, e:
+ self.logError(e)
- self.plugins = list(pluginset)
+ self.plugins = list(pluginset)
return self.plugins
def _pluginSet(self, plugins):
- plugins = set((decode(x).strip().lower() for x in plugins))
+ plugins = set((decode(x).strip().lower() for x in plugins if '.' in x))
for rf, rt in self.DOMAIN_REPLACEMENTS:
regex = re.compile(rf)
@@ -238,7 +249,7 @@ class MultiHook(Hook):
self.logDebug("New %ss: %s" % (self.plugintype, ", ".join(plugins)))
# create new regexp
- regexp = r'.*(%s).*' % "|".join([x.replace(".", "\.") for x in plugins])
+ 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)
@@ -287,7 +298,7 @@ class MultiHook(Hook):
wait_time = max(self.getConfig("retryinterval", 1), 0)
if 0 < retries > pyfile.plugin.retries:
+ pyfile.setCustomStatus("MultiHook", "queued")
pyfile.plugin.retries += 1
- pyfile.plugin.setCustomStatus("MultiHook", "queued")
pyfile.plugin.setWait(wait_time)
pyfile.plugin.wait()
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index fb19b8725..5a32ac943 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -183,7 +183,7 @@ def secondsToMidnight(gmt=0):
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "0.93"
+ __version__ = "0.94"
__pattern__ = r'^unmatchable$'
@@ -441,7 +441,7 @@ class SimpleHoster(Hoster):
elif not self.lastDownload or not exists(fs_encode(self.lastDownload)):
self.lastDownload = ""
- self.fail(errmsg, self.pyfile.error or _("No file downloaded"))
+ self.fail(self.pyfile.error or _("No file downloaded"))
else:
rules = {'empty file': re.compile(r'\A\Z'),