summaryrefslogtreecommitdiffstats
path: root/pyload/plugin/addon
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-13 10:21:32 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-13 10:21:32 +0200
commiteca20b701c411046e7ededb0462b310124ce3c18 (patch)
treec5eb36261cfc935f001b816f28f15d1f5afbf7e0 /pyload/plugin/addon
parentMerge branch 'stable' into 0.4.10 (diff)
downloadpyload-eca20b701c411046e7ededb0462b310124ce3c18.tar.xz
Cleanup + fixup + new lib
Diffstat (limited to 'pyload/plugin/addon')
-rw-r--r--pyload/plugin/addon/AntiVirus.py3
-rw-r--r--pyload/plugin/addon/UpdateManager.py4
-rw-r--r--pyload/plugin/addon/UserAgentSwitcher.py44
3 files changed, 46 insertions, 5 deletions
diff --git a/pyload/plugin/addon/AntiVirus.py b/pyload/plugin/addon/AntiVirus.py
index 2213cddc1..6fae3b532 100644
--- a/pyload/plugin/addon/AntiVirus.py
+++ b/pyload/plugin/addon/AntiVirus.py
@@ -27,9 +27,6 @@ class AntiVirus(Addon):
__authors__ = [("Walter Purcaro", "vuolter@gmail.com")]
- interval = 0 #@TODO: Remove in 0.4.10
-
-
def setup(self):
self.info = {} #@TODO: Remove in 0.4.10
diff --git a/pyload/plugin/addon/UpdateManager.py b/pyload/plugin/addon/UpdateManager.py
index c5bee16a1..0837918d3 100644
--- a/pyload/plugin/addon/UpdateManager.py
+++ b/pyload/plugin/addon/UpdateManager.py
@@ -32,7 +32,7 @@ class UpdateManager(Addon):
__type__ = "addon"
__version__ = "0.50"
- __config__ = [("activated", "bool", "Activated", True),
+ __config__ = [("activated", "bool", "Activated", False),
("checkinterval", "int", "Check interval in hours", 8),
("autorestart", "bool",
"Auto-restart pyLoad when required", True),
@@ -83,7 +83,7 @@ class UpdateManager(Addon):
def autoreloadPlugins(self):
""" reload and reindex all modified plugins """
modules = filter(
- lambda m: m and (m.__name__.startswith("module.plugins.") or
+ lambda m: m and (m.__name__.startswith("pyload.plugin.") or
m.__name__.startswith("userplugins.")) and
m.__name__.count(".") >= 2, sys.modules.itervalues()
)
diff --git a/pyload/plugin/addon/UserAgentSwitcher.py b/pyload/plugin/addon/UserAgentSwitcher.py
new file mode 100644
index 000000000..46807da67
--- /dev/null
+++ b/pyload/plugin/addon/UserAgentSwitcher.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import with_statement
+
+import os
+import pycurl
+import random
+
+from pyload.plugin.Addon import Addon
+from pyload.utils import fs_encode
+
+
+class UserAgentSwitcher(Addon):
+ __name__ = "UserAgentSwitcher"
+ __type__ = "addon"
+ __version__ = "0.04"
+
+ __config__ = [("activated", "bool", "Activated" , True ),
+ ("uaf" , "file", "Random user-agents file" , "" ),
+ ("uar" , "bool", "Random user-agent" , False ),
+ ("uas" , "str" , "Custom user-agent string", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0")]
+
+ __description__ = """Custom user-agent"""
+ __license__ = "GPLv3"
+ __authors__ = [("Walter Purcaro", "vuolter@gmail.com")]
+
+
+ def setup(self):
+ self.info = {} #@TODO: Remove in 0.4.10
+
+
+ def downloadPreparing(self, pyfile):
+ uar = self.getConfig('uar')
+ uaf = fs_encode(self.getConfig('uaf'))
+
+ if uar and os.path.isfile(uaf):
+ with open(uaf) as f:
+ uas = random.choice([ua for ua in f.read().splitlines()])
+ else:
+ uas = self.getConfig('uas')
+
+ if uas:
+ self.logDebug("Use custom user-agent string: " + uas)
+ pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, uas.encode('utf-8'))