Merge pull request #26 from horjulf/develop

Flag to do a first run
pull/54/head
James 7 years ago committed by desimaniac
commit bf37f6e4db

@ -705,28 +705,34 @@ def automatic_movies(add_delay=2.5, no_search=False, notifications=False):
@click.option('--add-delay', '-d', default=2.5, help='Seconds between each add request to Sonarr / Radarr.', @click.option('--add-delay', '-d', default=2.5, help='Seconds between each add request to Sonarr / Radarr.',
show_default=True) show_default=True)
@click.option('--no-search', is_flag=True, help='Disable search when adding to Sonarr / Radarr.') @click.option('--no-search', is_flag=True, help='Disable search when adding to Sonarr / Radarr.')
@click.option('--run-now', is_flag=True, help="Do a first run immediately without waiting.")
@click.option('--no-notifications', is_flag=True, help="Disable notifications.") @click.option('--no-notifications', is_flag=True, help="Disable notifications.")
def run(add_delay=2.5, no_search=False, no_notifications=False): def run(add_delay=2.5, no_search=False, run_now=False, no_notifications=False):
log.info("Automatic mode is now running...") log.info("Automatic mode is now running...")
# Add tasks to schedule and do first run # Add tasks to schedule and do first run if enabled
if cfg.automatic.movies.interval: if cfg.automatic.movies.interval:
schedule.every(cfg.automatic.movies.interval).hours.do( movie_schedule = schedule.every(cfg.automatic.movies.interval).hours.do(
automatic_movies, automatic_movies,
add_delay, add_delay,
no_search, no_search,
not no_notifications not no_notifications
).run() )
if run_now:
movie_schedule.run()
# Sleep between tasks # Sleep between tasks
time.sleep(add_delay) time.sleep(add_delay)
if cfg.automatic.shows.interval: if cfg.automatic.shows.interval:
schedule.every(cfg.automatic.shows.interval).hours.do( shows_schedule = schedule.every(cfg.automatic.shows.interval).hours.do(
automatic_shows, automatic_shows,
add_delay, add_delay,
no_search, no_search,
not no_notifications not no_notifications
).run() )
if run_now:
shows_schedule.run()
# Enter running schedule # Enter running schedule
while True: while True:

Loading…
Cancel
Save