Remove plexbmc plexsettings.py
This commit is contained in:
parent
90c76aa997
commit
41abcc8d2c
5 changed files with 22 additions and 90 deletions
|
@ -8,8 +8,7 @@ from urllib import urlencode
|
||||||
from xbmc import sleep, executebuiltin
|
from xbmc import sleep, executebuiltin
|
||||||
|
|
||||||
from utils import settings, thread_methods
|
from utils import settings, thread_methods
|
||||||
from plexbmchelper import listener, plexgdm, subscribers, httppersist, \
|
from plexbmchelper import listener, plexgdm, subscribers, httppersist
|
||||||
plexsettings
|
|
||||||
from PlexFunctions import ParseContainerKey, GetPlexMetadata
|
from PlexFunctions import ParseContainerKey, GetPlexMetadata
|
||||||
from PlexAPI import API
|
from PlexAPI import API
|
||||||
from playlist_func import get_pms_playqueue, get_plextype_from_xml
|
from playlist_func import get_pms_playqueue, get_plextype_from_xml
|
||||||
|
@ -32,10 +31,9 @@ class PlexCompanion(Thread):
|
||||||
log.info("----===## Starting PlexCompanion ##===----")
|
log.info("----===## Starting PlexCompanion ##===----")
|
||||||
if callback is not None:
|
if callback is not None:
|
||||||
self.mgr = callback
|
self.mgr = callback
|
||||||
self.settings = plexsettings.getSettings()
|
|
||||||
# Start GDM for server/client discovery
|
# Start GDM for server/client discovery
|
||||||
self.client = plexgdm.plexgdm()
|
self.client = plexgdm.plexgdm()
|
||||||
self.client.clientDetails(self.settings)
|
self.client.clientDetails()
|
||||||
log.debug("Registration string is:\n%s"
|
log.debug("Registration string is:\n%s"
|
||||||
% self.client.getClientDetails())
|
% self.client.getClientDetails())
|
||||||
# kodi player instance
|
# kodi player instance
|
||||||
|
@ -210,9 +208,8 @@ class PlexCompanion(Thread):
|
||||||
httpd = listener.ThreadedHTTPServer(
|
httpd = listener.ThreadedHTTPServer(
|
||||||
client,
|
client,
|
||||||
subscriptionManager,
|
subscriptionManager,
|
||||||
self.settings,
|
|
||||||
queue,
|
queue,
|
||||||
('', self.settings['myport']),
|
('', v.COMPANION_PORT),
|
||||||
listener.MyHandler)
|
listener.MyHandler)
|
||||||
httpd.timeout = 0.95
|
httpd.timeout = 0.95
|
||||||
break
|
break
|
||||||
|
@ -261,7 +258,7 @@ class PlexCompanion(Thread):
|
||||||
else:
|
else:
|
||||||
log.debug("Client is no longer registered. "
|
log.debug("Client is no longer registered. "
|
||||||
"Plex Companion still running on port %s"
|
"Plex Companion still running on port %s"
|
||||||
% self.settings['myport'])
|
% v.COMPANION_PORT)
|
||||||
client.register_as_client()
|
client.register_as_client()
|
||||||
# Get and set servers
|
# Get and set servers
|
||||||
if message_count % 30 == 0:
|
if message_count % 30 == 0:
|
||||||
|
|
|
@ -46,8 +46,7 @@ class MyHandler(BaseHTTPRequestHandler):
|
||||||
def do_OPTIONS(self):
|
def do_OPTIONS(self):
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-Length', '0')
|
self.send_header('Content-Length', '0')
|
||||||
self.send_header('X-Plex-Client-Identifier',
|
self.send_header('X-Plex-Client-Identifier', v.PKC_MACHINE_IDENTIFIER)
|
||||||
self.server.settings['uuid'])
|
|
||||||
self.send_header('Content-Type', 'text/plain')
|
self.send_header('Content-Type', 'text/plain')
|
||||||
self.send_header('Connection', 'close')
|
self.send_header('Connection', 'close')
|
||||||
self.send_header('Access-Control-Max-Age', '1209600')
|
self.send_header('Access-Control-Max-Age', '1209600')
|
||||||
|
@ -82,7 +81,6 @@ class MyHandler(BaseHTTPRequestHandler):
|
||||||
def answer_request(self, sendData):
|
def answer_request(self, sendData):
|
||||||
self.serverlist = self.server.client.getServerList()
|
self.serverlist = self.server.client.getServerList()
|
||||||
subMgr = self.server.subscriptionManager
|
subMgr = self.server.subscriptionManager
|
||||||
settings = self.server.settings
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
request_path = self.path[1:]
|
request_path = self.path[1:]
|
||||||
|
@ -101,7 +99,7 @@ class MyHandler(BaseHTTPRequestHandler):
|
||||||
if request_path == "version":
|
if request_path == "version":
|
||||||
self.response(
|
self.response(
|
||||||
"PlexKodiConnect Plex Companion: Running\nVersion: %s"
|
"PlexKodiConnect Plex Companion: Running\nVersion: %s"
|
||||||
% settings['version'])
|
% v.ADDON_VERSION)
|
||||||
elif request_path == "verify":
|
elif request_path == "verify":
|
||||||
self.response("XBMC JSON connection test:\n" +
|
self.response("XBMC JSON connection test:\n" +
|
||||||
js.ping())
|
js.ping())
|
||||||
|
@ -121,10 +119,10 @@ class MyHandler(BaseHTTPRequestHandler):
|
||||||
'/>'
|
'/>'
|
||||||
'</MediaContainer>'
|
'</MediaContainer>'
|
||||||
% (v.XML_HEADER,
|
% (v.XML_HEADER,
|
||||||
settings['client_name'],
|
v.DEVICENAME,
|
||||||
settings['uuid'],
|
v.PKC_MACHINE_IDENTIFIER,
|
||||||
settings['platform'],
|
v.PLATFORM,
|
||||||
settings['plexbmc_version']))
|
v.ADDON_VERSION))
|
||||||
log.debug("crafted resources response: %s" % resp)
|
log.debug("crafted resources response: %s" % resp)
|
||||||
self.response(resp, getXArgsDeviceInfo(include_token=False))
|
self.response(resp, getXArgsDeviceInfo(include_token=False))
|
||||||
elif "/subscribe" in request_path:
|
elif "/subscribe" in request_path:
|
||||||
|
@ -149,7 +147,7 @@ class MyHandler(BaseHTTPRequestHandler):
|
||||||
str(commandID),
|
str(commandID),
|
||||||
subMgr.msg(js.get_players())),
|
subMgr.msg(js.get_players())),
|
||||||
{
|
{
|
||||||
'X-Plex-Client-Identifier': settings['uuid'],
|
'X-Plex-Client-Identifier': v.PKC_MACHINE_IDENTIFIER,
|
||||||
'Access-Control-Expose-Headers':
|
'Access-Control-Expose-Headers':
|
||||||
'X-Plex-Client-Identifier',
|
'X-Plex-Client-Identifier',
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
@ -175,8 +173,7 @@ class MyHandler(BaseHTTPRequestHandler):
|
||||||
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
|
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
|
||||||
daemon_threads = True
|
daemon_threads = True
|
||||||
|
|
||||||
def __init__(self, client, subscriptionManager, settings,
|
def __init__(self, client, subscriptionManager, queue, *args, **kwargs):
|
||||||
queue, *args, **kwargs):
|
|
||||||
"""
|
"""
|
||||||
client: Class handle to plexgdm.plexgdm. We can thus ask for an up-to-
|
client: Class handle to plexgdm.plexgdm. We can thus ask for an up-to-
|
||||||
date serverlist without instantiating anything
|
date serverlist without instantiating anything
|
||||||
|
@ -185,6 +182,5 @@ class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
|
||||||
"""
|
"""
|
||||||
self.client = client
|
self.client = client
|
||||||
self.subscriptionManager = subscriptionManager
|
self.subscriptionManager = subscriptionManager
|
||||||
self.settings = settings
|
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
HTTPServer.__init__(self, *args, **kwargs)
|
HTTPServer.__init__(self, *args, **kwargs)
|
||||||
|
|
|
@ -30,6 +30,7 @@ from xbmc import sleep
|
||||||
|
|
||||||
import downloadutils
|
import downloadutils
|
||||||
from utils import window, settings, dialog, language
|
from utils import window, settings, dialog, language
|
||||||
|
import variables as v
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -44,7 +45,6 @@ class plexgdm:
|
||||||
self.discover_message = 'M-SEARCH * HTTP/1.0'
|
self.discover_message = 'M-SEARCH * HTTP/1.0'
|
||||||
self.client_header = '* HTTP/1.0'
|
self.client_header = '* HTTP/1.0'
|
||||||
self.client_data = None
|
self.client_data = None
|
||||||
self.client_id = None
|
|
||||||
|
|
||||||
self._multicast_address = '239.0.0.250'
|
self._multicast_address = '239.0.0.250'
|
||||||
self.discover_group = (self._multicast_address, 32414)
|
self.discover_group = (self._multicast_address, 32414)
|
||||||
|
@ -60,7 +60,7 @@ class plexgdm:
|
||||||
self.client_registered = False
|
self.client_registered = False
|
||||||
self.download = downloadutils.DownloadUtils().downloadUrl
|
self.download = downloadutils.DownloadUtils().downloadUrl
|
||||||
|
|
||||||
def clientDetails(self, options):
|
def clientDetails(self):
|
||||||
self.client_data = (
|
self.client_data = (
|
||||||
"Content-Type: plex/media-player\n"
|
"Content-Type: plex/media-player\n"
|
||||||
"Resource-Identifier: %s\n"
|
"Resource-Identifier: %s\n"
|
||||||
|
@ -74,13 +74,12 @@ class plexgdm:
|
||||||
"playqueues\n"
|
"playqueues\n"
|
||||||
"Device-Class: HTPC\n"
|
"Device-Class: HTPC\n"
|
||||||
) % (
|
) % (
|
||||||
options['uuid'],
|
v.PKC_MACHINE_IDENTIFIER,
|
||||||
options['client_name'],
|
v.DEVICENAME,
|
||||||
options['myport'],
|
v.COMPANION_PORT,
|
||||||
options['addonName'],
|
v.ADDON_NAME,
|
||||||
options['version']
|
v.ADDON_VERSION
|
||||||
)
|
)
|
||||||
self.client_id = options['uuid']
|
|
||||||
|
|
||||||
def getClientDetails(self):
|
def getClientDetails(self):
|
||||||
return self.client_data
|
return self.client_data
|
||||||
|
@ -211,7 +210,7 @@ class plexgdm:
|
||||||
registered = False
|
registered = False
|
||||||
for client in xml:
|
for client in xml:
|
||||||
if (client.attrib.get('machineIdentifier') ==
|
if (client.attrib.get('machineIdentifier') ==
|
||||||
self.client_id):
|
v.PKC_MACHINE_IDENTIFIER):
|
||||||
registered = True
|
registered = True
|
||||||
if registered:
|
if registered:
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
import logging
|
|
||||||
from utils import guisettingsXML, settings
|
|
||||||
import variables as v
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
log = logging.getLogger("PLEX."+__name__)
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
def getGUI(name):
|
|
||||||
xml = guisettingsXML()
|
|
||||||
try:
|
|
||||||
ans = list(xml.iter(name))[0].text
|
|
||||||
if ans is None:
|
|
||||||
ans = ''
|
|
||||||
except:
|
|
||||||
ans = ''
|
|
||||||
return ans
|
|
||||||
|
|
||||||
|
|
||||||
def getSettings():
|
|
||||||
options = {}
|
|
||||||
|
|
||||||
options['gdm_debug'] = settings('companionGDMDebugging')
|
|
||||||
options['gdm_debug'] = True if options['gdm_debug'] == 'true' else False
|
|
||||||
|
|
||||||
options['client_name'] = v.DEVICENAME
|
|
||||||
|
|
||||||
# XBMC web server options
|
|
||||||
options['webserver_enabled'] = (getGUI('webserver') == "true")
|
|
||||||
log.info('Webserver is set to %s' % options['webserver_enabled'])
|
|
||||||
webserverport = getGUI('webserverport')
|
|
||||||
try:
|
|
||||||
webserverport = int(webserverport)
|
|
||||||
log.info('Using webserver port %s' % str(webserverport))
|
|
||||||
except:
|
|
||||||
log.info('No setting for webserver port found in guisettings.xml.'
|
|
||||||
'Using default fallback port 8080')
|
|
||||||
webserverport = 8080
|
|
||||||
options['port'] = webserverport
|
|
||||||
|
|
||||||
options['user'] = getGUI('webserverusername')
|
|
||||||
options['passwd'] = getGUI('webserverpassword')
|
|
||||||
log.info('Webserver username: %s, password: %s'
|
|
||||||
% (options['user'], options['passwd']))
|
|
||||||
|
|
||||||
options['addonName'] = v.ADDON_NAME
|
|
||||||
options['uuid'] = settings('plex_client_Id')
|
|
||||||
options['platform'] = v.PLATFORM
|
|
||||||
options['version'] = v.ADDON_VERSION
|
|
||||||
options['plexbmc_version'] = options['version']
|
|
||||||
options['myplex_user'] = settings('username')
|
|
||||||
try:
|
|
||||||
options['myport'] = int(settings('companionPort'))
|
|
||||||
log.info('Using Plex Companion Port %s' % str(options['myport']))
|
|
||||||
except:
|
|
||||||
log.error('Error getting Plex Companion Port from file settings. '
|
|
||||||
'Using fallback port 39005')
|
|
||||||
options['myport'] = 39005
|
|
||||||
return options
|
|
|
@ -63,6 +63,8 @@ DEVICENAME = DEVICENAME.replace('(', "")
|
||||||
DEVICENAME = DEVICENAME.replace(')', "")
|
DEVICENAME = DEVICENAME.replace(')', "")
|
||||||
DEVICENAME = DEVICENAME.strip()
|
DEVICENAME = DEVICENAME.strip()
|
||||||
|
|
||||||
|
COMPANION_PORT = int(_ADDON.getSetting('companionPort'))
|
||||||
|
|
||||||
# Unique ID for this Plex client; also see clientinfo.py
|
# Unique ID for this Plex client; also see clientinfo.py
|
||||||
PKC_MACHINE_IDENTIFIER = None
|
PKC_MACHINE_IDENTIFIER = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue