Skip to content

Commit

Permalink
Updated the setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
bexem authored Jun 6, 2023
1 parent a8f16b0 commit f17ef81
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
10 changes: 5 additions & 5 deletions plexcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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}")
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion plexcache_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
"debug": false,
"skip_ondeck": [],
"skip_watchlist": [],
"skip_if_active_session": true
"exit_if_active_session": false
}
19 changes: 8 additions & 11 deletions plexcache_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f17ef81

Please sign in to comment.