API enabled by default

This commit is contained in:
JonnyWong16 2017-12-19 11:47:59 -08:00
parent 3df7642193
commit e51a425389
3 changed files with 11 additions and 4 deletions

View file

@ -172,10 +172,18 @@ def initialize(config_file):
# Check if Tautulli has a uuid # Check if Tautulli has a uuid
if CONFIG.PMS_UUID == '' or not CONFIG.PMS_UUID: if CONFIG.PMS_UUID == '' or not CONFIG.PMS_UUID:
logger.debug(u"Generating UUID...")
my_uuid = generate_uuid() my_uuid = generate_uuid()
CONFIG.__setattr__('PMS_UUID', my_uuid) CONFIG.__setattr__('PMS_UUID', my_uuid)
CONFIG.write() 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 # Get the currently installed version. Returns None, 'win32' or the git
# hash. # hash.
CURRENT_VERSION, CONFIG.GIT_REMOTE, CONFIG.GIT_BRANCH = versioncheck.getVersion() 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(): def generate_uuid():
logger.debug(u"Generating UUID...")
return uuid.uuid4().hex return uuid.uuid4().hex

View file

@ -66,7 +66,7 @@ _CONFIG_DEFINITIONS = {
'PMS_WEB_URL': (str, 'PMS', 'https://app.plex.tv/desktop'), 'PMS_WEB_URL': (str, 'PMS', 'https://app.plex.tv/desktop'),
'TIME_FORMAT': (str, 'General', 'HH:mm'), 'TIME_FORMAT': (str, 'General', 'HH:mm'),
'ANON_REDIRECT': (str, 'General', 'http://www.nullrefer.com/?'), 'ANON_REDIRECT': (str, 'General', 'http://www.nullrefer.com/?'),
'API_ENABLED': (int, 'General', 0), 'API_ENABLED': (int, 'General', 1),
'API_KEY': (str, 'General', ''), 'API_KEY': (str, 'General', ''),
'API_SQL': (int, 'General', 0), 'API_SQL': (int, 'General', 0),
'BOXCAR_ENABLED': (int, 'Boxcar', 0), 'BOXCAR_ENABLED': (int, 'Boxcar', 0),

View file

@ -3539,7 +3539,7 @@ class WebInterface(object):
def generate_api_key(self, device=None, **kwargs): def generate_api_key(self, device=None, **kwargs):
apikey = '' apikey = ''
while not apikey or apikey == plexpy.CONFIG.API_KEY or mobile_app.get_mobile_device_by_token(device_token=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.info(u"New API key generated.")
logger._BLACKLIST_WORDS.add(apikey) logger._BLACKLIST_WORDS.add(apikey)