diff --git a/plexpy/__init__.py b/plexpy/__init__.py index 5ff8bc5b..0292daa1 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -172,10 +172,18 @@ def initialize(config_file): # Check if Tautulli has a uuid if CONFIG.PMS_UUID == '' or not CONFIG.PMS_UUID: + logger.debug(u"Generating UUID...") my_uuid = generate_uuid() CONFIG.__setattr__('PMS_UUID', my_uuid) CONFIG.write() - + + # Check if Tautulli has an API key + if CONFIG.API_KEY == '': + logger.debug(u"Generating API key...") + api_key = generate_uuid() + CONFIG.__setattr__('API_KEY', api_key) + CONFIG.write() + # Get the currently installed version. Returns None, 'win32' or the git # hash. CURRENT_VERSION, CONFIG.GIT_REMOTE, CONFIG.GIT_BRANCH = versioncheck.getVersion() @@ -1491,5 +1499,4 @@ def shutdown(restart=False, update=False, checkout=False): def generate_uuid(): - logger.debug(u"Generating UUID...") return uuid.uuid4().hex diff --git a/plexpy/config.py b/plexpy/config.py index 62714751..438f79e8 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -66,7 +66,7 @@ _CONFIG_DEFINITIONS = { 'PMS_WEB_URL': (str, 'PMS', 'https://app.plex.tv/desktop'), 'TIME_FORMAT': (str, 'General', 'HH:mm'), 'ANON_REDIRECT': (str, 'General', 'http://www.nullrefer.com/?'), - 'API_ENABLED': (int, 'General', 0), + 'API_ENABLED': (int, 'General', 1), 'API_KEY': (str, 'General', ''), 'API_SQL': (int, 'General', 0), 'BOXCAR_ENABLED': (int, 'Boxcar', 0), diff --git a/plexpy/webserve.py b/plexpy/webserve.py index d43aa59e..c9382d90 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -3539,7 +3539,7 @@ class WebInterface(object): def generate_api_key(self, device=None, **kwargs): apikey = '' while not apikey or apikey == plexpy.CONFIG.API_KEY or mobile_app.get_mobile_device_by_token(device_token=apikey): - apikey = uuid.uuid4().hex + apikey = plexpy.generate_uuid() logger.info(u"New API key generated.") logger._BLACKLIST_WORDS.add(apikey)