From c6aa4d3021ef132f5f41aa8a74e63188e1d8d50e Mon Sep 17 00:00:00 2001 From: croneter Date: Thu, 18 Nov 2021 07:14:21 +0100 Subject: [PATCH] Fix PKC not being able to connect to plex.tv after installation --- resources/lib/clientinfo.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/resources/lib/clientinfo.py b/resources/lib/clientinfo.py index 5c5e51d8..6b65413d 100644 --- a/resources/lib/clientinfo.py +++ b/resources/lib/clientinfo.py @@ -51,6 +51,22 @@ def getXArgsDeviceInfo(options=None, include_token=True): return xargs +def generate_device_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) + # 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 + + def getDeviceId(reset=False): """ Returns a unique Plex client id "X-Plex-Client-Identifier" from Kodi @@ -60,28 +76,17 @@ def getDeviceId(reset=False): If id does not exist, create one and save in Kodi settings file. """ if reset: - 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) - # 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 + return generate_device_id() client_id = v.PKC_MACHINE_IDENTIFIER if client_id: return client_id client_id = utils.settings('plex_client_Id') - # Because Kodi appears to cache file settings!! - if client_id != "" and reset is False: + if client_id != "": v.PKC_MACHINE_IDENTIFIER = client_id utils.window('plex_client_Id', value=client_id) LOG.info("Unique device Id plex_client_Id loaded: %s", client_id) return client_id + else: + return generate_device_id()