plugin.video.mubi icon indicating copy to clipboard operation
plugin.video.mubi copied to clipboard

UnicodeEncodeError

Open djgw opened this issue 7 years ago • 4 comments

Jamie, Thanks for this great plugin I've been using it for a few weeks without any problems however something seems to have changed recently (possibly at the MUBI end?) as I am unable to access it anymore.

I've copied the error logs from Kodi below - maybe they can help clarify whether the issue relates to my installation or something else...

Please let me know if I can provide further detail. Cheers, David

22:30:53.414 T:3304059808 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-- - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: <type 'exceptions.UnicodeEncodeError'> Error Contents: 'ascii' codec can't encode character u'\u2019' in position 96: ordinal not in range(128) Traceback (most recent call last): File "/storage/.kodi/addons/plugin.video.mubi/addon.py", line 12, in mubi = Mubi(plugin.get_setting("username", unicode), plugin.get_setting("password", unicode)) File "/storage/.kodi/addons/plugin.video.mubi/resources/lib/mubi.py", line 42, in init self.login() File "/storage/.kodi/addons/plugin.video.mubi/resources/lib/mubi.py", line 55, in login self.app_startup() File "/storage/.kodi/addons/plugin.video.mubi/resources/lib/mubi.py", line 66, in app_startup xbmc.log("Failed to get country: %s" % r.text, 4) UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 96: ordinal not in range(128) -->End of Python script error report<--

djgw avatar Apr 11 '18 02:04 djgw

Hi Jamie, same here. I am trying to get the addon to work but unfortunately I get the same error like David only with a different letter (u'\xf6'). My system is a RaspBerry Pi 3 B OSMC 2018.03-2 (Kernel: Linux 4.14.26-2-OSMC).

I would highly appreciate your reply as I really like your addon and your effort. Thanks in advance Thomas

here the log: 16:02:40.985 T:1374679808 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-- - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: <type 'exceptions.UnicodeEncodeError'> Error Contents: 'ascii' codec can't encode character u'\xf6' in position 189: ordinal not in range(128) Traceback (most recent call last): File "/home/osmc/.kodi/addons/plugin.video.mubi/addon.py", line 12, in mubi = Mubi(plugin.get_setting("username", unicode), plugin.get_setting("password", unicode)) File "/home/osmc/.kodi/addons/plugin.video.mubi/resources/lib/mubi.py", line 42, in init self.login() File "/home/osmc/.kodi/addons/plugin.video.mubi/resources/lib/mubi.py", line 55, in login self.app_startup() File "/home/osmc/.kodi/addons/plugin.video.mubi/resources/lib/mubi.py", line 66, in app_startup xbmc.log("Failed to get country: %s" % r.text, 4) UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 189: ordinal not in range(128) -->End of Python script error report<-- 16:02:41.168 T:1926330880 ERROR: GetDirectory - Error getting plugin://plugin.video.mubi/ 16:02:41.169 T:1926330880 ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.mubi/) failed

ThomZenTury avatar Apr 29 '18 14:04 ThomZenTury

This problem is caused by an incorrect handling of the downloaded JSON files. Mubi is now probaly sending emojis or country flags and this is revealing the issue.

To correct this try to change

json.loads(r.text)['country']

to

json.loads(r.text)['country'].encode("utf-8")

If this works one should sprinkle .encode everywhere.

zensurette avatar May 09 '18 20:05 zensurette

Thanks for the suggestion. Unfortunately adding .encode("utf-8") as shown doesn't stop the exception and the same error as before is logged. Also tried adding .encode to some other json.loads statements without success.

djgw avatar May 12 '18 13:05 djgw

I've the same exact problem, did you solved it perhaps?

tonytozoo avatar Mar 20 '20 19:03 tonytozoo