Google: Fix bad json format.

This commit is contained in:
Valentin Lorentz 2012-05-02 15:36:34 +00:00
parent c310d74a19
commit 207f6ec2da

View File

@ -347,11 +347,17 @@ class Google(callbacks.PluginRegexp):
urlig = self._googleUrlIG(expr) urlig = self._googleUrlIG(expr)
js = utils.web.getUrl(urlig) js = utils.web.getUrl(urlig)
# fix bad google json # fix bad google json
js = js.replace('lhs:','"lhs":').replace('rhs:','"rhs":').replace('error:','"error":').replace('icc:','"icc":') js = js \
.replace('lhs:','"lhs":') \
.replace('rhs:','"rhs":') \
.replace('error:','"error":') \
.replace('icc:','"icc":') \
.replace('\\', '\\\\')
js = simplejson.loads(js) js = simplejson.loads(js)
if js['error'] == '': if js['error'] == '':
irc.reply("%s = %s" % (js['lhs'].encode('utf8'), js['rhs'].encode('utf8'),)) irc.reply("%s = %s" % (js['lhs'].encode('utf8').decode('string_escape'),
js['rhs'].encode('utf8').decode('string_escape'),))
return return
url = self._googleUrl(expr) url = self._googleUrl(expr)