Improvements to Plex Companion daemon
- Still need improvements to tell the PMS and Plex Companion devices that we STOPPED playing something.
This commit is contained in:
parent
a248580f24
commit
caba11c43f
3 changed files with 21 additions and 10 deletions
|
@ -3,6 +3,7 @@ import threading
|
|||
import traceback
|
||||
import socket
|
||||
import Queue
|
||||
import threading
|
||||
|
||||
import xbmc
|
||||
|
||||
|
@ -164,6 +165,9 @@ class PlexCompanion(threading.Thread):
|
|||
client.start_all()
|
||||
|
||||
message_count = 0
|
||||
if httpd:
|
||||
t = threading.Thread(target=httpd.handle_request)
|
||||
|
||||
while not threadStopped():
|
||||
# If we are not authorized, sleep
|
||||
# Otherwise, we trigger a download which leads to a
|
||||
|
@ -173,23 +177,27 @@ class PlexCompanion(threading.Thread):
|
|||
break
|
||||
xbmc.sleep(1000)
|
||||
try:
|
||||
if httpd:
|
||||
httpd.handle_request()
|
||||
message_count += 1
|
||||
if httpd:
|
||||
if not t.isAlive():
|
||||
t = threading.Thread(target=httpd.handle_request)
|
||||
t.start()
|
||||
|
||||
if message_count > 100:
|
||||
if message_count == 3000:
|
||||
message_count = 0
|
||||
if client.check_client_registration():
|
||||
log("Client is still registered", 1)
|
||||
else:
|
||||
log("Client is no longer registered", 1)
|
||||
log("Plex Companion still running on port %s"
|
||||
% self.settings['myport'], 1)
|
||||
message_count = 0
|
||||
|
||||
# Get and set servers
|
||||
if message_count % 30 == 0:
|
||||
subscriptionManager.serverlist = client.getServerList()
|
||||
|
||||
subscriptionManager.notify()
|
||||
if not httpd:
|
||||
message_count = 0
|
||||
except:
|
||||
log("Error in loop, continuing anyway. Traceback:", 1)
|
||||
log(traceback.format_exc(), 1)
|
||||
|
@ -202,7 +210,9 @@ class PlexCompanion(threading.Thread):
|
|||
# Got instructions, process them
|
||||
self.processTasks(task)
|
||||
queue.task_done()
|
||||
xbmc.sleep(10)
|
||||
# Don't sleep
|
||||
continue
|
||||
xbmc.sleep(20)
|
||||
|
||||
client.stop_all()
|
||||
if httpd:
|
||||
|
|
|
@ -192,15 +192,18 @@ class MyHandler(BaseHTTPRequestHandler):
|
|||
for playerid in js.getPlayerIds():
|
||||
js.jsonrpc("Player.PlayPause",
|
||||
{"playerid": playerid, "play": True})
|
||||
subMgr.notify()
|
||||
elif request_path == "player/playback/pause":
|
||||
self.response(getOKMsg(), js.getPlexHeaders())
|
||||
for playerid in js.getPlayerIds():
|
||||
js.jsonrpc("Player.PlayPause",
|
||||
{"playerid": playerid, "play": False})
|
||||
subMgr.notify()
|
||||
elif request_path == "player/playback/stop":
|
||||
self.response(getOKMsg(), js.getPlexHeaders())
|
||||
for playerid in js.getPlayerIds():
|
||||
js.jsonrpc("Player.Stop", {"playerid": playerid})
|
||||
subMgr.notify()
|
||||
elif request_path == "player/playback/seekTo":
|
||||
self.response(getOKMsg(), js.getPlexHeaders())
|
||||
for playerid in js.getPlayerIds():
|
||||
|
|
|
@ -150,8 +150,6 @@ class SubscriptionManager:
|
|||
return True
|
||||
|
||||
def notifyServer(self, players):
|
||||
if not players:
|
||||
return True
|
||||
for p in players.values():
|
||||
info = self.playerprops[p.get('playerid')]
|
||||
params = {'state': 'stopped'}
|
||||
|
|
Loading…
Reference in a new issue