From 68e5535ca44303dcfbd6548cbe0ab3dd640b413c Mon Sep 17 00:00:00 2001 From: Lasse Vang Gravesen Date: Sun, 3 Jun 2012 01:08:30 +0200 Subject: [PATCH 1/3] Added referer field to http.py, as to make it possible to use a referer. I don't know if this was possible before, and if it was it should be removed and the appropriate changes should be made without the http.py change. Stock plugin output was changed so the percent change has an actual percentage sign after it. UrbanDictionary plugin was changed to use a referer because it didn't work without it. --- plugins/dictionary.py | 2 +- plugins/stock.py | 2 +- plugins/util/http.py | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/dictionary.py b/plugins/dictionary.py index 951099c..abf2086 100755 --- a/plugins/dictionary.py +++ b/plugins/dictionary.py @@ -9,7 +9,7 @@ def urban(inp): '''.u/.urban -- looks up on urbandictionary.com''' url = 'http://www.urbandictionary.com/iphone/search/define' - page = http.get_json(url, term=inp) + page = http.get_json(url, term=inp, referer="http://m.urbandictionary.com") defs = page['list'] if page['result_type'] == 'no_results': diff --git a/plugins/stock.py b/plugins/stock.py index 5b28c60..e05c6fc 100644 --- a/plugins/stock.py +++ b/plugins/stock.py @@ -28,7 +28,7 @@ def stock(inp): results['color'] = "3" ret = "%(company)s - %(last)s %(currency)s " \ - "\x03%(color)s%(change)s (%(perc_change)s)\x03 " \ + "\x03%(color)s%(change)s (%(perc_change)s%%)\x03 " \ "as of %(trade_timestamp)s" % results if results['delay'] != '0': diff --git a/plugins/util/http.py b/plugins/util/http.py index 888c102..f48355a 100644 --- a/plugins/util/http.py +++ b/plugins/util/http.py @@ -37,7 +37,7 @@ def get_json(*args, **kwargs): return json.loads(get(*args, **kwargs)) -def open(url, query_params=None, user_agent=None, post_data=None, +def open(url, query_params=None, user_agent=None, referer=None, post_data=None, get_method=None, cookies=False, **kwargs): if query_params is None: @@ -57,6 +57,9 @@ def open(url, query_params=None, user_agent=None, post_data=None, request.add_header('User-Agent', user_agent) + if referer is not None: + request.add_header('Referer', referer) + if cookies: opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar)) else: From 12cd3521e508bbb10269dc6f4887c5d5c4dbacbf Mon Sep 17 00:00:00 2001 From: Lasse Vang Gravesen Date: Wed, 18 Jul 2012 18:39:51 +0200 Subject: [PATCH 2/3] Problem with urbandict plugin fixed by replacing \r\n with a space --- plugins/dictionary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dictionary.py b/plugins/dictionary.py index abf2086..d593085 100755 --- a/plugins/dictionary.py +++ b/plugins/dictionary.py @@ -15,7 +15,7 @@ def urban(inp): if page['result_type'] == 'no_results': return 'not found.' - out = defs[0]['word'] + ': ' + defs[0]['definition'] + out = defs[0]['word'] + ': ' + defs[0]['definition'].replace('\r\n',' ') if len(out) > 400: out = out[:out.rfind(' ', 0, 400)] + '...' From 2b321a932e9dde6594162f83c8a512731319428c Mon Sep 17 00:00:00 2001 From: Lasse Vang Gravesen Date: Wed, 19 Sep 2012 18:22:48 +0200 Subject: [PATCH 3/3] imdbapi.com moved to omdbapi.com, so that's fixed. --- plugins/imdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/imdb.py b/plugins/imdb.py index 83e96e2..e9caf87 100644 --- a/plugins/imdb.py +++ b/plugins/imdb.py @@ -7,7 +7,7 @@ from util import hook, http def imdb(inp): '''.imdb -- gets information about from IMDb''' - content = http.get_json("http://www.imdbapi.com/", t=inp) + content = http.get_json("http://www.omdbapi.com/", t=inp) if content['Response'] == 'Movie Not Found': return 'movie not found'