Basic recoding
This commit is contained in:
parent
517f41b534
commit
b988344c9b
2 changed files with 97 additions and 59 deletions
|
@ -298,10 +298,34 @@ def main():
|
|||
LOG.info('Starting PKC %s', util.ADDON.getAddonInfo('version'))
|
||||
LOG.info('User-agent: %s', plex.defaultUserAgent())
|
||||
|
||||
server_select_shown = False
|
||||
|
||||
try:
|
||||
plex.init()
|
||||
# Check plex.tv sign-in status
|
||||
if not plexapp.ACCOUNT.authToken:
|
||||
LOG.info('Not signed in to plex.tv yet')
|
||||
if utils.settings('myplexlogin') == 'true':
|
||||
plex.authorize_user()
|
||||
# Main Loop
|
||||
while not xbmc.abortRequested:
|
||||
if plex.init():
|
||||
# Check whether a PMS server has been set
|
||||
selectedServer = plexapp.SERVERMANAGER.selectedServer
|
||||
if not selectedServer:
|
||||
if not server_select_shown:
|
||||
server_select_shown = True
|
||||
LOG.debug('No PMS set yet, presenting dialog')
|
||||
plex.select_server()
|
||||
else:
|
||||
util.MONITOR.waitForAbort(1)
|
||||
continue
|
||||
# Ping the PMS until we're sure its online
|
||||
if not selectedServer.isReachable():
|
||||
selectedServer.updateReachability(force=True,
|
||||
allowFallback=True)
|
||||
continue
|
||||
while not xbmc.abortRequested:
|
||||
|
||||
if (
|
||||
not plexapp.ACCOUNT.isOffline and not
|
||||
plexapp.ACCOUNT.isAuthenticated and
|
||||
|
@ -352,9 +376,6 @@ def main():
|
|||
finally:
|
||||
windowutils.shutdownHome()
|
||||
gc.collect(2)
|
||||
|
||||
else:
|
||||
break
|
||||
except:
|
||||
util.ERROR()
|
||||
finally:
|
||||
|
|
|
@ -275,33 +275,50 @@ class CallbackEvent(plexapp.CompatEvent):
|
|||
|
||||
def init():
|
||||
LOG.info('Initializing')
|
||||
|
||||
with CallbackEvent(plexapp.APP, 'init'):
|
||||
plexapp.init()
|
||||
LOG.info('Waiting for account initialization...')
|
||||
LOG.info('Account initialization done...')
|
||||
|
||||
if not plexapp.ACCOUNT.authToken:
|
||||
|
||||
def authorize_user():
|
||||
"""
|
||||
Display userselect dialog. Returns True if user has been selected
|
||||
and a valid token has been retrieved, False otherwise
|
||||
"""
|
||||
LOG.info('Displaying userselect dialog')
|
||||
from .windows import background
|
||||
with background.BackgroundContext(function=authorize) as d:
|
||||
token = d.result
|
||||
|
||||
if not token:
|
||||
LOG.info('Did not get a Plex token')
|
||||
return False
|
||||
|
||||
with CallbackEvent(plexapp.APP, 'account:response'):
|
||||
plexapp.ACCOUNT.validateToken(token)
|
||||
LOG.info('Waiting for account initialization')
|
||||
return True
|
||||
return plexapp.ACCOUNT.isSignedIn
|
||||
|
||||
|
||||
def select_user():
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def select_server():
|
||||
"""
|
||||
Displays a window for the user to select a pms.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def authorize():
|
||||
"""
|
||||
Shows dialogs to sign in to plex.tv with pin. Returns token or None
|
||||
"""
|
||||
from .windows import signin, background
|
||||
|
||||
background.setSplash(False)
|
||||
|
||||
back = signin.Background.create()
|
||||
|
||||
try:
|
||||
while True:
|
||||
pinLoginWindow = signin.PinLoginWindow.create()
|
||||
|
|
Loading…
Reference in a new issue