summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/UserAgentSwitcher.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-02 05:46:41 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-02 05:46:41 +0200
commit74be49e90e044ee25c5e7f2898e65d2026c99862 (patch)
treeadc82b90a878c1c3eb5a80999aa9b3b0dba12f88 /module/plugins/hooks/UserAgentSwitcher.py
parentFix https://github.com/pyload/pyload/issues/1442 (diff)
downloadpyload-74be49e90e044ee25c5e7f2898e65d2026c99862.tar.xz
[UserAgentSwitcher] Update
Diffstat (limited to 'module/plugins/hooks/UserAgentSwitcher.py')
-rw-r--r--module/plugins/hooks/UserAgentSwitcher.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py
index 5f9fd5212..74c43f7c4 100644
--- a/module/plugins/hooks/UserAgentSwitcher.py
+++ b/module/plugins/hooks/UserAgentSwitcher.py
@@ -8,10 +8,12 @@ from module.plugins.Hook import Hook
class UserAgentSwitcher(Hook):
__name__ = "UserAgentSwitcher"
__type__ = "hook"
- __version__ = "0.07"
+ __version__ = "0.08"
- __config__ = [("activated", "bool", "Activated" , True ),
- ("useragent", "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0")]
+ __config__ = [("activated" , "bool", "Activated" , True ),
+ ("connecttimeout", "int" , "Connection timeout in seconds" , 60 ),
+ ("maxredirs" , "int" , "Maximum number of redirects to follow" , 10 ),
+ ("useragent" , "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0")]
__description__ = """Custom user-agent"""
__license__ = "GPLv3"
@@ -26,7 +28,16 @@ class UserAgentSwitcher(Hook):
def downloadPreparing(self, pyfile):
- useragent = self.getConfig('useragent').encode("utf8", "replace") #@TODO: Remove `encode` in 0.4.10
+ connecttimeout = self.getConfig('connecttimeout')
+ maxredirs = self.getConfig('maxredirs')
+ useragent = self.getConfig('useragent').encode("utf8", "replace") #@TODO: Remove `encode` in 0.4.10
+
+ if connecttimeout:
+ pyfile.plugin.req.http.c.setopt(pycurl.CONNECTTIMEOUT, connecttimeout)
+
+ if maxredirs:
+ pyfile.plugin.req.http.c.setopt(pycurl.MAXREDIRS, maxredirs)
+
if useragent:
self.logDebug("Use custom user-agent string: " + useragent)
pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, useragent)