Init unique machine identifier earlier
This commit is contained in:
parent
5223f7620c
commit
90c76aa997
3 changed files with 45 additions and 40 deletions
|
@ -59,24 +59,27 @@ 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 is True:
|
||||||
|
v.PKC_MACHINE_IDENTIFIER = None
|
||||||
window('plex_client_Id', clear=True)
|
window('plex_client_Id', clear=True)
|
||||||
settings('plex_client_Id', value="")
|
settings('plex_client_Id', value="")
|
||||||
|
|
||||||
clientId = window('plex_client_Id')
|
client_id = v.PKC_MACHINE_IDENTIFIER
|
||||||
if clientId:
|
if client_id:
|
||||||
return clientId
|
return client_id
|
||||||
|
|
||||||
clientId = settings('plex_client_Id')
|
client_id = settings('plex_client_Id')
|
||||||
# Because Kodi appears to cache file settings!!
|
# Because Kodi appears to cache file settings!!
|
||||||
if clientId != "" and reset is False:
|
if client_id != "" and reset is False:
|
||||||
window('plex_client_Id', value=clientId)
|
v.PKC_MACHINE_IDENTIFIER = client_id
|
||||||
log.info("Unique device Id plex_client_Id loaded: %s" % clientId)
|
window('plex_client_Id', value=client_id)
|
||||||
return clientId
|
log.info("Unique device Id plex_client_Id loaded: %s", client_id)
|
||||||
|
return client_id
|
||||||
|
|
||||||
log.info("Generating a new deviceid.")
|
log.info("Generating a new deviceid.")
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
clientId = str(uuid4())
|
client_id = str(uuid4())
|
||||||
settings('plex_client_Id', value=clientId)
|
settings('plex_client_Id', value=client_id)
|
||||||
window('plex_client_Id', value=clientId)
|
v.PKC_MACHINE_IDENTIFIER = client_id
|
||||||
log.info("Unique device Id plex_client_Id loaded: %s" % clientId)
|
window('plex_client_Id', value=client_id)
|
||||||
return clientId
|
log.info("Unique device Id plex_client_Id generated: %s", client_id)
|
||||||
|
return client_id
|
||||||
|
|
|
@ -63,6 +63,9 @@ DEVICENAME = DEVICENAME.replace('(', "")
|
||||||
DEVICENAME = DEVICENAME.replace(')', "")
|
DEVICENAME = DEVICENAME.replace(')', "")
|
||||||
DEVICENAME = DEVICENAME.strip()
|
DEVICENAME = DEVICENAME.strip()
|
||||||
|
|
||||||
|
# Unique ID for this Plex client; also see clientinfo.py
|
||||||
|
PKC_MACHINE_IDENTIFIER = None
|
||||||
|
|
||||||
# Database paths
|
# Database paths
|
||||||
_DB_VIDEO_VERSION = {
|
_DB_VIDEO_VERSION = {
|
||||||
13: 78, # Gotham
|
13: 78, # Gotham
|
||||||
|
|
53
service.py
53
service.py
|
@ -37,6 +37,7 @@ import videonodes
|
||||||
from websocket_client import PMS_Websocket, Alexa_Websocket
|
from websocket_client import PMS_Websocket, Alexa_Websocket
|
||||||
import downloadutils
|
import downloadutils
|
||||||
from playqueue import Playqueue
|
from playqueue import Playqueue
|
||||||
|
import clientinfo
|
||||||
|
|
||||||
import PlexAPI
|
import PlexAPI
|
||||||
from PlexCompanion import PlexCompanion
|
from PlexCompanion import PlexCompanion
|
||||||
|
@ -51,7 +52,7 @@ import state
|
||||||
import loghandler
|
import loghandler
|
||||||
|
|
||||||
loghandler.config()
|
loghandler.config()
|
||||||
log = getLogger("PLEX.service")
|
LOG = getLogger("PLEX.service")
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
def set_webserver():
|
def set_webserver():
|
||||||
|
@ -92,24 +93,15 @@ class Service():
|
||||||
image_cache_thread_running = False
|
image_cache_thread_running = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
set_webserver()
|
|
||||||
self.monitor = Monitor()
|
|
||||||
|
|
||||||
window('plex_kodiProfile',
|
|
||||||
value=tryDecode(translatePath("special://profile")))
|
|
||||||
window('fetch_pms_item_number',
|
|
||||||
value=settings('fetch_pms_item_number'))
|
|
||||||
|
|
||||||
# Initial logging
|
# Initial logging
|
||||||
log.info("======== START %s ========" % v.ADDON_NAME)
|
LOG.info("======== START %s ========", v.ADDON_NAME)
|
||||||
log.info("Platform: %s" % v.PLATFORM)
|
LOG.info("Platform: %s", v.PLATFORM)
|
||||||
log.info("KODI Version: %s" % v.KODILONGVERSION)
|
LOG.info("KODI Version: %s", v.KODILONGVERSION)
|
||||||
log.info("%s Version: %s" % (v.ADDON_NAME, v.ADDON_VERSION))
|
LOG.info("%s Version: %s", v.ADDON_NAME, v.ADDON_VERSION)
|
||||||
log.info("Using plugin paths: %s"
|
LOG.info("Using plugin paths: %s",
|
||||||
% (settings('useDirectPaths') != "true"))
|
settings('useDirectPaths') != "true")
|
||||||
log.info("Number of sync threads: %s"
|
LOG.info("Number of sync threads: %s", settings('syncThreadNumber'))
|
||||||
% settings('syncThreadNumber'))
|
LOG.info("Full sys.argv received: %s", argv)
|
||||||
log.info("Full sys.argv received: %s" % argv)
|
|
||||||
|
|
||||||
# Reset window props for profile switch
|
# Reset window props for profile switch
|
||||||
properties = [
|
properties = [
|
||||||
|
@ -130,8 +122,15 @@ class Service():
|
||||||
# Clear video nodes properties
|
# Clear video nodes properties
|
||||||
videonodes.VideoNodes().clearProperties()
|
videonodes.VideoNodes().clearProperties()
|
||||||
|
|
||||||
# Set the minimum database version
|
# Init some stuff
|
||||||
window('plex_minDBVersion', value="1.5.10")
|
window('plex_minDBVersion', value="1.5.10")
|
||||||
|
set_webserver()
|
||||||
|
self.monitor = Monitor()
|
||||||
|
window('plex_kodiProfile',
|
||||||
|
value=tryDecode(translatePath("special://profile")))
|
||||||
|
window('fetch_pms_item_number',
|
||||||
|
value=settings('fetch_pms_item_number'))
|
||||||
|
clientinfo.getDeviceId()
|
||||||
|
|
||||||
def __stop_PKC(self):
|
def __stop_PKC(self):
|
||||||
"""
|
"""
|
||||||
|
@ -172,7 +171,7 @@ class Service():
|
||||||
|
|
||||||
if window('plex_kodiProfile') != kodiProfile:
|
if window('plex_kodiProfile') != kodiProfile:
|
||||||
# Profile change happened, terminate this thread and others
|
# Profile change happened, terminate this thread and others
|
||||||
log.info("Kodi profile was: %s and changed to: %s. "
|
LOG.info("Kodi profile was: %s and changed to: %s. "
|
||||||
"Terminating old PlexKodiConnect thread."
|
"Terminating old PlexKodiConnect thread."
|
||||||
% (kodiProfile,
|
% (kodiProfile,
|
||||||
window('plex_kodiProfile')))
|
window('plex_kodiProfile')))
|
||||||
|
@ -235,7 +234,7 @@ class Service():
|
||||||
# Alert user is not authenticated and suppress future
|
# Alert user is not authenticated and suppress future
|
||||||
# warning
|
# warning
|
||||||
self.warn_auth = False
|
self.warn_auth = False
|
||||||
log.warn("Not authenticated yet.")
|
LOG.warn("Not authenticated yet.")
|
||||||
|
|
||||||
# User access is restricted.
|
# User access is restricted.
|
||||||
# Keep verifying until access is granted
|
# Keep verifying until access is granted
|
||||||
|
@ -267,7 +266,7 @@ class Service():
|
||||||
window('plex_online', value="false")
|
window('plex_online', value="false")
|
||||||
# Suspend threads
|
# Suspend threads
|
||||||
state.SUSPEND_LIBRARY_THREAD = True
|
state.SUSPEND_LIBRARY_THREAD = True
|
||||||
log.error("Plex Media Server went offline")
|
LOG.error("Plex Media Server went offline")
|
||||||
if settings('show_pms_offline') == 'true':
|
if settings('show_pms_offline') == 'true':
|
||||||
dialog('notification',
|
dialog('notification',
|
||||||
lang(33001),
|
lang(33001),
|
||||||
|
@ -301,7 +300,7 @@ class Service():
|
||||||
icon='{plex}',
|
icon='{plex}',
|
||||||
time=5000,
|
time=5000,
|
||||||
sound=False)
|
sound=False)
|
||||||
log.info("Server %s is online and ready." % server)
|
LOG.info("Server %s is online and ready." % server)
|
||||||
window('plex_online', value="true")
|
window('plex_online', value="true")
|
||||||
if state.AUTHENTICATED:
|
if state.AUTHENTICATED:
|
||||||
# Server got offline when we were authenticated.
|
# Server got offline when we were authenticated.
|
||||||
|
@ -331,7 +330,7 @@ class Service():
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
window('plex_service_started', clear=True)
|
window('plex_service_started', clear=True)
|
||||||
log.info("======== STOP %s ========" % v.ADDON_NAME)
|
LOG.info("======== STOP %s ========" % v.ADDON_NAME)
|
||||||
|
|
||||||
|
|
||||||
# Safety net - Kody starts PKC twice upon first installation!
|
# Safety net - Kody starts PKC twice upon first installation!
|
||||||
|
@ -344,11 +343,11 @@ else:
|
||||||
# Delay option
|
# Delay option
|
||||||
delay = int(settings('startupDelay'))
|
delay = int(settings('startupDelay'))
|
||||||
|
|
||||||
log.info("Delaying Plex startup by: %s sec..." % delay)
|
LOG.info("Delaying Plex startup by: %s sec..." % delay)
|
||||||
if exit:
|
if exit:
|
||||||
log.error('PKC service.py already started - exiting this instance')
|
LOG.error('PKC service.py already started - exiting this instance')
|
||||||
elif delay and Monitor().waitForAbort(delay):
|
elif delay and Monitor().waitForAbort(delay):
|
||||||
# Start the service
|
# Start the service
|
||||||
log.info("Abort requested while waiting. PKC not started.")
|
LOG.info("Abort requested while waiting. PKC not started.")
|
||||||
else:
|
else:
|
||||||
Service().ServiceEntryPoint()
|
Service().ServiceEntryPoint()
|
||||||
|
|
Loading…
Reference in a new issue