diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index 881ac7456..fd130ac43 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -93,7 +93,6 @@ class Google(callbacks.PluginRegexp): _gsearchUrl = 'https://www.google.com/search' - @internationalizeDocstring def search(self, query, channel, options={}): """Perform a search using Google's AJAX API. search("search phrase", options={}) @@ -170,10 +169,11 @@ class Google(callbacks.PluginRegexp): """ opts = dict(opts) data = self.search(text, msg.args[0], {'smallsearch': True}) + data = self.decode(data) if data: - url = data['url'] + url = data[0]['url'] if 'snippet' in opts: - snippet = data['content'] + snippet = data[0]['content'] snippet = " | " + utils.web.htmlToText(snippet, tagReplace='') else: snippet = "" diff --git a/plugins/Google/test.py b/plugins/Google/test.py index ae2b2cadc..68b0e90be 100644 --- a/plugins/Google/test.py +++ b/plugins/Google/test.py @@ -54,6 +54,10 @@ class GoogleTestCase(ChannelPluginTestCase): # Unicode check self.assertNotError('google ae') + def testLucky(self): + self.assertResponse('lucky Hacker News', + 'https://news.ycombinator.com/') + def testSearchFormat(self): self.assertRegexp('google foo', '') self.assertNotError('config reply.format.url %s')