Fix generating new PKC unique device ID not working
This commit is contained in:
parent
4baee9afc1
commit
b6d09eb59b
3 changed files with 19 additions and 31 deletions
20
default.py
20
default.py
|
@ -117,7 +117,8 @@ class Main(object):
|
||||||
transfer.plex_command('choose_pms_server')
|
transfer.plex_command('choose_pms_server')
|
||||||
|
|
||||||
elif mode == 'deviceid':
|
elif mode == 'deviceid':
|
||||||
self.deviceid()
|
LOG.info('New PKC UUID / unique device id requested')
|
||||||
|
transfer.plex_command('generate_new_uuid')
|
||||||
|
|
||||||
elif mode == 'fanart':
|
elif mode == 'fanart':
|
||||||
LOG.info('User requested fanarttv refresh')
|
LOG.info('User requested fanarttv refresh')
|
||||||
|
@ -173,23 +174,6 @@ class Main(object):
|
||||||
# Received a xbmcgui.ListItem()
|
# Received a xbmcgui.ListItem()
|
||||||
xbmcplugin.setResolvedUrl(HANDLE, True, result)
|
xbmcplugin.setResolvedUrl(HANDLE, True, result)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def deviceid():
|
|
||||||
window = xbmcgui.Window(10000)
|
|
||||||
deviceId_old = window.getProperty('plex_client_Id')
|
|
||||||
from resources.lib import clientinfo
|
|
||||||
try:
|
|
||||||
deviceId = clientinfo.getDeviceId(reset=True)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error('Failed to generate a new device Id: %s' % e)
|
|
||||||
utils.messageDialog(utils.lang(29999), utils.lang(33032))
|
|
||||||
else:
|
|
||||||
LOG.info('Successfully removed old device ID: %s New deviceId:'
|
|
||||||
'%s' % (deviceId_old, deviceId))
|
|
||||||
# 'Kodi will now restart to apply the changes'
|
|
||||||
utils.messageDialog(utils.lang(29999), utils.lang(33033))
|
|
||||||
xbmc.executebuiltin('RestartApp')
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
LOG.info('%s started' % v.ADDON_ID)
|
LOG.info('%s started' % v.ADDON_ID)
|
||||||
|
|
|
@ -59,10 +59,20 @@ def getDeviceId(reset=False):
|
||||||
|
|
||||||
If id does not exist, create one and save in Kodi settings file.
|
If id does not exist, create one and save in Kodi settings file.
|
||||||
"""
|
"""
|
||||||
if reset is True:
|
if reset:
|
||||||
v.PKC_MACHINE_IDENTIFIER = None
|
LOG.info("Generating a new deviceid.")
|
||||||
utils.window('plex_client_Id', clear=True)
|
from uuid import uuid4
|
||||||
utils.settings('plex_client_Id', value="")
|
client_id = str(uuid4())
|
||||||
|
utils.settings('plex_client_Id', value=client_id)
|
||||||
|
v.PKC_MACHINE_IDENTIFIER = client_id
|
||||||
|
utils.window('plex_client_Id', value=client_id)
|
||||||
|
LOG.info("Unique device Id plex_client_Id generated: %s", client_id)
|
||||||
|
# IF WE EXIT KODI NOW, THE SETTING WON'T STICK!
|
||||||
|
# 'Kodi will now restart to apply the changes'
|
||||||
|
# utils.messageDialog(utils.lang(29999), utils.lang(33033))
|
||||||
|
# xbmc.executebuiltin('RestartApp')
|
||||||
|
utils.messageDialog(utils.lang(29999), 'Please restart Kodi now!')
|
||||||
|
return client_id
|
||||||
|
|
||||||
client_id = v.PKC_MACHINE_IDENTIFIER
|
client_id = v.PKC_MACHINE_IDENTIFIER
|
||||||
if client_id:
|
if client_id:
|
||||||
|
@ -75,12 +85,3 @@ def getDeviceId(reset=False):
|
||||||
utils.window('plex_client_Id', value=client_id)
|
utils.window('plex_client_Id', value=client_id)
|
||||||
LOG.info("Unique device Id plex_client_Id loaded: %s", client_id)
|
LOG.info("Unique device Id plex_client_Id loaded: %s", client_id)
|
||||||
return client_id
|
return client_id
|
||||||
|
|
||||||
LOG.info("Generating a new deviceid.")
|
|
||||||
from uuid import uuid4
|
|
||||||
client_id = str(uuid4())
|
|
||||||
utils.settings('plex_client_Id', value=client_id)
|
|
||||||
v.PKC_MACHINE_IDENTIFIER = client_id
|
|
||||||
utils.window('plex_client_Id', value=client_id)
|
|
||||||
LOG.info("Unique device Id plex_client_Id generated: %s", client_id)
|
|
||||||
return client_id
|
|
||||||
|
|
|
@ -498,6 +498,9 @@ class Service(object):
|
||||||
elif plex_command == 'EXIT-PKC':
|
elif plex_command == 'EXIT-PKC':
|
||||||
LOG.info('Received command from another instance to quit')
|
LOG.info('Received command from another instance to quit')
|
||||||
app.APP.stop_pkc = True
|
app.APP.stop_pkc = True
|
||||||
|
elif plex_command == 'generate_new_uuid':
|
||||||
|
LOG.info('Generating new UUID for PKC')
|
||||||
|
clientinfo.getDeviceId(reset=True)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('Unknown command: %s', plex_command)
|
raise RuntimeError('Unknown command: %s', plex_command)
|
||||||
if task:
|
if task:
|
||||||
|
|
Loading…
Reference in a new issue