From f17ef8121ca312d3eaf253ea35342cfaca28ec5a Mon Sep 17 00:00:00 2001 From: Emanuele B Date: Wed, 7 Jun 2023 00:26:20 +0100 Subject: [PATCH] Updated the setup script --- plexcache.py | 10 +++++----- plexcache_settings.json | 2 +- plexcache_setup.py | 19 ++++++++----------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/plexcache.py b/plexcache.py index 73aca90..cf78c14 100644 --- a/plexcache.py +++ b/plexcache.py @@ -267,13 +267,13 @@ def convert_path(value, key, settings_data, drive_letter=None): nas_library_folders = remove_all_slashes(settings_data['nas_library_folders']) plex_library_folders = remove_all_slashes(settings_data['plex_library_folders']) - skip_if_active_session = settings_data.get('skip_if_active_session') - if skip_if_active_session is not None: + exit_if_active_session = settings_data.get('exit_if_active_session') + if exit_if_active_session is not None: skip = settings_data.get('skip') if skip is not None: del settings_data['skip'] else: - skip_if_active_session = not settings_data.get('skip') #Inverting the boolean as the logic has been inverted + exit_if_active_session = not settings_data.get('skip') #Inverting the boolean as the logic has been inverted del settings_data['skip'] max_concurrent_moves_array = settings_data['max_concurrent_moves_array'] @@ -297,7 +297,7 @@ def convert_path(value, key, settings_data, drive_letter=None): settings_data['plex_library_folders'] = plex_library_folders settings_data['skip_ondeck'] = skip_ondeck settings_data['skip_watchlist'] = skip_watchlist - settings_data['skip_if_active_session'] = skip_if_active_session + settings_data['exit_if_active_session'] = exit_if_active_session json.dump(settings_data, f, indent=4) except Exception as e: logging.error(f"Error occurred while saving settings data: {e}") @@ -321,7 +321,7 @@ def convert_path(value, key, settings_data, drive_letter=None): # Check if any active session sessions = plex.sessions() # Get the list of active sessions if sessions: # Check if there are any active sessions - if not skip_if_active_session: # Check if the 'skip_if_active_session' boolean is set + if exit_if_active_session: # Check if the 'exit_if_active_session' boolean is set to true logging.warning('There is an active session. Exiting...') exit('There is an active session. Exiting...') else: diff --git a/plexcache_settings.json b/plexcache_settings.json index fc4e9bc..49b45fe 100644 --- a/plexcache_settings.json +++ b/plexcache_settings.json @@ -33,5 +33,5 @@ "debug": false, "skip_ondeck": [], "skip_watchlist": [], - "skip_if_active_session": true + "exit_if_active_session": false } \ No newline at end of file diff --git a/plexcache_setup.py b/plexcache_setup.py index 9526727..e996816 100644 --- a/plexcache_setup.py +++ b/plexcache_setup.py @@ -273,17 +273,14 @@ def is_valid_plex_url(url): settings_data['nas_library_folders'] = nas_library_folder # Asks if to stop the script or continue if active session - while True: - if 'skip' not in settings_data: - session = input('\nIf there is an active session in plex (someone is playing a media) do you want to exit the script or just skip the playing media? [SKIP/exit] ') or 'skip' - if session.lower() == 'skip': - settings_data['skip'] = True - break - elif session.lower() == 'exit': - settings_data['skip'] = False - break - else: - print("Invalid choice. Please enter either skip or exit") + while 'exit_if_active_session' not in settings_data: + session = input('\nIf there is an active session in plex (someone is playing a media) do you want to exit the script (Yes) or just skip the playing media (No)? [y/N] ') or 'no' + if session.lower() in ['n', 'no']: + settings_data['exit_if_active_session'] = False + elif session.lower() in ['y', 'yes']: + settings_data['exit_if_active_session'] = True + else: + print("Invalid choice. Please enter either yes or no") # Concurrent moving process if 'max_concurrent_moves_cache' not in settings_data: