mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
Convert to string
Prep for translation
This commit is contained in:
parent
bfbc66457c
commit
b54f4d54e1
2 changed files with 34 additions and 22 deletions
|
@ -283,5 +283,8 @@
|
||||||
<string id="33001">Error connecting</string>
|
<string id="33001">Error connecting</string>
|
||||||
<string id="33002">Server is unreachable</string>
|
<string id="33002">Server is unreachable</string>
|
||||||
<string id="33003">Server is online</string>
|
<string id="33003">Server is online</string>
|
||||||
|
<string id="33004">items added to playlist</string>
|
||||||
|
<string id="33005">items queued to playlist</string>
|
||||||
|
<string id="33006">Server is restarting</string>
|
||||||
|
|
||||||
</strings>
|
</strings>
|
||||||
|
|
|
@ -50,7 +50,10 @@ class WebSocket_Client(threading.Thread):
|
||||||
|
|
||||||
|
|
||||||
def sendProgressUpdate(self, data):
|
def sendProgressUpdate(self, data):
|
||||||
self.logMsg("sendProgressUpdate", 2)
|
|
||||||
|
log = self.logMsg
|
||||||
|
|
||||||
|
log("sendProgressUpdate", 2)
|
||||||
try:
|
try:
|
||||||
messageData = {
|
messageData = {
|
||||||
|
|
||||||
|
@ -59,20 +62,24 @@ class WebSocket_Client(threading.Thread):
|
||||||
}
|
}
|
||||||
messageString = json.dumps(messageData)
|
messageString = json.dumps(messageData)
|
||||||
self.client.send(messageString)
|
self.client.send(messageString)
|
||||||
self.logMsg("Message data: %s" % messageString, 2)
|
log("Message data: %s" % messageString, 2)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logMsg("Exception: %s" % e, 1)
|
log("Exception: %s" % e, 1)
|
||||||
|
|
||||||
def on_message(self, ws, message):
|
def on_message(self, ws, message):
|
||||||
|
|
||||||
|
log = self.logMsg
|
||||||
|
window = utils.window
|
||||||
|
lang = utils.language
|
||||||
|
|
||||||
result = json.loads(message)
|
result = json.loads(message)
|
||||||
messageType = result['MessageType']
|
messageType = result['MessageType']
|
||||||
data = result['Data']
|
data = result['Data']
|
||||||
|
|
||||||
if messageType not in ('SessionEnded'):
|
if messageType not in ('SessionEnded'):
|
||||||
# Mute certain events
|
# Mute certain events
|
||||||
self.logMsg("Message: %s" % message, 1)
|
log("Message: %s" % message, 1)
|
||||||
|
|
||||||
if messageType == "Play":
|
if messageType == "Play":
|
||||||
# A remote control play command has been sent from the server.
|
# A remote control play command has been sent from the server.
|
||||||
|
@ -81,12 +88,11 @@ class WebSocket_Client(threading.Thread):
|
||||||
|
|
||||||
pl = playlist.Playlist()
|
pl = playlist.Playlist()
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
dialog.notification("Emby for Kodi", "Adding %s items to playlist." % len(itemIds))
|
|
||||||
|
|
||||||
if command == "PlayNow":
|
if command == "PlayNow":
|
||||||
dialog.notification(
|
dialog.notification(
|
||||||
heading="Emby for Kodi",
|
heading="Emby for Kodi",
|
||||||
message="Adding %s items to playlist." % len(itemIds),
|
message="%s %s" % (len(itemIds), lang(33004)),
|
||||||
icon="special://home/addons/plugin.video.emby/icon.png",
|
icon="special://home/addons/plugin.video.emby/icon.png",
|
||||||
sound=False)
|
sound=False)
|
||||||
startat = data.get('StartPositionTicks', 0)
|
startat = data.get('StartPositionTicks', 0)
|
||||||
|
@ -95,7 +101,7 @@ class WebSocket_Client(threading.Thread):
|
||||||
elif command == "PlayNext":
|
elif command == "PlayNext":
|
||||||
dialog.notification(
|
dialog.notification(
|
||||||
heading="Emby for Kodi",
|
heading="Emby for Kodi",
|
||||||
message="Queueing %s items to playlist." % len(itemIds),
|
message="%s %s" % (len(itemIds), lang(33005)),
|
||||||
icon="special://home/addons/plugin.video.emby/icon.png",
|
icon="special://home/addons/plugin.video.emby/icon.png",
|
||||||
sound=False)
|
sound=False)
|
||||||
newplaylist = pl.modifyPlaylist(itemIds)
|
newplaylist = pl.modifyPlaylist(itemIds)
|
||||||
|
@ -123,12 +129,12 @@ class WebSocket_Client(threading.Thread):
|
||||||
seekto = data['SeekPositionTicks']
|
seekto = data['SeekPositionTicks']
|
||||||
seektime = seekto / 10000000.0
|
seektime = seekto / 10000000.0
|
||||||
action(seektime)
|
action(seektime)
|
||||||
self.logMsg("Seek to %s." % seektime, 1)
|
log("Seek to %s." % seektime, 1)
|
||||||
else:
|
else:
|
||||||
action()
|
action()
|
||||||
self.logMsg("Command: %s completed." % command, 1)
|
log("Command: %s completed." % command, 1)
|
||||||
|
|
||||||
utils.window('emby_command', value="true")
|
window('emby_command', value="true")
|
||||||
|
|
||||||
elif messageType == "UserDataChanged":
|
elif messageType == "UserDataChanged":
|
||||||
# A user changed their personal rating for an item, or their playstate was updated
|
# A user changed their personal rating for an item, or their playstate was updated
|
||||||
|
@ -171,7 +177,7 @@ class WebSocket_Client(threading.Thread):
|
||||||
embyindex = int(arguments['Index'])
|
embyindex = int(arguments['Index'])
|
||||||
currentFile = player.getPlayingFile()
|
currentFile = player.getPlayingFile()
|
||||||
|
|
||||||
mapping = utils.window('emby_%s.indexMapping' % currentFile)
|
mapping = window('emby_%s.indexMapping' % currentFile)
|
||||||
if mapping:
|
if mapping:
|
||||||
externalIndex = json.loads(mapping)
|
externalIndex = json.loads(mapping)
|
||||||
# If there's external subtitles added via playbackutils
|
# If there's external subtitles added via playbackutils
|
||||||
|
@ -190,7 +196,7 @@ class WebSocket_Client(threading.Thread):
|
||||||
player.setSubtitleStream(index - audioTracks - 1)
|
player.setSubtitleStream(index - audioTracks - 1)
|
||||||
|
|
||||||
# Let service know
|
# Let service know
|
||||||
utils.window('emby_command', value="true")
|
window('emby_command', value="true")
|
||||||
|
|
||||||
elif command == "DisplayMessage":
|
elif command == "DisplayMessage":
|
||||||
|
|
||||||
|
@ -249,8 +255,8 @@ class WebSocket_Client(threading.Thread):
|
||||||
elif messageType == "ServerRestarting":
|
elif messageType == "ServerRestarting":
|
||||||
if utils.settings('supressRestartMsg') == "true":
|
if utils.settings('supressRestartMsg') == "true":
|
||||||
xbmcgui.Dialog().notification(
|
xbmcgui.Dialog().notification(
|
||||||
heading="Emby server",
|
heading="Emby for Kodi",
|
||||||
message="Server is restarting.",
|
message=lang(33006),
|
||||||
icon="special://home/addons/plugin.video.emby/icon.png")
|
icon="special://home/addons/plugin.video.emby/icon.png")
|
||||||
|
|
||||||
elif messageType == "UserConfigurationUpdated":
|
elif messageType == "UserConfigurationUpdated":
|
||||||
|
@ -273,13 +279,16 @@ class WebSocket_Client(threading.Thread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
|
log = self.logMsg
|
||||||
|
window = utils.window
|
||||||
monitor = self.monitor
|
monitor = self.monitor
|
||||||
loglevel = int(utils.window('emby_logLevel'))
|
|
||||||
|
loglevel = int(window('emby_logLevel'))
|
||||||
# websocket.enableTrace(True)
|
# websocket.enableTrace(True)
|
||||||
|
|
||||||
userId = utils.window('emby_currUser')
|
userId = window('emby_currUser')
|
||||||
server = utils.window('emby_server%s' % userId)
|
server = window('emby_server%s' % userId)
|
||||||
token = utils.window('emby_accessToken%s' % userId)
|
token = window('emby_accessToken%s' % userId)
|
||||||
deviceId = self.deviceId
|
deviceId = self.deviceId
|
||||||
|
|
||||||
# Get the appropriate prefix for the websocket
|
# Get the appropriate prefix for the websocket
|
||||||
|
@ -289,7 +298,7 @@ class WebSocket_Client(threading.Thread):
|
||||||
server = server.replace('http', "ws")
|
server = server.replace('http', "ws")
|
||||||
|
|
||||||
websocket_url = "%s?api_key=%s&deviceId=%s" % (server, token, deviceId)
|
websocket_url = "%s?api_key=%s&deviceId=%s" % (server, token, deviceId)
|
||||||
self.logMsg("websocket url: %s" % websocket_url, 1)
|
log("websocket url: %s" % websocket_url, 1)
|
||||||
|
|
||||||
self.client = websocket.WebSocketApp(websocket_url,
|
self.client = websocket.WebSocketApp(websocket_url,
|
||||||
on_message=self.on_message,
|
on_message=self.on_message,
|
||||||
|
@ -297,11 +306,11 @@ class WebSocket_Client(threading.Thread):
|
||||||
on_close=self.on_close)
|
on_close=self.on_close)
|
||||||
|
|
||||||
self.client.on_open = self.on_open
|
self.client.on_open = self.on_open
|
||||||
self.logMsg("----===## Starting WebSocketClient ##===----", 0)
|
log("----===## Starting WebSocketClient ##===----", 0)
|
||||||
|
|
||||||
while not monitor.abortRequested():
|
while not monitor.abortRequested():
|
||||||
|
|
||||||
self.client.run_forever(ping_interval = 10)
|
self.client.run_forever(ping_interval=10)
|
||||||
if self.stopWebsocket:
|
if self.stopWebsocket:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -309,7 +318,7 @@ class WebSocket_Client(threading.Thread):
|
||||||
# Abort was requested, exit
|
# Abort was requested, exit
|
||||||
break
|
break
|
||||||
|
|
||||||
self.logMsg("##===---- WebSocketClient Stopped ----===##", 0)
|
log("##===---- WebSocketClient Stopped ----===##", 0)
|
||||||
|
|
||||||
def stopClient(self):
|
def stopClient(self):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue