Commit 17f65f8a authored by Svetlana Tkachenko's avatar Svetlana Tkachenko
Browse files

Parse JSON properly in the Google plugin (fixes Youtube URLs)

parent bef95762
......@@ -22,7 +22,7 @@
# ~ Nathan Hakak (aka DrKabob)
import urllib.request, urllib.parse
import json
@plugin
class Google(object):
......@@ -36,6 +36,9 @@ class Google(object):
if cmd == "google" or cmd == "g":
search = " ".join(args)
req = urllib.request.Request("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" + urllib.parse.quote(search) + "&key=ABQIAAAA4B16PYoznYWgfVLfNDV4fxRsamdul3hUHNYXnxki2eGK76NS_RQ795CTZZ3l-TuRCO2d5eibFI1WZA")
data = urllib.request.urlopen(req).read().decode('utf-8')
splitdata = data.split("\"")
self.server.doMessage(channel, splitdata[31] + " - " + splitdata[11])
data = urllib.request.urlopen(req).read()
data = json.loads(str(data,encoding='utf-8'))
results = data['responseData']['results']
if(len(results)>0):
result1=results[0]
self.server.doMessage(channel, result1['titleNoFormatting'] + ' - ' + result1['url'])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment