mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
prevent possible unicode error in window method
This commit is contained in:
parent
a5d4c881e1
commit
cf94305743
1 changed files with 8 additions and 2 deletions
|
@ -43,10 +43,16 @@ def window(property, value=None, clear=False, windowid=10000):
|
||||||
# Get or set window property
|
# Get or set window property
|
||||||
WINDOW = xbmcgui.Window(windowid)
|
WINDOW = xbmcgui.Window(windowid)
|
||||||
|
|
||||||
|
#setproperty accepts both string and unicode but utf-8 strings are adviced by kodi devs because some unicode can give issues
|
||||||
|
if isinstance(property, unicode):
|
||||||
|
property = property.encode("utf-8")
|
||||||
|
if isinstance(value, unicode):
|
||||||
|
value = value.encode("utf-8")
|
||||||
|
|
||||||
if clear:
|
if clear:
|
||||||
WINDOW.clearProperty(property)
|
WINDOW.clearProperty(property)
|
||||||
elif value is not None: #setproperty accepts both string and unicode but utf-8 string seems best practice to pass
|
elif value is not None:
|
||||||
WINDOW.setProperty(property.encode("utf-8"), value.encode("utf-8"))
|
WINDOW.setProperty(property, value)
|
||||||
else: #getproperty returns string so convert to unicode
|
else: #getproperty returns string so convert to unicode
|
||||||
return WINDOW.getProperty(property).decode("utf-8")
|
return WINDOW.getProperty(property).decode("utf-8")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue