From 32b3fa5e79ce39b754547beffea4ed081e698dff Mon Sep 17 00:00:00 2001 From: Filipe Santos Date: Mon, 23 Apr 2018 12:24:02 +1200 Subject: [PATCH] Automatic run execute on startup --- traktarr.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/traktarr.py b/traktarr.py index 5e14706..dba5b8e 100755 --- a/traktarr.py +++ b/traktarr.py @@ -491,14 +491,18 @@ def automatic_movies(add_delay=2.5, no_search=False, notifications=False): @click.option('--no-search', is_flag=True, help='Disable search when adding to Sonarr / Radarr.') @click.option('--no-notifications', is_flag=True, help="Disable notifications.") def run(add_delay=2.5, no_search=False, no_notifications=False): - # add tasks to repeat + log.info("Automatic mode is now running...") + + # Add tasks to schedule and do first run if cfg.automatic.movies.interval: schedule.every(cfg.automatic.movies.interval).hours.do( automatic_movies, add_delay, no_search, not no_notifications - ) + ).run() + # Sleep between tasks + time.sleep(add_delay) if cfg.automatic.shows.interval: schedule.every(cfg.automatic.shows.interval).hours.do( @@ -506,13 +510,13 @@ def run(add_delay=2.5, no_search=False, no_notifications=False): add_delay, no_search, not no_notifications - ) + ).run() - # run schedule - log.info("Automatic mode is now running...") + # Enter running schedule while True: try: # Sleep until next run + log.info("Next job at %s", schedule.next_run()) time.sleep(schedule.idle_seconds()) # Check jobs to run schedule.run_pending()