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
This commit is contained in:
stoneLeaf 2012-04-12 01:52:32 +02:00
parent b3e97f2500
commit ff1832c471
1 changed files with 3 additions and 1 deletions

View File

@ -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'],