Convert to string

Prep for translation
This commit is contained in:
angelblue05 2016-02-02 17:49:22 -06:00
parent c8621400f0
commit bfbc66457c
2 changed files with 45 additions and 32 deletions

View file

@ -276,6 +276,12 @@
<string id="30406">Remove from Emby favorites</string> <string id="30406">Remove from Emby favorites</string>
<string id="30407">Set custom song rating</string> <string id="30407">Set custom song rating</string>
<string id="30408">Emby addon settings</string> <string id="30408">Emby addon settings</string>
<string id="30409">Delete item from the server</string> <string id="30409">Delete item from the server</string>
<!-- service add-on -->
<string id="33000">Welcome</string>
<string id="33001">Error connecting</string>
<string id="33002">Server is unreachable</string>
<string id="33003">Server is online</string>
</strings> </strings>

View file

@ -48,22 +48,25 @@ class Service():
def __init__(self): def __init__(self):
log = self.logMsg
window = utils.window
self.clientInfo = clientinfo.ClientInfo() self.clientInfo = clientinfo.ClientInfo()
self.addonName = self.clientInfo.getAddonName() self.addonName = self.clientInfo.getAddonName()
logLevel = userclient.UserClient().getLogLevel() logLevel = userclient.UserClient().getLogLevel()
self.monitor = xbmc.Monitor() self.monitor = xbmc.Monitor()
utils.window('emby_logLevel', value=str(logLevel)) window('emby_logLevel', value=str(logLevel))
utils.window('emby_kodiProfile', value=xbmc.translatePath("special://profile")) window('emby_kodiProfile', value=xbmc.translatePath("special://profile"))
utils.window('emby_pluginpath', value=utils.settings('useDirectPaths')) window('emby_pluginpath', value=utils.settings('useDirectPaths'))
# Initial logging # Initial logging
self.logMsg("======== START %s ========" % self.addonName, 0) log("======== START %s ========" % self.addonName, 0)
self.logMsg("Platform: %s" % (self.clientInfo.getPlatform()), 0) log("Platform: %s" % (self.clientInfo.getPlatform()), 0)
self.logMsg("KODI Version: %s" % xbmc.getInfoLabel('System.BuildVersion'), 0) log("KODI Version: %s" % xbmc.getInfoLabel('System.BuildVersion'), 0)
self.logMsg("%s Version: %s" % (self.addonName, self.clientInfo.getVersion()), 0) log("%s Version: %s" % (self.addonName, self.clientInfo.getVersion()), 0)
self.logMsg("Using plugin paths: %s" % (utils.settings('useDirectPaths') != "true"), 0) log("Using plugin paths: %s" % (utils.settings('useDirectPaths') != "true"), 0)
self.logMsg("Log Level: %s" % logLevel, 0) log("Log Level: %s" % logLevel, 0)
# Reset window props for profile switch # Reset window props for profile switch
properties = [ properties = [
@ -74,13 +77,13 @@ class Service():
"emby_initialScan", "emby_customplaylist", "emby_playbackProps" "emby_initialScan", "emby_customplaylist", "emby_playbackProps"
] ]
for prop in properties: for prop in properties:
utils.window(prop, clear=True) window(prop, clear=True)
# Clear video nodes properties # Clear video nodes properties
videonodes.VideoNodes().clearProperties() videonodes.VideoNodes().clearProperties()
# Set the minimum database version # Set the minimum database version
utils.window('emby_minDBVersion', value="1.1.63") window('emby_minDBVersion', value="1.1.63")
def logMsg(self, msg, lvl=1): def logMsg(self, msg, lvl=1):
@ -89,6 +92,11 @@ class Service():
def ServiceEntryPoint(self): def ServiceEntryPoint(self):
log = self.logMsg
window = utils.window
lang = utils.language
# Important: Threads depending on abortRequest will not trigger # Important: Threads depending on abortRequest will not trigger
# if profile switch happens more than once. # if profile switch happens more than once.
monitor = self.monitor monitor = self.monitor
@ -107,10 +115,9 @@ class Service():
while not monitor.abortRequested(): while not monitor.abortRequested():
if utils.window('emby_kodiProfile') != kodiProfile: if window('emby_kodiProfile') != kodiProfile:
# Profile change happened, terminate this thread and others # Profile change happened, terminate this thread and others
self.logMsg( log("Kodi profile was: %s and changed to: %s. Terminating old Emby thread."
"Kodi profile was: %s and changed to: %s. Terminating old Emby thread."
% (kodiProfile, utils.window('emby_kodiProfile')), 1) % (kodiProfile, utils.window('emby_kodiProfile')), 1)
break break
@ -120,7 +127,7 @@ class Service():
# 2. User is set # 2. User is set
# 3. User has access to the server # 3. User has access to the server
if utils.window('emby_online') == "true": if window('emby_online') == "true":
# Emby server is online # Emby server is online
# Verify if user is set and has access to the server # Verify if user is set and has access to the server
@ -146,15 +153,15 @@ class Service():
kplayer.reportPlayback() kplayer.reportPlayback()
lastProgressUpdate = datetime.today() lastProgressUpdate = datetime.today()
elif utils.window('emby_command') == "true": elif window('emby_command') == "true":
# Received a remote control command that # Received a remote control command that
# requires updating immediately # requires updating immediately
utils.window('emby_command', clear=True) window('emby_command', clear=True)
kplayer.reportPlayback() kplayer.reportPlayback()
lastProgressUpdate = datetime.today() lastProgressUpdate = datetime.today()
except Exception as e: except Exception as e:
self.logMsg("Exception in Playback Monitor Service: %s" % e, 1) log("Exception in Playback Monitor Service: %s" % e, 1)
pass pass
else: else:
# Start up events # Start up events
@ -169,8 +176,8 @@ class Service():
else: else:
add = "" add = ""
xbmcgui.Dialog().notification( xbmcgui.Dialog().notification(
heading="Emby server", heading="Emby for Kodi",
message="Welcome %s%s!" % (user.currUser, add), message="%s %s%s!" % (lang(33000), user.currUser, add),
icon="special://home/addons/plugin.video.emby/icon.png", icon="special://home/addons/plugin.video.emby/icon.png",
time=2000, time=2000,
sound=False) sound=False)
@ -192,7 +199,7 @@ class Service():
if (user.currUser is None) and self.warn_auth: if (user.currUser is None) and self.warn_auth:
# Alert user is not authenticated and suppress future warning # Alert user is not authenticated and suppress future warning
self.warn_auth = False self.warn_auth = False
self.logMsg("Not authenticated yet.", 1) log("Not authenticated yet.", 1)
# User access is restricted. # User access is restricted.
# Keep verifying until access is granted # Keep verifying until access is granted
@ -201,7 +208,7 @@ class Service():
# Verify access with an API call # Verify access with an API call
user.hasAccess() user.hasAccess()
if utils.window('emby_online') != "true": if window('emby_online') != "true":
# Server went offline # Server went offline
break break
@ -221,12 +228,12 @@ class Service():
# Server is offline. # Server is offline.
# Alert the user and suppress future warning # Alert the user and suppress future warning
if self.server_online: if self.server_online:
self.logMsg("Server is offline.", 1) log("Server is offline.", 1)
utils.window('emby_online', value="false") window('emby_online', value="false")
xbmcgui.Dialog().notification( xbmcgui.Dialog().notification(
heading="Error connecting", heading=lang(33001),
message="%s Server is unreachable." % self.addonName, message="%s %s" % (self.addonName, lang(33002)),
icon="special://home/addons/plugin.video.emby/icon.png", icon="special://home/addons/plugin.video.emby/icon.png",
sound=False) sound=False)
@ -242,15 +249,15 @@ class Service():
break break
# Alert the user that server is online. # Alert the user that server is online.
xbmcgui.Dialog().notification( xbmcgui.Dialog().notification(
heading="Emby server", heading="Emby for Kodi",
message="Server is online.", message=lang(33003),
icon="special://home/addons/plugin.video.emby/icon.png", icon="special://home/addons/plugin.video.emby/icon.png",
time=2000, time=2000,
sound=False) sound=False)
self.server_online = True self.server_online = True
self.logMsg("Server is online and ready.", 1) log("Server is online and ready.", 1)
utils.window('emby_online', value="true") window('emby_online', value="true")
# Start the userclient thread # Start the userclient thread
if not self.userclient_running: if not self.userclient_running:
@ -278,7 +285,7 @@ class Service():
if self.userclient_running: if self.userclient_running:
user.stopClient() user.stopClient()
self.logMsg("======== STOP %s ========" % self.addonName, 0) log("======== STOP %s ========" % self.addonName, 0)
# Delay option # Delay option
delay = int(utils.settings('startupDelay')) delay = int(utils.settings('startupDelay'))