From e948054ea4eb6bbba8091482cca52fd2454322a5 Mon Sep 17 00:00:00 2001
From: Walter Purcaro <vuolter@users.noreply.github.com>
Date: Tue, 7 Apr 2015 19:30:29 +0200
Subject: New plugin: UserAgentSwitcher

Fix https://github.com/pyload/pyload/issues/1305
---
 module/plugins/hooks/UserAgentSwitcher.py | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 module/plugins/hooks/UserAgentSwitcher.py

(limited to 'module/plugins/hooks/UserAgentSwitcher.py')

diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py
new file mode 100644
index 000000000..56c605bac
--- /dev/null
+++ b/module/plugins/hooks/UserAgentSwitcher.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+
+import pycurl
+
+from module.plugins.Hook import Hook
+
+
+class UserAgentSwitcher(Hook):
+    __name__    = "UserAgentSwitcher"
+    __type__    = "hook"
+    __version__ = "0.01"
+
+    __config__ = [("ua", "str", "Custom user-agent string", "")]
+
+    __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)
-- 
cgit v1.2.3


From 48abd898139b3f40d52b17680c9d5b8a674545c6 Mon Sep 17 00:00:00 2001
From: Walter Purcaro <vuolter@users.noreply.github.com>
Date: Wed, 8 Apr 2015 00:10:43 +0200
Subject: [UserAgentSwitcher] Default activated set to True

---
 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 56c605bac..31eac9820 100644
--- a/module/plugins/hooks/UserAgentSwitcher.py
+++ b/module/plugins/hooks/UserAgentSwitcher.py
@@ -8,9 +8,10 @@ from module.plugins.Hook import Hook
 class UserAgentSwitcher(Hook):
     __name__    = "UserAgentSwitcher"
     __type__    = "hook"
-    __version__ = "0.01"
+    __version__ = "0.02"
 
-    __config__ = [("ua", "str", "Custom user-agent string", "")]
+    __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"
-- 
cgit v1.2.3