Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

UnicodeEncodeError #26

Open
djgw opened this issue Apr 11, 2018 · 4 comments
Open

UnicodeEncodeError #26

djgw opened this issue Apr 11, 2018 · 4 comments

Comments

@djgw
Copy link

djgw commented Apr 11, 2018

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<--

@ThomZenTury
Copy link

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

@zensurette
Copy link
Contributor

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.

@djgw
Copy link
Author

djgw commented May 12, 2018

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.

@tonytozoo
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants