From 6e47278b9f9e6cf5120b2d7ec0d35a2c8c22c3a6 Mon Sep 17 00:00:00 2001 From: Gordon Shumway Date: Tue, 14 Jul 2020 08:44:43 -0400 Subject: [PATCH] Google: Set User-Agent override. (#1426) With a custom (globally-configured) user-agent, Google may serve a different page, which breaks this plugin. This override disables this custom user-agent and uses a predefined one, which is known to work. --- plugins/Google/plugin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index 4f74a5d6c..0edec6136 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -107,6 +107,7 @@ class Google(callbacks.PluginRegexp): dynamic.irc.nick) headers = dict(utils.web.defaultHeaders) headers['Referer'] = ref + headers['User-agent'] = 'Mozilla/5.0 (compatible; utils.web python module)' opts = {'q': query, 'gbv': '2'} for (k, v) in options.items(): if k == 'smallsearch': @@ -254,7 +255,7 @@ class Google(callbacks.PluginRegexp): def _translate(self, sourceLang, targetLang, text): headers = dict(utils.web.defaultHeaders) - headers['User-Agent'] = ('Mozilla/5.0 (X11; U; Linux i686) ' + headers['User-agent'] = ('Mozilla/5.0 (X11; U; Linux i686) ' 'Gecko/20071127 Firefox/2.0.0.11') sourceLang = utils.web.urlquote(sourceLang)