Browse Source

Added HTTPS and Port support to Plex notifications

pull/7279/head
Lee Hilton 7 years ago
parent
commit
3ff0e7ebdd
  1. 13
      couchpotato/core/notifications/plex/__init__.py
  2. 8
      couchpotato/core/notifications/plex/server.py

13
couchpotato/core/notifications/plex/__init__.py

@ -24,6 +24,19 @@ config = [{
'description': 'Hostname/IP, default localhost' 'description': 'Hostname/IP, default localhost'
}, },
{ {
'name': 'media_server_port',
'label': 'Port',
'default': '32400',
'description': 'Connection tot he Media Server should use this port'
},
{
'name': 'use_https',
'label': 'Use HTTPS',
'default': '0',
'type': 'bool',
'description': 'Connection to the Media Server should use HTTPS instead of HTTP'
},
{
'name': 'username', 'name': 'username',
'label': 'Username', 'label': 'Username',
'default': '', 'default': '',

8
couchpotato/core/notifications/plex/server.py

@ -38,7 +38,7 @@ class PlexServer(object):
#Maintain support for older Plex installations without myPlex #Maintain support for older Plex installations without myPlex
if not self.plex.conf('auth_token') and not self.plex.conf('username') and not self.plex.conf('password'): if not self.plex.conf('auth_token') and not self.plex.conf('username') and not self.plex.conf('password'):
data = self.plex.urlopen('%s/%s' % ( data = self.plex.urlopen('%s/%s' % (
self.createHost(self.plex.conf('media_server'), port = 32400), self.createHost(self.plex.conf('media_server'), port = self.plex.conf('media_server_port'), use_https = self.plex.conf('use_https')),
path path
)) ))
else: else:
@ -71,7 +71,7 @@ class PlexServer(object):
#Add X-Plex-Token header for myPlex support workaround #Add X-Plex-Token header for myPlex support workaround
data = self.plex.urlopen('%s/%s?X-Plex-Token=%s' % ( data = self.plex.urlopen('%s/%s?X-Plex-Token=%s' % (
self.createHost(self.plex.conf('media_server'), port = 32400), self.createHost(self.plex.conf('media_server'), port = self.plex.conf('media_server_port'), use_https = self.plex.conf('use_https')),
path, path,
self.plex.conf('auth_token') self.plex.conf('auth_token')
)) ))
@ -139,9 +139,9 @@ class PlexServer(object):
return True return True
def createHost(self, host, port = None): def createHost(self, host, port = None, use_https = False):
h = cleanHost(host) h = cleanHost(host, True, use_https)
p = urlparse(h) p = urlparse(h)
h = h.rstrip('/') h = h.rstrip('/')

Loading…
Cancel
Save