Commit 86002658 authored by Svetlana Tkachenko's avatar Svetlana Tkachenko
Browse files

Unquote definitionURL in DuckDuckGo plugin (fixes double encoded URLs)

parent 6efd156d
......@@ -25,6 +25,7 @@ import urllib.request
#from urllib.error import HTTPError, URLError
#import socket
import json
import urllib.parse
@plugin
......@@ -46,9 +47,11 @@ class ddg(object):
sock.close()
data = data.decode('utf-8')
jl = json.loads(data)
# print(json.dumps(jl,indent=2))
if str(jl["AbstractText"]) != "":
self.server.doMessage(channel, user + ": " + "%s %s)" % (str(jl["AbstractURL"]), str(jl["AbstractText"][0:200])))
elif str(jl["Definition"]) != "":
self.server.doMessage(channel, user + ": " + "%s %s" % (str(jl["DefinitionURL"]), str(jl["Definition"])))
url = urllib.parse.unquote(str(jl["DefinitionURL"]))
self.server.doMessage(channel, user + ": " + "%s %s" % (url, str(jl["Definition"])))
except Exception as e:
self.server.doMessage(channel, user + ": " + str(e))
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