Correct encoding
Kodi dialogs take unicode
This commit is contained in:
parent
d5aae4934b
commit
56af183288
8 changed files with 70 additions and 81 deletions
|
@ -131,17 +131,14 @@ class PlexAPI():
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
while retrievedPlexLogin == '' and plexLogin != '':
|
while retrievedPlexLogin == '' and plexLogin != '':
|
||||||
# Enter plex.tv username. Or nothing to cancel.
|
# Enter plex.tv username. Or nothing to cancel.
|
||||||
plexLogin = dialog.input(
|
plexLogin = dialog.input(self.addonName + string(39300),
|
||||||
self.addonName.encode('utf-8') + string(39300).encode('utf-8'),
|
type=xbmcgui.INPUT_ALPHANUM)
|
||||||
type=xbmcgui.INPUT_ALPHANUM,
|
|
||||||
)
|
|
||||||
if plexLogin != "":
|
if plexLogin != "":
|
||||||
# Enter password for plex.tv user
|
# Enter password for plex.tv user
|
||||||
plexPassword = dialog.input(
|
plexPassword = dialog.input(
|
||||||
string(39301).encode('utf-8') + plexLogin.encode('utf-8'),
|
string(39301) + plexLogin,
|
||||||
type=xbmcgui.INPUT_ALPHANUM,
|
type=xbmcgui.INPUT_ALPHANUM,
|
||||||
option=xbmcgui.ALPHANUM_HIDE_INPUT
|
option=xbmcgui.ALPHANUM_HIDE_INPUT)
|
||||||
)
|
|
||||||
retrievedPlexLogin, authtoken = self.MyPlexSignIn(
|
retrievedPlexLogin, authtoken = self.MyPlexSignIn(
|
||||||
plexLogin,
|
plexLogin,
|
||||||
plexPassword,
|
plexPassword,
|
||||||
|
@ -151,8 +148,7 @@ class PlexAPI():
|
||||||
if plexLogin == '':
|
if plexLogin == '':
|
||||||
# Could not sign in user
|
# Could not sign in user
|
||||||
dialog.ok(self.addonName,
|
dialog.ok(self.addonName,
|
||||||
string(39302).encode('utf-8')
|
string(39302) + plexLogin)
|
||||||
+ plexLogin.encode('utf-8'))
|
|
||||||
# Write to Kodi settings file
|
# Write to Kodi settings file
|
||||||
utils.settings('plexLogin', value=retrievedPlexLogin)
|
utils.settings('plexLogin', value=retrievedPlexLogin)
|
||||||
utils.settings('plexToken', value=authtoken)
|
utils.settings('plexToken', value=authtoken)
|
||||||
|
@ -177,12 +173,12 @@ class PlexAPI():
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
if not code:
|
if not code:
|
||||||
# Problems trying to contact plex.tv. Try again later
|
# Problems trying to contact plex.tv. Try again later
|
||||||
dialog.ok(self.addonName, string(39303).encode('utf-8'))
|
dialog.ok(self.addonName, string(39303))
|
||||||
return False
|
return False
|
||||||
# Go to https://plex.tv/pin and enter the code:
|
# Go to https://plex.tv/pin and enter the code:
|
||||||
answer = dialog.yesno(self.addonName,
|
answer = dialog.yesno(self.addonName,
|
||||||
(string(39304) + "\n\n").encode('utf-8'),
|
string(39304) + "\n\n",
|
||||||
code.encode('utf-8'))
|
code)
|
||||||
if not answer:
|
if not answer:
|
||||||
return False
|
return False
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -196,7 +192,7 @@ class PlexAPI():
|
||||||
count += 1
|
count += 1
|
||||||
if not xml:
|
if not xml:
|
||||||
# Could not sign in to plex.tv Try again later
|
# Could not sign in to plex.tv Try again later
|
||||||
dialog.ok(self.addonName, string(39305).encode('utf-8'))
|
dialog.ok(self.addonName, string(39305))
|
||||||
return False
|
return False
|
||||||
# Parse xml
|
# Parse xml
|
||||||
userid = xml.attrib.get('id')
|
userid = xml.attrib.get('id')
|
||||||
|
@ -1089,7 +1085,7 @@ class PlexAPI():
|
||||||
if usernumber > 1:
|
if usernumber > 1:
|
||||||
# Select user
|
# Select user
|
||||||
user_select = dialog.select(
|
user_select = dialog.select(
|
||||||
(self.addonName + string(39306)).encode('utf-8'),
|
self.addonName + string(39306),
|
||||||
userlistCoded)
|
userlistCoded)
|
||||||
if user_select == -1:
|
if user_select == -1:
|
||||||
self.logMsg("No user selected.", 1)
|
self.logMsg("No user selected.", 1)
|
||||||
|
@ -1108,7 +1104,7 @@ class PlexAPI():
|
||||||
# Please enter pin for user
|
# Please enter pin for user
|
||||||
self.logMsg('Asking for users PIN', 1)
|
self.logMsg('Asking for users PIN', 1)
|
||||||
pin = dialog.input(
|
pin = dialog.input(
|
||||||
(string(39307) + selected_user).encode('utf-8'),
|
string(39307) + selected_user,
|
||||||
type=xbmcgui.INPUT_NUMERIC,
|
type=xbmcgui.INPUT_NUMERIC,
|
||||||
option=xbmcgui.ALPHANUM_HIDE_INPUT)
|
option=xbmcgui.ALPHANUM_HIDE_INPUT)
|
||||||
# User chose to cancel
|
# User chose to cancel
|
||||||
|
@ -1129,11 +1125,9 @@ class PlexAPI():
|
||||||
# Couldn't get user auth
|
# Couldn't get user auth
|
||||||
if not username:
|
if not username:
|
||||||
# Could not login user, please try again
|
# Could not login user, please try again
|
||||||
if not dialog.yesno(
|
if not dialog.yesno(self.addonName,
|
||||||
self.addonName,
|
string(39308) + selected_user,
|
||||||
(string(39308) + selected_user).encode('utf-8'),
|
string(39309)):
|
||||||
string(39309).encode('utf-8')
|
|
||||||
):
|
|
||||||
# User chose to cancel
|
# User chose to cancel
|
||||||
break
|
break
|
||||||
# Successfully retrieved: break out of while loop
|
# Successfully retrieved: break out of while loop
|
||||||
|
|
|
@ -98,7 +98,7 @@ def reConnect():
|
||||||
if counter > 20:
|
if counter > 20:
|
||||||
dialog.ok(
|
dialog.ok(
|
||||||
heading=addonName,
|
heading=addonName,
|
||||||
message=string(39208).encode('utf-8'),
|
message=string(39208),
|
||||||
)
|
)
|
||||||
# Resuming threads, just in case
|
# Resuming threads, just in case
|
||||||
utils.window('suspend_LibraryThread', clear=True)
|
utils.window('suspend_LibraryThread', clear=True)
|
||||||
|
@ -185,7 +185,7 @@ def resetAuth():
|
||||||
string = xbmcaddon.Addon().getLocalizedString
|
string = xbmcaddon.Addon().getLocalizedString
|
||||||
resp = xbmcgui.Dialog().yesno(
|
resp = xbmcgui.Dialog().yesno(
|
||||||
heading="Warning",
|
heading="Warning",
|
||||||
line1=string(39206).encode('utf-8'))
|
line1=string(39206))
|
||||||
if resp == 1:
|
if resp == 1:
|
||||||
utils.logMsg("PLEX", "Reset login attempts.", 1)
|
utils.logMsg("PLEX", "Reset login attempts.", 1)
|
||||||
utils.window('emby_serverStatus', value="Auth")
|
utils.window('emby_serverStatus', value="Auth")
|
||||||
|
@ -255,14 +255,14 @@ def resetDeviceId():
|
||||||
"Failed to generate a new device Id: %s" % e, 1)
|
"Failed to generate a new device Id: %s" % e, 1)
|
||||||
dialog.ok(
|
dialog.ok(
|
||||||
heading=addonName,
|
heading=addonName,
|
||||||
line1=language(33032).encode('utf-8'))
|
line1=language(33032))
|
||||||
else:
|
else:
|
||||||
utils.logMsg(addonName,
|
utils.logMsg(addonName,
|
||||||
"Successfully removed old deviceId: %s New deviceId: %s"
|
"Successfully removed old deviceId: %s New deviceId: %s"
|
||||||
% (deviceId_old, deviceId), 1)
|
% (deviceId_old, deviceId), 1)
|
||||||
dialog.ok(
|
dialog.ok(
|
||||||
heading=addonName,
|
heading=addonName,
|
||||||
line1=language(33033).encode('utf-8'))
|
line1=language(33033))
|
||||||
xbmc.executebuiltin('RestartApp')
|
xbmc.executebuiltin('RestartApp')
|
||||||
|
|
||||||
##### ADD ADDITIONAL USERS #####
|
##### ADD ADDITIONAL USERS #####
|
||||||
|
@ -1189,6 +1189,6 @@ def RunLibScan(mode):
|
||||||
# Server is not online, do not run the sync
|
# Server is not online, do not run the sync
|
||||||
string = xbmcaddon.Addon().getLocalizedString
|
string = xbmcaddon.Addon().getLocalizedString
|
||||||
xbmcgui.Dialog().ok(heading=addonName,
|
xbmcgui.Dialog().ok(heading=addonName,
|
||||||
line1=string(39205).encode('utf-8'))
|
line1=string(39205))
|
||||||
else:
|
else:
|
||||||
utils.window('plex_runLibScan', value='full')
|
utils.window('plex_runLibScan', value='full')
|
||||||
|
|
|
@ -57,10 +57,8 @@ class InitialSetup():
|
||||||
# Delete token in the settings
|
# Delete token in the settings
|
||||||
utils.settings('plexToken', value='')
|
utils.settings('plexToken', value='')
|
||||||
# Could not login, please try again
|
# Could not login, please try again
|
||||||
dialog.ok(
|
dialog.ok(self.addonName,
|
||||||
self.addonName,
|
string(39009))
|
||||||
string(39009).encode('utf-8')
|
|
||||||
)
|
|
||||||
result = self.plx.PlexTvSignInWithPin()
|
result = self.plx.PlexTvSignInWithPin()
|
||||||
if result:
|
if result:
|
||||||
plexLogin = result['username']
|
plexLogin = result['username']
|
||||||
|
@ -68,10 +66,8 @@ class InitialSetup():
|
||||||
plexid = result['plexid']
|
plexid = result['plexid']
|
||||||
elif chk is False or chk >= 400:
|
elif chk is False or chk >= 400:
|
||||||
# Problems connecting to plex.tv. Network or internet issue?
|
# Problems connecting to plex.tv. Network or internet issue?
|
||||||
dialog.ok(
|
dialog.ok(self.addonName,
|
||||||
self.addonName,
|
string(39010))
|
||||||
string(39010).encode('utf-8')
|
|
||||||
)
|
|
||||||
# If a Plex server IP has already been set, return.
|
# If a Plex server IP has already been set, return.
|
||||||
if server and forcePlexTV is False:
|
if server and forcePlexTV is False:
|
||||||
self.logMsg("Server is already set.", 0)
|
self.logMsg("Server is already set.", 0)
|
||||||
|
@ -100,8 +96,8 @@ class InitialSetup():
|
||||||
self.logMsg("Result of setting g_PMS variable: %s"
|
self.logMsg("Result of setting g_PMS variable: %s"
|
||||||
% self.plx.g_PMS, 1)
|
% self.plx.g_PMS, 1)
|
||||||
isconnected = False
|
isconnected = False
|
||||||
serverlist = self.plx.returnServerList(
|
serverlist = self.plx.returnServerList(clientId,
|
||||||
clientId, self.plx.g_PMS)
|
self.plx.g_PMS)
|
||||||
self.logMsg('PMS serverlist: %s' % serverlist)
|
self.logMsg('PMS serverlist: %s' % serverlist)
|
||||||
# Let user pick server from a list
|
# Let user pick server from a list
|
||||||
# Get a nicer list
|
# Get a nicer list
|
||||||
|
@ -110,18 +106,18 @@ class InitialSetup():
|
||||||
if len(serverlist) == 0:
|
if len(serverlist) == 0:
|
||||||
dialog.ok(
|
dialog.ok(
|
||||||
self.addonName,
|
self.addonName,
|
||||||
string(39011).encode('utf-8')
|
string(39011)
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
for server in serverlist:
|
for server in serverlist:
|
||||||
if server['local'] == '1':
|
if server['local'] == '1':
|
||||||
# server is in the same network as client. Add "local"
|
# server is in the same network as client. Add "local"
|
||||||
dialoglist.append(
|
dialoglist.append(
|
||||||
server['name'].encode('utf-8')
|
server['name']
|
||||||
+ string(39022).encode('utf-8'))
|
+ string(39022))
|
||||||
else:
|
else:
|
||||||
dialoglist.append(server['name'].encode('utf-8'))
|
dialoglist.append(server['name'])
|
||||||
resp = dialog.select(string(39012).encode('utf-8'), dialoglist)
|
resp = dialog.select(string(39012), dialoglist)
|
||||||
server = serverlist[resp]
|
server = serverlist[resp]
|
||||||
activeServer = server['machineIdentifier']
|
activeServer = server['machineIdentifier']
|
||||||
url = server['scheme'] + '://' + server['ip'] + ':' + \
|
url = server['scheme'] + '://' + server['ip'] + ':' + \
|
||||||
|
@ -146,9 +142,8 @@ class InitialSetup():
|
||||||
# Not yet authorized for Plex server
|
# Not yet authorized for Plex server
|
||||||
# Please sign in to plex.tv
|
# Please sign in to plex.tv
|
||||||
dialog.ok(self.addonName,
|
dialog.ok(self.addonName,
|
||||||
string(39013).encode('utf-8')
|
string(39013) + server['name'],
|
||||||
+ server['name'].encode('utf-8'),
|
string(39014))
|
||||||
string(39014).encode('utf-8'))
|
|
||||||
result = self.plx.PlexTvSignInWithPin()
|
result = self.plx.PlexTvSignInWithPin()
|
||||||
if result:
|
if result:
|
||||||
plexLogin = result['username']
|
plexLogin = result['username']
|
||||||
|
@ -161,7 +156,7 @@ class InitialSetup():
|
||||||
elif chk >= 400 or chk is False:
|
elif chk >= 400 or chk is False:
|
||||||
# Problems connecting to server. Pick another server?
|
# Problems connecting to server. Pick another server?
|
||||||
resp = dialog.yesno(self.addonName,
|
resp = dialog.yesno(self.addonName,
|
||||||
string(39015).encode('utf-8'))
|
string(39015))
|
||||||
# Exit while loop if user chooses No
|
# Exit while loop if user chooses No
|
||||||
if not resp:
|
if not resp:
|
||||||
break
|
break
|
||||||
|
@ -173,7 +168,7 @@ class InitialSetup():
|
||||||
# Enter Kodi settings instead
|
# Enter Kodi settings instead
|
||||||
if dialog.yesno(
|
if dialog.yesno(
|
||||||
heading=self.addonName,
|
heading=self.addonName,
|
||||||
line1=string(39016).encode('utf-8')):
|
line1=string(39016)):
|
||||||
self.logMsg("User opted to disable Plex music library.", 1)
|
self.logMsg("User opted to disable Plex music library.", 1)
|
||||||
utils.settings('enableMusic', value="false")
|
utils.settings('enableMusic', value="false")
|
||||||
xbmc.executebuiltin('Addon.OpenSettings(%s)' % self.addonId)
|
xbmc.executebuiltin('Addon.OpenSettings(%s)' % self.addonId)
|
||||||
|
@ -207,14 +202,14 @@ class InitialSetup():
|
||||||
if forcePlexTV:
|
if forcePlexTV:
|
||||||
return
|
return
|
||||||
|
|
||||||
if dialog.yesno(
|
# Disable Plex music?
|
||||||
heading=self.addonName,
|
if dialog.yesno(heading=self.addonName,
|
||||||
line1=string(39016).encode('utf-8')):
|
line1=string(39016)):
|
||||||
self.logMsg("User opted to disable Plex music library.", 1)
|
self.logMsg("User opted to disable Plex music library.", 1)
|
||||||
utils.settings('enableMusic', value="false")
|
utils.settings('enableMusic', value="false")
|
||||||
|
|
||||||
if dialog.yesno(
|
# Open Settings page now?
|
||||||
heading=self.addonName,
|
if dialog.yesno(heading=self.addonName,
|
||||||
line1=string(39017).encode('utf-8')):
|
line1=string(39017)):
|
||||||
xbmc.executebuiltin(
|
xbmc.executebuiltin(
|
||||||
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
||||||
|
|
|
@ -524,8 +524,8 @@ class Player(xbmc.Player):
|
||||||
offerDelete = False
|
offerDelete = False
|
||||||
if percentComplete >= markPlayedAt and offerDelete:
|
if percentComplete >= markPlayedAt and offerDelete:
|
||||||
resp = xbmcgui.Dialog().yesno(
|
resp = xbmcgui.Dialog().yesno(
|
||||||
lang(30091).encode('utf-8'),
|
lang(30091),
|
||||||
lang(33015).encode('utf-8'),
|
lang(33015),
|
||||||
autoclose=120000)
|
autoclose=120000)
|
||||||
if not resp:
|
if not resp:
|
||||||
log("User skipped deletion.", 1)
|
log("User skipped deletion.", 1)
|
||||||
|
|
|
@ -34,6 +34,8 @@ class PlayUtils():
|
||||||
"""
|
"""
|
||||||
Returns the playurl for the part with number partNumber
|
Returns the playurl for the part with number partNumber
|
||||||
(movie might consist of several files)
|
(movie might consist of several files)
|
||||||
|
|
||||||
|
playurl is utf-8 encoded!
|
||||||
"""
|
"""
|
||||||
log = self.logMsg
|
log = self.logMsg
|
||||||
window = utils.window
|
window = utils.window
|
||||||
|
@ -64,6 +66,7 @@ class PlayUtils():
|
||||||
}
|
}
|
||||||
playurl = self.API.getTranscodeVideoPath('Transcode',
|
playurl = self.API.getTranscodeVideoPath('Transcode',
|
||||||
quality=quality)
|
quality=quality)
|
||||||
|
playurl = playurl.encode('utf-8')
|
||||||
# Set playmethod property
|
# Set playmethod property
|
||||||
window('emby_%s.playmethod' % playurl, value="Transcode")
|
window('emby_%s.playmethod' % playurl, value="Transcode")
|
||||||
|
|
||||||
|
@ -371,7 +374,7 @@ class PlayUtils():
|
||||||
subNum += 1
|
subNum += 1
|
||||||
|
|
||||||
if audioNum > 1:
|
if audioNum > 1:
|
||||||
resp = dialog.select(lang(33013).encode('utf-8'), audioStreams)
|
resp = dialog.select(lang(33013), audioStreams)
|
||||||
if resp > -1:
|
if resp > -1:
|
||||||
# User selected audio
|
# User selected audio
|
||||||
playurlprefs['audioStreamID'] = audioStreamsList[resp]
|
playurlprefs['audioStreamID'] = audioStreamsList[resp]
|
||||||
|
@ -384,7 +387,7 @@ class PlayUtils():
|
||||||
playurlprefs['audioBoost'] = utils.settings('audioBoost')
|
playurlprefs['audioBoost'] = utils.settings('audioBoost')
|
||||||
|
|
||||||
if subNum > 1:
|
if subNum > 1:
|
||||||
resp = dialog.select(lang(33014).encode('utf-8'), subtitleStreams)
|
resp = dialog.select(lang(33014), subtitleStreams)
|
||||||
if resp == 0:
|
if resp == 0:
|
||||||
# User selected no subtitles
|
# User selected no subtitles
|
||||||
playurlprefs["skipSubtitles"] = 1
|
playurlprefs["skipSubtitles"] = 1
|
||||||
|
|
|
@ -46,23 +46,16 @@ class UserClient(threading.Thread):
|
||||||
|
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
def getAdditionalUsers(self):
|
|
||||||
|
|
||||||
additionalUsers = utils.settings('additionalUsers')
|
|
||||||
|
|
||||||
if additionalUsers:
|
|
||||||
self.AdditionalUser = additionalUsers.split(',')
|
|
||||||
|
|
||||||
def getUsername(self):
|
def getUsername(self):
|
||||||
"""
|
"""
|
||||||
Returns username as unicode
|
Returns username as unicode
|
||||||
"""
|
"""
|
||||||
|
|
||||||
username = utils.settings('username').decode('utf-8')
|
username = utils.settings('username')
|
||||||
|
|
||||||
if not username:
|
if not username:
|
||||||
self.logMsg("No username saved, trying to get Plex username", 0)
|
self.logMsg("No username saved, trying to get Plex username", 0)
|
||||||
username = utils.settings('plexLogin').decode('utf-8')
|
username = utils.settings('plexLogin')
|
||||||
if not username:
|
if not username:
|
||||||
self.logMsg("Also no Plex username found", 0)
|
self.logMsg("Also no Plex username found", 0)
|
||||||
return ""
|
return ""
|
||||||
|
@ -245,9 +238,8 @@ class UserClient(threading.Thread):
|
||||||
log("Access is granted.", 1)
|
log("Access is granted.", 1)
|
||||||
self.HasAccess = True
|
self.HasAccess = True
|
||||||
window('emby_serverStatus', clear=True)
|
window('emby_serverStatus', clear=True)
|
||||||
xbmcgui.Dialog().notification(
|
xbmcgui.Dialog().notification(self.addonName,
|
||||||
self.addonName,
|
utils.language(33007))
|
||||||
utils.language(33007).encode('utf-8'))
|
|
||||||
|
|
||||||
def loadCurrUser(self, authenticated=False):
|
def loadCurrUser(self, authenticated=False):
|
||||||
self.logMsg('Loading current user', 0)
|
self.logMsg('Loading current user', 0)
|
||||||
|
@ -318,7 +310,8 @@ class UserClient(threading.Thread):
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
|
|
||||||
# Get /profile/addon_data
|
# Get /profile/addon_data
|
||||||
addondir = xbmc.translatePath(self.addon.getAddonInfo('profile')).decode('utf-8')
|
addondir = xbmc.translatePath(
|
||||||
|
self.addon.getAddonInfo('profile')).decode('utf-8')
|
||||||
hasSettings = xbmcvfs.exists("%ssettings.xml" % addondir)
|
hasSettings = xbmcvfs.exists("%ssettings.xml" % addondir)
|
||||||
|
|
||||||
# If there's no settings.xml
|
# If there's no settings.xml
|
||||||
|
@ -373,7 +366,7 @@ class UserClient(threading.Thread):
|
||||||
if username:
|
if username:
|
||||||
dialog.notification(
|
dialog.notification(
|
||||||
heading=self.addonName,
|
heading=self.addonName,
|
||||||
message=("Welcome " + username).encode('utf-8'),
|
message="Welcome " + username,
|
||||||
icon="special://home/addons/plugin.video.plexkodiconnect/icon.png")
|
icon="special://home/addons/plugin.video.plexkodiconnect/icon.png")
|
||||||
else:
|
else:
|
||||||
dialog.notification(
|
dialog.notification(
|
||||||
|
@ -391,8 +384,8 @@ class UserClient(threading.Thread):
|
||||||
if self.retry >= 5:
|
if self.retry >= 5:
|
||||||
log("Too many retries.", 1)
|
log("Too many retries.", 1)
|
||||||
window('emby_serverStatus', value="Stop")
|
window('emby_serverStatus', value="Stop")
|
||||||
dialog.ok(lang(33001).encode('utf-8'),
|
dialog.ok(lang(33001),
|
||||||
lang(39023).encode('utf-8'))
|
lang(39023))
|
||||||
xbmc.executebuiltin(
|
xbmc.executebuiltin(
|
||||||
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,13 @@ def logMsg(title, msg, level=1):
|
||||||
|
|
||||||
|
|
||||||
def window(property, value=None, clear=False, windowid=10000):
|
def window(property, value=None, clear=False, windowid=10000):
|
||||||
# Get or set window property
|
"""
|
||||||
|
Get or set window property - thread safe!
|
||||||
|
|
||||||
|
Returns unicode.
|
||||||
|
|
||||||
|
Property needs to be string; value may be string or unicode
|
||||||
|
"""
|
||||||
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
|
#setproperty accepts both string and unicode but utf-8 strings are adviced by kodi devs because some unicode can give issues
|
||||||
|
@ -228,14 +234,13 @@ def window(property, value=None, clear=False, windowid=10000):
|
||||||
if clear:
|
if clear:
|
||||||
WINDOW.clearProperty(property)
|
WINDOW.clearProperty(property)
|
||||||
elif value is not None:
|
elif value is not None:
|
||||||
# Takes unicode or string by default!
|
WINDOW.setProperty(property, value.encode('utf-8'))
|
||||||
WINDOW.setProperty(property, value)
|
else:
|
||||||
else: #getproperty returns string so convert to unicode
|
return WINDOW.getProperty(property).decode('utf-8')
|
||||||
return WINDOW.getProperty(property)
|
|
||||||
|
|
||||||
def settings(setting, value=None):
|
def settings(setting, value=None):
|
||||||
"""
|
"""
|
||||||
Get or add addon setting.
|
Get or add addon setting. Returns unicode
|
||||||
|
|
||||||
Settings needs to be string
|
Settings needs to be string
|
||||||
Value can either be unicode or string
|
Value can either be unicode or string
|
||||||
|
@ -244,10 +249,10 @@ def settings(setting, value=None):
|
||||||
|
|
||||||
if value is not None:
|
if value is not None:
|
||||||
# Takes string or unicode by default!
|
# Takes string or unicode by default!
|
||||||
addon.setSetting(setting, value)
|
addon.setSetting(setting, value.encode('utf-8'))
|
||||||
else:
|
else:
|
||||||
# Returns unicode by default!
|
# Should return unicode by default, but just in case
|
||||||
return addon.getSetting(setting)
|
return addon.getSetting(setting).decode('utf-8')
|
||||||
|
|
||||||
def language(stringid):
|
def language(stringid):
|
||||||
# Central string retrieval
|
# Central string retrieval
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
import xml.etree.ElementTree as etree
|
import xml.etree.ElementTree as etree
|
||||||
from os import path as ospath
|
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
|
Loading…
Reference in a new issue