This commit is contained in:
tomkat83 2016-03-07 17:11:54 +01:00
parent a258f969ab
commit e9e1de6e3d

View file

@ -88,36 +88,40 @@ class InitialSetup():
plexToken = result['token'] plexToken = result['token']
plexid = result['plexid'] plexid = result['plexid']
# Get g_PMS list of servers (saved to plx.g_PMS) # Get g_PMS list of servers (saved to plx.g_PMS)
httpsUpdated = False
while True: while True:
tokenDict = {'MyPlexToken': plexToken} if plexToken else {} if httpsUpdated is False:
# Populate g_PMS variable with the found Plex servers tokenDict = {'MyPlexToken': plexToken} if plexToken else {}
self.plx.discoverPMS(clientId, # Populate g_PMS variable with the found Plex servers
None, self.plx.discoverPMS(clientId,
xbmc.getIPAddress(), None,
tokenDict=tokenDict) xbmc.getIPAddress(),
self.logMsg("Result of setting g_PMS variable: %s" tokenDict=tokenDict)
% self.plx.g_PMS, 2) self.logMsg("Result of setting g_PMS variable: %s"
isconnected = False % self.plx.g_PMS, 1)
serverlist = self.plx.returnServerList(clientId, self.plx.g_PMS) isconnected = False
# Let user pick server from a list serverlist = self.plx.returnServerList(
# Get a nicer list clientId, self.plx.g_PMS)
dialoglist = [] self.logMsg('PMS serverlist: %s' % serverlist)
# Exit if no servers found # Let user pick server from a list
if len(serverlist) == 0: # Get a nicer list
dialog.ok( dialoglist = []
self.addonName, # Exit if no servers found
string(39011).encode('utf-8') if len(serverlist) == 0:
) dialog.ok(
break self.addonName,
for server in serverlist: string(39011).encode('utf-8')
if server['local'] == '1': )
# server is in the same network as client. Add "local" break
dialoglist.append( for server in serverlist:
server['name'].encode('utf-8') if server['local'] == '1':
+ string(39022).encode('utf-8')) # server is in the same network as client. Add "local"
else: dialoglist.append(
dialoglist.append(server['name'].encode('utf-8')) server['name'].encode('utf-8')
resp = dialog.select(string(39012).encode('utf-8'), dialoglist) + string(39022).encode('utf-8'))
else:
dialoglist.append(server['name'].encode('utf-8'))
resp = dialog.select(string(39012).encode('utf-8'), dialoglist)
server = serverlist[resp] server = serverlist[resp]
activeServer = server['machineIdentifier'] activeServer = server['machineIdentifier']
url = server['scheme'] + '://' + server['ip'] + ':' + \ url = server['scheme'] + '://' + server['ip'] + ':' + \
@ -132,7 +136,12 @@ class InitialSetup():
self.logMsg("Setting SSL verify to true, because server is " self.logMsg("Setting SSL verify to true, because server is "
"not local", 1) "not local", 1)
chk = self.plx.CheckConnection(url, server['accesstoken']) chk = self.plx.CheckConnection(url, server['accesstoken'])
# Unauthorized if chk == 504 and httpsUpdated is False:
# Not able to use HTTP, try HTTPs for now
serverlist[resp]['scheme'] = 'https'
httpsUpdated = True
continue
httpsUpdated = False
if chk == 401: if chk == 401:
# Not yet authorized for Plex server # Not yet authorized for Plex server
# Please sign in to plex.tv # Please sign in to plex.tv