From ff1832c47155d3a415528e701f5e19132760ca5b Mon Sep 17 00:00:00 2001 From: stoneLeaf Date: Thu, 12 Apr 2012 01:52:32 +0200 Subject: [PATCH] Fixed a locale issue in the youtube plugin locale.format() can throw a UnicodeDecodeError in some cases. The use of str.decode() prevents its occurrence. See http://stackoverflow.com/questions/4082645/using-python-2-xs-locale-module-to-format-numbers-and-currency --- plugins/youtube.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/youtube.py b/plugins/youtube.py index 747a1b2..651fa4d 100644 --- a/plugins/youtube.py +++ b/plugins/youtube.py @@ -41,9 +41,11 @@ def get_video_description(vid_id): out += ' - rated \x02%.2f/5.0\x02 (%d)' % (j['rating'], j['ratingCount']) + # The use of str.decode() prevents UnicodeDecodeError with some locales + # See http://stackoverflow.com/questions/4082645/ if 'viewCount' in j: out += ' - \x02%s\x02 views' % locale.format('%d', - j['viewCount'], 1) + j['viewCount'], 1).decode(locale.getlocale()[1]) upload_time = time.strptime(j['uploaded'], "%Y-%m-%dT%H:%M:%S.000Z") out += ' - \x02%s\x02 on \x02%s\x02' % (j['uploader'],