From 82b7128c04900b8ce11c581d148fb7996c1cf3f3 Mon Sep 17 00:00:00 2001
From: Tim Van
Date: Mon, 8 Feb 2016 01:28:58 +0200
Subject: [PATCH] Allow secure websocket connections.
---
data/interfaces/default/settings.html | 2 +-
plexpy/web_socket.py | 11 +++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html
index 3e10c49c..84b97e32 100644
--- a/data/interfaces/default/settings.html
+++ b/data/interfaces/default/settings.html
@@ -490,7 +490,7 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
Use Websocket (requires restart) [experimental]
Instead of polling the server at regular intervals let the server tell us when something happens.
- This is currently experimental. Encrypted websocket is not currently supported.
+ This is currently experimental.
diff --git a/plexpy/web_socket.py b/plexpy/web_socket.py
index dc2a3f29..0d4fc88a 100644
--- a/plexpy/web_socket.py
+++ b/plexpy/web_socket.py
@@ -37,10 +37,13 @@ def start_thread():
def run():
from websocket import create_connection
- uri = 'ws://%s:%s/:/websockets/notifications' % (
- plexpy.CONFIG.PMS_IP,
- plexpy.CONFIG.PMS_PORT
- )
+ if plexpy.CONFIG.PMS_SSL and plexpy.CONFIG.PMS_URL[:5] == 'https':
+ uri = plexpy.CONFIG.PMS_URL.replace('https://', 'wss://') + '/:/websockets/notifications'
+ else:
+ uri = 'ws://%s:%s/:/websockets/notifications' % (
+ plexpy.CONFIG.PMS_IP,
+ plexpy.CONFIG.PMS_PORT
+ )
# Set authentication token (if one is available)
if plexpy.CONFIG.PMS_TOKEN: