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 utils import settings, thread_methods
|
||||
from plexbmchelper import listener, plexgdm, subscribers, httppersist, \
|
||||
plexsettings
|
||||
from plexbmchelper import listener, plexgdm, subscribers, httppersist
|
||||
from PlexFunctions import ParseContainerKey, GetPlexMetadata
|
||||
from PlexAPI import API
|
||||
from playlist_func import get_pms_playqueue, get_plextype_from_xml
|
||||
|
@ -32,10 +31,9 @@ class PlexCompanion(Thread):
|
|||
log.info("----===## Starting PlexCompanion ##===----")
|
||||
if callback is not None:
|
||||
self.mgr = callback
|
||||
self.settings = plexsettings.getSettings()
|
||||
# Start GDM for server/client discovery
|
||||
self.client = plexgdm.plexgdm()
|
||||
self.client.clientDetails(self.settings)
|
||||
self.client.clientDetails()
|
||||
log.debug("Registration string is:\n%s"
|
||||
% self.client.getClientDetails())
|
||||
# kodi player instance
|
||||
|
@ -210,9 +208,8 @@ class PlexCompanion(Thread):
|
|||
httpd = listener.ThreadedHTTPServer(
|
||||
client,
|
||||
subscriptionManager,
|
||||
self.settings,
|
||||
queue,
|
||||
('', self.settings['myport']),
|
||||
('', v.COMPANION_PORT),
|
||||
listener.MyHandler)
|
||||
httpd.timeout = 0.95
|
||||
break
|
||||
|
@ -261,7 +258,7 @@ class PlexCompanion(Thread):
|
|||
else:
|
||||
log.debug("Client is no longer registered. "
|
||||
"Plex Companion still running on port %s"
|
||||
% self.settings['myport'])
|
||||
% v.COMPANION_PORT)
|
||||
client.register_as_client()
|
||||
# Get and set servers
|
||||
if message_count % 30 == 0:
|
||||
|
|
|
@ -46,8 +46,7 @@ class MyHandler(BaseHTTPRequestHandler):
|
|||
def do_OPTIONS(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Length', '0')
|
||||
self.send_header('X-Plex-Client-Identifier',
|
||||
self.server.settings['uuid'])
|
||||
self.send_header('X-Plex-Client-Identifier', v.PKC_MACHINE_IDENTIFIER)
|
||||
self.send_header('Content-Type', 'text/plain')
|
||||
self.send_header('Connection', 'close')
|
||||
self.send_header('Access-Control-Max-Age', '1209600')
|
||||
|
@ -82,7 +81,6 @@ class MyHandler(BaseHTTPRequestHandler):
|
|||
def answer_request(self, sendData):
|
||||
self.serverlist = self.server.client.getServerList()
|
||||
subMgr = self.server.subscriptionManager
|
||||
settings = self.server.settings
|
||||
|
||||
try:
|
||||
request_path = self.path[1:]
|
||||
|
@ -101,7 +99,7 @@ class MyHandler(BaseHTTPRequestHandler):
|
|||
if request_path == "version":
|
||||
self.response(
|
||||
"PlexKodiConnect Plex Companion: Running\nVersion: %s"
|
||||
% settings['version'])
|
||||
% v.ADDON_VERSION)
|
||||
elif request_path == "verify":
|
||||
self.response("XBMC JSON connection test:\n" +
|
||||
js.ping())
|
||||
|
@ -121,10 +119,10 @@ class MyHandler(BaseHTTPRequestHandler):
|
|||
'/>'
|
||||
'</MediaContainer>'
|
||||
% (v.XML_HEADER,
|
||||
settings['client_name'],
|
||||
settings['uuid'],
|
||||
settings['platform'],
|
||||
settings['plexbmc_version']))
|
||||
v.DEVICENAME,
|
||||
v.PKC_MACHINE_IDENTIFIER,
|
||||
v.PLATFORM,
|
||||
v.ADDON_VERSION))
|
||||
log.debug("crafted resources response: %s" % resp)
|
||||
self.response(resp, getXArgsDeviceInfo(include_token=False))
|
||||
elif "/subscribe" in request_path:
|
||||
|
@ -149,7 +147,7 @@ class MyHandler(BaseHTTPRequestHandler):
|
|||
str(commandID),
|
||||
subMgr.msg(js.get_players())),
|
||||
{
|
||||
'X-Plex-Client-Identifier': settings['uuid'],
|
||||
'X-Plex-Client-Identifier': v.PKC_MACHINE_IDENTIFIER,
|
||||
'Access-Control-Expose-Headers':
|
||||
'X-Plex-Client-Identifier',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
|
@ -175,8 +173,7 @@ class MyHandler(BaseHTTPRequestHandler):
|
|||
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
|
||||
daemon_threads = True
|
||||
|
||||
def __init__(self, client, subscriptionManager, settings,
|
||||
queue, *args, **kwargs):
|
||||
def __init__(self, client, subscriptionManager, queue, *args, **kwargs):
|
||||
"""
|
||||
client: Class handle to plexgdm.plexgdm. We can thus ask for an up-to-
|
||||
date serverlist without instantiating anything
|
||||
|
@ -185,6 +182,5 @@ class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
|
|||
"""
|
||||
self.client = client
|
||||
self.subscriptionManager = subscriptionManager
|
||||
self.settings = settings
|
||||
self.queue = queue
|
||||
HTTPServer.__init__(self, *args, **kwargs)
|
||||
|
|
|
@ -30,6 +30,7 @@ from xbmc import sleep
|
|||
|
||||
import downloadutils
|
||||
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.client_header = '* HTTP/1.0'
|
||||
self.client_data = None
|
||||
self.client_id = None
|
||||
|
||||
self._multicast_address = '239.0.0.250'
|
||||
self.discover_group = (self._multicast_address, 32414)
|
||||
|
@ -60,7 +60,7 @@ class plexgdm:
|
|||
self.client_registered = False
|
||||
self.download = downloadutils.DownloadUtils().downloadUrl
|
||||
|
||||
def clientDetails(self, options):
|
||||
def clientDetails(self):
|
||||
self.client_data = (
|
||||
"Content-Type: plex/media-player\n"
|
||||
"Resource-Identifier: %s\n"
|
||||
|
@ -74,13 +74,12 @@ class plexgdm:
|
|||
"playqueues\n"
|
||||
"Device-Class: HTPC\n"
|
||||
) % (
|
||||
options['uuid'],
|
||||
options['client_name'],
|
||||
options['myport'],
|
||||
options['addonName'],
|
||||
options['version']
|
||||
v.PKC_MACHINE_IDENTIFIER,
|
||||
v.DEVICENAME,
|
||||
v.COMPANION_PORT,
|
||||
v.ADDON_NAME,
|
||||
v.ADDON_VERSION
|
||||
)
|
||||
self.client_id = options['uuid']
|
||||
|
||||
def getClientDetails(self):
|
||||
return self.client_data
|
||||
|
@ -211,7 +210,7 @@ class plexgdm:
|
|||
registered = False
|
||||
for client in xml:
|
||||
if (client.attrib.get('machineIdentifier') ==
|
||||
self.client_id):
|
||||
v.PKC_MACHINE_IDENTIFIER):
|
||||
registered = True
|
||||
if registered:
|
||||
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.strip()
|
||||
|
||||
COMPANION_PORT = int(_ADDON.getSetting('companionPort'))
|
||||
|
||||
# Unique ID for this Plex client; also see clientinfo.py
|
||||
PKC_MACHINE_IDENTIFIER = None
|
||||
|
||||
|
|
Loading…
Reference in a new issue