From 74be49e90e044ee25c5e7f2898e65d2026c99862 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 2 Jun 2015 05:46:41 +0200 Subject: [UserAgentSwitcher] Update --- module/plugins/hooks/UserAgentSwitcher.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/UserAgentSwitcher.py') 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) -- cgit v1.2.3 From 0e1ef9bc01579328e17e79416fa3c1c7b77adcc8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 8 Jun 2015 06:08:01 +0200 Subject: Update everything --- module/plugins/hooks/UserAgentSwitcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/UserAgentSwitcher.py') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 74c43f7c4..0637936f9 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -2,13 +2,13 @@ import pycurl -from module.plugins.Hook import Hook +from module.plugins.internal.Hook import Hook class UserAgentSwitcher(Hook): __name__ = "UserAgentSwitcher" __type__ = "hook" - __version__ = "0.08" + __version__ = "0.09" __config__ = [("activated" , "bool", "Activated" , True ), ("connecttimeout", "int" , "Connection timeout in seconds" , 60 ), -- cgit v1.2.3 From 5a139055ae658d3a05cbb658cbd66aeae0d01db5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 15 Jun 2015 21:06:10 +0200 Subject: Spare code cosmetics --- module/plugins/hooks/UserAgentSwitcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/UserAgentSwitcher.py') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 0637936f9..0504ec9d0 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -27,7 +27,7 @@ class UserAgentSwitcher(Hook): self.info = {} #@TODO: Remove in 0.4.10 - def downloadPreparing(self, pyfile): + def download_preparing(self, pyfile): connecttimeout = self.getConfig('connecttimeout') maxredirs = self.getConfig('maxredirs') useragent = self.getConfig('useragent').encode("utf8", "replace") #@TODO: Remove `encode` in 0.4.10 -- cgit v1.2.3 From c1764e2fea0bb05164c83a876e8cd58b97f58f25 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Jun 2015 17:31:38 +0200 Subject: Update all --- module/plugins/hooks/UserAgentSwitcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/UserAgentSwitcher.py') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 0504ec9d0..ea2d84a43 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -30,7 +30,7 @@ class UserAgentSwitcher(Hook): def download_preparing(self, pyfile): connecttimeout = self.getConfig('connecttimeout') maxredirs = self.getConfig('maxredirs') - useragent = self.getConfig('useragent').encode("utf8", "replace") #@TODO: Remove `encode` in 0.4.10 + useragent = self.getConfig('useragent') if connecttimeout: pyfile.plugin.req.http.c.setopt(pycurl.CONNECTTIMEOUT, connecttimeout) -- cgit v1.2.3 From b1759bc440cd6013837697eb8de540914f693ffd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Jul 2015 01:23:55 +0200 Subject: No camelCase style anymore --- module/plugins/hooks/UserAgentSwitcher.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks/UserAgentSwitcher.py') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index ea2d84a43..fdfe4b673 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -8,7 +8,7 @@ from module.plugins.internal.Hook import Hook class UserAgentSwitcher(Hook): __name__ = "UserAgentSwitcher" __type__ = "hook" - __version__ = "0.09" + __version__ = "0.10" __config__ = [("activated" , "bool", "Activated" , True ), ("connecttimeout", "int" , "Connection timeout in seconds" , 60 ), @@ -28,9 +28,9 @@ class UserAgentSwitcher(Hook): def download_preparing(self, pyfile): - connecttimeout = self.getConfig('connecttimeout') - maxredirs = self.getConfig('maxredirs') - useragent = self.getConfig('useragent') + connecttimeout = self.get_config('connecttimeout') + maxredirs = self.get_config('maxredirs') + useragent = self.get_config('useragent') if connecttimeout: pyfile.plugin.req.http.c.setopt(pycurl.CONNECTTIMEOUT, connecttimeout) @@ -39,5 +39,5 @@ class UserAgentSwitcher(Hook): pyfile.plugin.req.http.c.setopt(pycurl.MAXREDIRS, maxredirs) if useragent: - self.logDebug("Use custom user-agent string: " + useragent) + self.log_debug("Use custom user-agent string: " + useragent) pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, useragent) -- cgit v1.2.3 From 502517f37c7540b0bddb092e69386d9d6f08800c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 09:42:34 +0200 Subject: Fix addons --- module/plugins/hooks/UserAgentSwitcher.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks/UserAgentSwitcher.py') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index fdfe4b673..637f6c3ad 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -2,10 +2,10 @@ import pycurl -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon -class UserAgentSwitcher(Hook): +class UserAgentSwitcher(Addon): __name__ = "UserAgentSwitcher" __type__ = "hook" __version__ = "0.10" @@ -20,13 +20,6 @@ class UserAgentSwitcher(Hook): __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 download_preparing(self, pyfile): connecttimeout = self.get_config('connecttimeout') maxredirs = self.get_config('maxredirs') -- cgit v1.2.3 From d38e830b7c0b3c6561a0072c74bbccb5fcdf4a61 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 14:43:42 +0200 Subject: New __status__ magic key --- module/plugins/hooks/UserAgentSwitcher.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hooks/UserAgentSwitcher.py') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 637f6c3ad..aa90bdd1a 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -9,6 +9,7 @@ class UserAgentSwitcher(Addon): __name__ = "UserAgentSwitcher" __type__ = "hook" __version__ = "0.10" + __status__ = "stable" __config__ = [("activated" , "bool", "Activated" , True ), ("connecttimeout", "int" , "Connection timeout in seconds" , 60 ), -- cgit v1.2.3 From 94d017cd2a5c1f194960827a8c7e46afc3682008 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 24 Jul 2015 06:55:49 +0200 Subject: Hotfixes (2) --- module/plugins/hooks/UserAgentSwitcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/UserAgentSwitcher.py') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index aa90bdd1a..dbd18bc2c 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -9,7 +9,7 @@ class UserAgentSwitcher(Addon): __name__ = "UserAgentSwitcher" __type__ = "hook" __version__ = "0.10" - __status__ = "stable" + __status__ = "testing" __config__ = [("activated" , "bool", "Activated" , True ), ("connecttimeout", "int" , "Connection timeout in seconds" , 60 ), -- cgit v1.2.3 From f0df222caaa8544b84d84af2f8ea36783ddd8fb8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Jul 2015 19:22:06 +0200 Subject: Fix https://github.com/pyload/pyload/issues/1581 --- module/plugins/hooks/UserAgentSwitcher.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/UserAgentSwitcher.py') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index dbd18bc2c..52f542268 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -3,12 +3,13 @@ import pycurl from module.plugins.internal.Addon import Addon +from module.plugins.internal.Plugin import encode class UserAgentSwitcher(Addon): __name__ = "UserAgentSwitcher" __type__ = "hook" - __version__ = "0.10" + __version__ = "0.11" __status__ = "testing" __config__ = [("activated" , "bool", "Activated" , True ), @@ -34,4 +35,4 @@ class UserAgentSwitcher(Addon): if useragent: self.log_debug("Use custom user-agent string: " + useragent) - pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, useragent) + pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, encode(useragent)) -- cgit v1.2.3