Merge pull request #673 from croneter/pr_improve_dialogs
Improve pop-up "Searching for PMS"
This commit is contained in:
commit
7f0abcee7d
1 changed files with 47 additions and 33 deletions
|
@ -220,7 +220,7 @@ class InitialSetup(object):
|
||||||
verifySSL=verifySSL)
|
verifySSL=verifySSL)
|
||||||
return chk
|
return chk
|
||||||
|
|
||||||
def pick_pms(self, showDialog=False):
|
def pick_pms(self, showDialog=False, inform_of_search=False):
|
||||||
"""
|
"""
|
||||||
Searches for PMS in local Lan and optionally (if self.plex_token set)
|
Searches for PMS in local Lan and optionally (if self.plex_token set)
|
||||||
also on plex.tv
|
also on plex.tv
|
||||||
|
@ -260,10 +260,10 @@ class InitialSetup(object):
|
||||||
if showDialog is True:
|
if showDialog is True:
|
||||||
server = self._user_pick_pms()
|
server = self._user_pick_pms()
|
||||||
else:
|
else:
|
||||||
server = self._auto_pick_pms()
|
server = self._auto_pick_pms(show_dialog=inform_of_search)
|
||||||
return server
|
return server
|
||||||
|
|
||||||
def _auto_pick_pms(self):
|
def _auto_pick_pms(self, show_dialog=False):
|
||||||
"""
|
"""
|
||||||
Will try to pick PMS based on machineIdentifier saved in file settings
|
Will try to pick PMS based on machineIdentifier saved in file settings
|
||||||
but only once
|
but only once
|
||||||
|
@ -272,35 +272,47 @@ class InitialSetup(object):
|
||||||
"""
|
"""
|
||||||
https_updated = False
|
https_updated = False
|
||||||
server = None
|
server = None
|
||||||
while True:
|
if show_dialog:
|
||||||
if https_updated is False:
|
# Searching for PMS
|
||||||
serverlist = PF.discover_pms(self.plex_token)
|
utils.dialog('notification',
|
||||||
for item in serverlist:
|
heading='{plex}',
|
||||||
if item.get('machineIdentifier') == app.CONN.machine_identifier:
|
message=utils.lang(30001),
|
||||||
server = item
|
icon='{plex}',
|
||||||
if server is None:
|
time=60000)
|
||||||
name = utils.settings('plex_servername')
|
try:
|
||||||
LOG.warn('The PMS you have used before with a unique '
|
while True:
|
||||||
'machineIdentifier of %s and name %s is '
|
if https_updated is False:
|
||||||
'offline', app.CONN.machine_identifier, name)
|
serverlist = PF.discover_pms(self.plex_token)
|
||||||
|
for item in serverlist:
|
||||||
|
if item.get('machineIdentifier') == app.CONN.machine_identifier:
|
||||||
|
server = item
|
||||||
|
if server is None:
|
||||||
|
name = utils.settings('plex_servername')
|
||||||
|
LOG.warn('The PMS you have used before with a unique '
|
||||||
|
'machineIdentifier of %s and name %s is '
|
||||||
|
'offline', app.CONN.machine_identifier, name)
|
||||||
|
return
|
||||||
|
chk = self._check_pms_connectivity(server)
|
||||||
|
if chk == 504 and https_updated is False:
|
||||||
|
# switch HTTPS to HTTP or vice-versa
|
||||||
|
if server['scheme'] == 'https':
|
||||||
|
server['scheme'] = 'http'
|
||||||
|
else:
|
||||||
|
server['scheme'] = 'https'
|
||||||
|
https_updated = True
|
||||||
|
continue
|
||||||
|
# Problems connecting
|
||||||
|
elif chk >= 400 or chk is False:
|
||||||
|
LOG.warn('Problems connecting to server %s. chk is %s',
|
||||||
|
server['name'], chk)
|
||||||
return
|
return
|
||||||
chk = self._check_pms_connectivity(server)
|
LOG.info('We found a server to automatically connect to: %s',
|
||||||
if chk == 504 and https_updated is False:
|
server['name'])
|
||||||
# switch HTTPS to HTTP or vice-versa
|
return server
|
||||||
if server['scheme'] == 'https':
|
finally:
|
||||||
server['scheme'] = 'http'
|
if show_dialog:
|
||||||
else:
|
executebuiltin("Dialog.Close(all, true)")
|
||||||
server['scheme'] = 'https'
|
|
||||||
https_updated = True
|
|
||||||
continue
|
|
||||||
# Problems connecting
|
|
||||||
elif chk >= 400 or chk is False:
|
|
||||||
LOG.warn('Problems connecting to server %s. chk is %s',
|
|
||||||
server['name'], chk)
|
|
||||||
return
|
|
||||||
LOG.info('We found a server to automatically connect to: %s',
|
|
||||||
server['name'])
|
|
||||||
return server
|
|
||||||
|
|
||||||
def _user_pick_pms(self):
|
def _user_pick_pms(self):
|
||||||
"""
|
"""
|
||||||
|
@ -314,7 +326,7 @@ class InitialSetup(object):
|
||||||
heading='{plex}',
|
heading='{plex}',
|
||||||
message=utils.lang(30001),
|
message=utils.lang(30001),
|
||||||
icon='{plex}',
|
icon='{plex}',
|
||||||
time=5000)
|
time=60000)
|
||||||
while True:
|
while True:
|
||||||
if https_updated is False:
|
if https_updated is False:
|
||||||
serverlist = PF.discover_pms(self.plex_token)
|
serverlist = PF.discover_pms(self.plex_token)
|
||||||
|
@ -343,6 +355,8 @@ class InitialSetup(object):
|
||||||
dialoglist.append('%s (%s)'
|
dialoglist.append('%s (%s)'
|
||||||
% (server['name'], msg))
|
% (server['name'], msg))
|
||||||
# Let user pick server from a list
|
# Let user pick server from a list
|
||||||
|
# Close the PKC info "Searching for PMS"
|
||||||
|
executebuiltin("Dialog.Close(all, true)")
|
||||||
resp = utils.dialog('select', utils.lang(39012), dialoglist)
|
resp = utils.dialog('select', utils.lang(39012), dialoglist)
|
||||||
if resp == -1:
|
if resp == -1:
|
||||||
# User cancelled
|
# User cancelled
|
||||||
|
@ -551,7 +565,7 @@ class InitialSetup(object):
|
||||||
if not self.plex_token and app.ACCOUNT.myplexlogin:
|
if not self.plex_token and app.ACCOUNT.myplexlogin:
|
||||||
self.plex_tv_sign_in()
|
self.plex_tv_sign_in()
|
||||||
|
|
||||||
server = self.pick_pms()
|
server = self.pick_pms(inform_of_search=True)
|
||||||
if server is not None:
|
if server is not None:
|
||||||
# Write our chosen server to Kodi settings file
|
# Write our chosen server to Kodi settings file
|
||||||
self.save_pms_settings(server['baseURL'], server['token'])
|
self.save_pms_settings(server['baseURL'], server['token'])
|
||||||
|
|
Loading…
Reference in a new issue