added --version option.

begin addition of run mode/automatic mode.
pull/5/head 1.0.0
l3uddz 7 years ago
parent c14253e133
commit c7cfa180dd

@ -47,6 +47,30 @@ base_config = {
'blacklist_title_keywords': ['untitled', 'barbie'],
'allowed_countries': ['us', 'gb', 'ca']
}
},
'automatic': {
'movies': {
'interval': 24,
'anticipated': 10,
'trending': 2,
'popular': 3
},
'shows': {
'interval': 72,
'anticipated': 100,
'trending': 2,
'popular': 1
},
'notifications': {
'plex slack': {
'type': 'slack',
'webhook': 'http://'
},
'my pushover': {
'client_id': '....',
'client_secret': '....'
}
}
}
}
cfg = None

@ -18,6 +18,7 @@ class Logger:
# disable bloat loggers
logging.getLogger('urllib3').setLevel(logging.ERROR)
logging.getLogger('schedule').setLevel(logging.ERROR)
# init console_logger
self.console_handler = logging.StreamHandler(sys.stdout)

@ -1,4 +1,5 @@
backoff==1.4.3
schedule==0.4.3
attrdict==2.0.0
click==6.7
backoff==1.4.3
requests==2.18.4

@ -2,6 +2,7 @@
import time
import click
import schedule
from media.radarr import Radarr
from media.sonarr import Sonarr
@ -20,6 +21,7 @@ log = logger.get_logger('traktarr')
# Click
@click.group(help='Add new shows & movies to Sonarr/Radarr from Trakt lists.')
@click.version_option('1.0.0', prog_name='traktarr')
def app():
pass
@ -143,6 +145,10 @@ def shows(list_type, add_limit=0, add_delay=2.5, no_search=False):
log.info("Added %d new show(s) to Sonarr", added_shows)
############################################################
# MOVIES
############################################################
@app.command(help='Add new movies to Radarr.')
@click.option('--list-type', '-t', type=click.Choice(['anticipated', 'trending', 'popular']),
help='Trakt list to process.', required=True)
@ -243,6 +249,42 @@ def movies(list_type, add_limit=0, add_delay=2.5, no_search=False):
log.info("Added %d new movie(s) to Radarr", added_movies)
############################################################
# AUTOMATIC
############################################################
def automatic_shows():
log.info("Running")
def automatic_movies():
log.info("Running")
@app.command(help='Run in automatic mode.')
@click.option('--add-delay', '-d', default=2.5, help='Seconds between each add request to Sonarr / Radarr.',
show_default=True)
@click.option('--no-search', is_flag=True, help='Disable search when adding to Sonarr / Radarr.')
def run(add_delay=2.5, no_search=False):
# add tasks to repeat
schedule.every(1).minutes.do(automatic_movies)
schedule.every(2).minutes.do(automatic_shows)
# run schedule
log.info("Automatic mode is now running...")
while True:
try:
schedule.run_pending()
except KeyboardInterrupt:
log.info("Scheduled tasks are no longer being processed due to Ctrl + C")
break
except Exception:
log.exception("Unhandled exception occurred while processing scheduled tasks: ")
else:
time.sleep(1)
log.info("Automatic mode is now finished!")
############################################################
# MAIN
############################################################

Loading…
Cancel
Save