diff --git a/LICENSE b/LICENSE index f288702d..b01123cb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 + Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies diff --git a/README.md b/README.md index 6a66abf9..0c8f7ced 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Huntarr [Sonarr Edition] - Force Sonarr to Hunt Missing Shows & Upgrade Episode Qualities -

Want to Help? Click the Star in the Upper-Right Corner! ⭐

+

Want to Help? Click the Star in the Upper-Right Corner! ⭐

diff --git a/config.py b/config.py index 3a3067dd..f2748576 100644 --- a/config.py +++ b/config.py @@ -88,22 +88,30 @@ # Debug Settings DEBUG_MODE = os.environ.get("DEBUG_MODE", "false").lower() == "true" -# Override settings from settings manager if they exist def refresh_settings(): """Refresh configuration settings from the settings manager.""" global HUNT_MISSING_SHOWS, HUNT_UPGRADE_EPISODES, SLEEP_DURATION global STATE_RESET_INTERVAL_HOURS, MONITORED_ONLY, RANDOM_SELECTION global SKIP_FUTURE_EPISODES, SKIP_SERIES_REFRESH - # Load settings from settings manager - HUNT_MISSING_SHOWS = settings_manager.get_setting("huntarr", "hunt_missing_shows", HUNT_MISSING_SHOWS) - HUNT_UPGRADE_EPISODES = settings_manager.get_setting("huntarr", "hunt_upgrade_episodes", HUNT_UPGRADE_EPISODES) - SLEEP_DURATION = settings_manager.get_setting("huntarr", "sleep_duration", SLEEP_DURATION) - STATE_RESET_INTERVAL_HOURS = settings_manager.get_setting("huntarr", "state_reset_interval_hours", STATE_RESET_INTERVAL_HOURS) - MONITORED_ONLY = settings_manager.get_setting("huntarr", "monitored_only", MONITORED_ONLY) - RANDOM_SELECTION = settings_manager.get_setting("huntarr", "random_selection", RANDOM_SELECTION) - SKIP_FUTURE_EPISODES = settings_manager.get_setting("huntarr", "skip_future_episodes", SKIP_FUTURE_EPISODES) - SKIP_SERIES_REFRESH = settings_manager.get_setting("huntarr", "skip_series_refresh", SKIP_SERIES_REFRESH) + # Load settings directly from settings manager + settings = settings_manager.get_all_settings() + huntarr_settings = settings.get("huntarr", {}) + + # Update global variables with fresh values + HUNT_MISSING_SHOWS = huntarr_settings.get("hunt_missing_shows", HUNT_MISSING_SHOWS) + HUNT_UPGRADE_EPISODES = huntarr_settings.get("hunt_upgrade_episodes", HUNT_UPGRADE_EPISODES) + SLEEP_DURATION = huntarr_settings.get("sleep_duration", SLEEP_DURATION) + STATE_RESET_INTERVAL_HOURS = huntarr_settings.get("state_reset_interval_hours", STATE_RESET_INTERVAL_HOURS) + MONITORED_ONLY = huntarr_settings.get("monitored_only", MONITORED_ONLY) + RANDOM_SELECTION = huntarr_settings.get("random_selection", RANDOM_SELECTION) + SKIP_FUTURE_EPISODES = huntarr_settings.get("skip_future_episodes", SKIP_FUTURE_EPISODES) + SKIP_SERIES_REFRESH = huntarr_settings.get("skip_series_refresh", SKIP_SERIES_REFRESH) + + # Log the refresh for debugging + import logging + logger = logging.getLogger("huntarr-sonarr") + logger.debug(f"Settings refreshed: SLEEP_DURATION={SLEEP_DURATION}, HUNT_MISSING_SHOWS={HUNT_MISSING_SHOWS}") def log_configuration(logger): """Log the current configuration settings""" diff --git a/main.py b/main.py index 739898e5..e7229b5b 100644 --- a/main.py +++ b/main.py @@ -83,8 +83,13 @@ def main_loop() -> None: # Calculate time until the next reset calculate_reset_time() + # Refresh settings before sleep to get the latest sleep_duration + refresh_settings() + # Import it directly from the settings manager to ensure latest value + from config import SLEEP_DURATION as CURRENT_SLEEP_DURATION + # Sleep at the end of the cycle only - logger.info(f"Cycle complete. Sleeping {SLEEP_DURATION}s before next cycle...") + logger.info(f"Cycle complete. Sleeping {CURRENT_SLEEP_DURATION}s before next cycle...") logger.info("⭐ Tool Great? Donate @ https://donate.plex.one for Daughter's College Fund!") # Log web UI information if enabled @@ -94,7 +99,7 @@ def main_loop() -> None: # Sleep with progress updates for the web interface sleep_start = time.time() - sleep_end = sleep_start + SLEEP_DURATION + sleep_end = sleep_start + CURRENT_SLEEP_DURATION while time.time() < sleep_end: # Sleep in smaller chunks for more responsive shutdown diff --git a/static/css/style.css b/static/css/style.css index 09be8c41..5c76db5c 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -382,6 +382,11 @@ input:checked + .slider:before { justify-content: flex-end; } +.top-buttons { + margin-bottom: 20px; + margin-top: 10px; +} + .save-button { background-color: var(--save-button-bg); color: white; diff --git a/static/js/main.js b/static/js/main.js index e1b52b7e..47bd3e64 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -21,8 +21,12 @@ document.addEventListener('DOMContentLoaded', function() { const randomSelectionInput = document.getElementById('random_selection'); const skipFutureEpisodesInput = document.getElementById('skip_future_episodes'); const skipSeriesRefreshInput = document.getElementById('skip_series_refresh'); + + // Button elements for saving and resetting settings const saveSettingsButton = document.getElementById('saveSettings'); const resetSettingsButton = document.getElementById('resetSettings'); + const saveSettingsBottomButton = document.getElementById('saveSettingsBottom'); + const resetSettingsBottomButton = document.getElementById('resetSettingsBottom'); // Update sleep duration display function updateSleepDurationDisplay() { @@ -135,8 +139,8 @@ document.addEventListener('DOMContentLoaded', function() { .catch(error => console.error('Error loading settings:', error)); } - // Save settings to API - saveSettingsButton.addEventListener('click', function() { + // Function to save settings + function saveSettings() { const settings = { huntarr: { hunt_missing_shows: parseInt(huntMissingShowsInput.value) || 0, @@ -169,10 +173,10 @@ document.addEventListener('DOMContentLoaded', function() { console.error('Error saving settings:', error); alert('Error saving settings: ' + error.message); }); - }); + } - // Reset settings to defaults - resetSettingsButton.addEventListener('click', function() { + // Function to reset settings + function resetSettings() { if (confirm('Are you sure you want to reset all settings to default values?')) { fetch('/api/settings/reset', { method: 'POST' @@ -191,7 +195,14 @@ document.addEventListener('DOMContentLoaded', function() { alert('Error resetting settings: ' + error.message); }); } - }); + } + + // Add event listeners to both button sets + saveSettingsButton.addEventListener('click', saveSettings); + resetSettingsButton.addEventListener('click', resetSettings); + + saveSettingsBottomButton.addEventListener('click', saveSettings); + resetSettingsBottomButton.addEventListener('click', resetSettings); // Event source for logs let eventSource; diff --git a/templates/index.html b/templates/index.html index e8c790b2..60aaabbf 100644 --- a/templates/index.html +++ b/templates/index.html @@ -43,6 +43,13 @@