|
|
|
@ -19,7 +19,7 @@ log = logger.get_logger('traktarr')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Click
|
|
|
|
|
@click.group(help='Add new series/movies to Sonarr & Radarr from Trakt.')
|
|
|
|
|
@click.group(help='Add new shows & movies to Sonarr/Radarr from Trakt lists.')
|
|
|
|
|
def app():
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
@ -28,12 +28,12 @@ def app():
|
|
|
|
|
# SHOWS
|
|
|
|
|
############################################################
|
|
|
|
|
|
|
|
|
|
@app.command(help='Add new series to Sonarr.')
|
|
|
|
|
@app.command(help='Add new shows to Sonarr.')
|
|
|
|
|
@click.option('--list-type', '-t', type=click.Choice(['anticipated', 'trending', 'popular']),
|
|
|
|
|
help='Trakt list to process.', required=True)
|
|
|
|
|
@click.option('--add-limit', '-l', default=0, help='Limit number of series added to Sonarr.', show_default=True)
|
|
|
|
|
@click.option('--add-limit', '-l', default=0, help='Limit number of shows added to Sonarr.', show_default=True)
|
|
|
|
|
@click.option('--add-delay', '-d', default=2.5, help='Seconds between each add request to Sonarr.', show_default=True)
|
|
|
|
|
@click.option('--no-search', is_flag=True, help='Disable search when adding series to Sonarr.')
|
|
|
|
|
@click.option('--no-search', is_flag=True, help='Disable search when adding shows to Sonarr.')
|
|
|
|
|
def shows(list_type, add_limit=0, add_delay=2.5, no_search=False):
|
|
|
|
|
added_shows = 0
|
|
|
|
|
|
|
|
|
@ -64,10 +64,10 @@ def shows(list_type, add_limit=0, add_delay=2.5, no_search=False):
|
|
|
|
|
# get sonarr series list
|
|
|
|
|
sonarr_series_list = sonarr.get_series()
|
|
|
|
|
if not sonarr_series_list:
|
|
|
|
|
log.error("Aborting due to failure to retrieve Sonarr series list")
|
|
|
|
|
log.error("Aborting due to failure to retrieve Sonarr shows list")
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
log.info("Retrieved Sonarr series list, series found: %d", len(sonarr_series_list))
|
|
|
|
|
log.info("Retrieved Sonarr shows list, shows found: %d", len(sonarr_series_list))
|
|
|
|
|
|
|
|
|
|
# get trakt series list
|
|
|
|
|
trakt_series_list = None
|
|
|
|
@ -81,23 +81,23 @@ def shows(list_type, add_limit=0, add_delay=2.5, no_search=False):
|
|
|
|
|
log.error("Aborting due to unknown Trakt list type")
|
|
|
|
|
return
|
|
|
|
|
if not trakt_series_list:
|
|
|
|
|
log.error("Aborting due to failure to retrieve Trakt %s series list", list_type)
|
|
|
|
|
log.error("Aborting due to failure to retrieve Trakt %s shows list", list_type)
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
log.info("Retrieved Trakt %s series list, series found: %d", list_type, len(trakt_series_list))
|
|
|
|
|
log.info("Retrieved Trakt %s shows list, shows found: %d", list_type, len(trakt_series_list))
|
|
|
|
|
|
|
|
|
|
# build filtered series list without series that exist in sonarr
|
|
|
|
|
processed_series_list = helpers.sonarr_remove_existing_series(sonarr_series_list, trakt_series_list)
|
|
|
|
|
if not processed_series_list:
|
|
|
|
|
log.error("Aborting due to failure to remove existing Sonarr series from retrieved Trakt series list")
|
|
|
|
|
log.error("Aborting due to failure to remove existing Sonarr shows from retrieved Trakt shows list")
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
log.info("Removed existing Sonarr series from Trakt series list, series left to process: %d",
|
|
|
|
|
log.info("Removed existing Sonarr shows from Trakt shows list, shows left to process: %d",
|
|
|
|
|
len(processed_series_list))
|
|
|
|
|
|
|
|
|
|
# sort filtered series list by highest votes
|
|
|
|
|
sorted_series_list = sorted(processed_series_list, key=lambda k: k['show']['votes'], reverse=True)
|
|
|
|
|
log.info("Sorted series list to process by highest votes")
|
|
|
|
|
log.info("Sorted shows list to process by highest votes")
|
|
|
|
|
|
|
|
|
|
# loop series_list
|
|
|
|
|
log.info("Processing list now...")
|
|
|
|
@ -125,7 +125,7 @@ def shows(list_type, add_limit=0, add_delay=2.5, no_search=False):
|
|
|
|
|
time.sleep(add_delay)
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
log.exception("Exception while processing series %s: ", series['show']['title'])
|
|
|
|
|
log.exception("Exception while processing show %s: ", series['show']['title'])
|
|
|
|
|
|
|
|
|
|
log.info("Added %d new shows to Sonarr", added_shows)
|
|
|
|
|
|
|
|
|
|