summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/UserAgentSwitcher.py
diff options
context:
space:
mode:
authorGravatar sraedler <simon.raedler@yahoo.de> 2015-04-08 01:58:10 +0200
committerGravatar sraedler <simon.raedler@yahoo.de> 2015-04-08 01:58:10 +0200
commita59784a64f8afdca1642a0e53a396548a8608d61 (patch)
treea7eb9914bbc55bbc46f5a5f6929c6c6c95c81244 /module/plugins/hooks/UserAgentSwitcher.py
parentFixed RemixshareCom (diff)
parent[ExtractArchive] Fix https://github.com/pyload/pyload/issues/1322 (diff)
downloadpyload-a59784a64f8afdca1642a0e53a396548a8608d61.tar.xz
Merge pull request #1 from pyload/stable
merge with base
Diffstat (limited to 'module/plugins/hooks/UserAgentSwitcher.py')
-rw-r--r--module/plugins/hooks/UserAgentSwitcher.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py
new file mode 100644
index 000000000..31eac9820
--- /dev/null
+++ b/module/plugins/hooks/UserAgentSwitcher.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+
+import pycurl
+
+from module.plugins.Hook import Hook
+
+
+class UserAgentSwitcher(Hook):
+ __name__ = "UserAgentSwitcher"
+ __type__ = "hook"
+ __version__ = "0.02"
+
+ __config__ = [("activated", "bool", "Activated" , True ),
+ ("ua" , "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")]
+
+
+ interval = 0 #@TODO: Remove in 0.4.10
+
+
+ def setup(self):
+ self.info = {} #@TODO: Remove in 0.4.10
+
+
+ def downloadPreparing(self, pyfile):
+ ua = self.getConfig('ua')
+ if ua:
+ self.logDebug("Use custom user-agent string: " + ua)
+ pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, ua)