From 66e1b1b2f7c3e9ff90ff9bf1059ef2d0197102cf Mon Sep 17 00:00:00 2001 From: Ramesh Dharan Date: Thu, 6 Mar 2014 17:04:14 -0500 Subject: [PATCH] Decode IMDB API output as utf-8 I noticed that .movie sometimes generates a UnicodeDecodeError exception, e.g. issuing '.movie gravity' produced: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 151: ordinal not in range(128) (file "willie/modules/movie.py", line 26, in movie) Adding an explicit 'utf-8' to u.decode() on the IMDB API result resolves the issue for me. --- willie/modules/movie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/willie/modules/movie.py b/willie/modules/movie.py index 5e098a6265..a9095d8193 100644 --- a/willie/modules/movie.py +++ b/willie/modules/movie.py @@ -23,7 +23,7 @@ def movie(bot, trigger): word = word.replace(" ", "+") uri = "http://www.imdbapi.com/?t=" + word u = web.get(uri, 30) - data = json.loads(u.decode()) # data is a Dict containing all the information we need + data = json.loads(u.decode('utf-8')) # data is a Dict containing all the information we need if data['Response'] == 'False': if 'Error' in data: message = '[MOVIE] %s' % data['Error']