added --version option.

begin addition of run mode/automatic mode.
pull/54/head
l3uddz 7 years ago
parent 74792f82e1
commit 0aff1d4830

@ -47,6 +47,30 @@ base_config = {
'blacklist_title_keywords': ['untitled', 'barbie'], 'blacklist_title_keywords': ['untitled', 'barbie'],
'allowed_countries': ['us', 'gb', 'ca'] '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 cfg = None

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

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

@ -2,6 +2,7 @@
import time import time
import click import click
import schedule
from media.radarr import Radarr from media.radarr import Radarr
from media.sonarr import Sonarr from media.sonarr import Sonarr
@ -20,6 +21,7 @@ log = logger.get_logger('traktarr')
# Click # Click
@click.group(help='Add new shows & movies to Sonarr/Radarr from Trakt lists.') @click.group(help='Add new shows & movies to Sonarr/Radarr from Trakt lists.')
@click.version_option('1.0.0', prog_name='traktarr')
def app(): def app():
pass 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) log.info("Added %d new show(s) to Sonarr", added_shows)
############################################################
# MOVIES
############################################################
@app.command(help='Add new movies to Radarr.') @app.command(help='Add new movies to Radarr.')
@click.option('--list-type', '-t', type=click.Choice(['anticipated', 'trending', 'popular']), @click.option('--list-type', '-t', type=click.Choice(['anticipated', 'trending', 'popular']),
help='Trakt list to process.', required=True) 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) 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 # MAIN
############################################################ ############################################################

Loading…
Cancel
Save