Add --dry-run flag to report what would happen in a multiple show/movie run

pull/152/head
chazlarson 4 years ago committed by salty
parent 0a49f0566e
commit 5c5ab0f4af

@ -344,6 +344,10 @@ def show(
'--remove-rejected-from-recommended', '--remove-rejected-from-recommended',
is_flag=True, is_flag=True,
help='Removes rejected/existing shows from recommended.') help='Removes rejected/existing shows from recommended.')
@click.option(
'--dry-run',
is_flag=True,
help='Shows the list of shows remaining after processing, takes no action on them.')
def shows( def shows(
list_type, list_type,
add_limit=0, add_limit=0,
@ -359,6 +363,7 @@ def shows(
authenticate_user=None, authenticate_user=None,
ignore_blacklist=False, ignore_blacklist=False,
remove_rejected_from_recommended=False, remove_rejected_from_recommended=False,
dry_run=False,
): ):
from media.sonarr import Sonarr from media.sonarr import Sonarr
@ -641,34 +646,37 @@ def shows(
(series['show']['network'] or 'N/A').upper(), (series['show']['network'] or 'N/A').upper(),
) )
# add show to sonarr if dry_run:
if sonarr.add_series( log.info("dry-run: SKIPPING")
series['show']['ids']['tvdb'],
series_title,
series['show']['ids']['slug'],
quality_profile_id,
language_profile_id,
cfg.sonarr.root_folder,
tag_ids,
not no_search,
series_type,
):
if profile_tags is not None and tag_names is not None:
log.info("ADDED: \'%s (%s)\' with Sonarr Tags: %s", series_title, series_year,
tag_names)
else:
log.info("ADDED: \'%s (%s)\'", series_title, series_year)
if notifications:
callback_notify({'event': 'add_show', 'list_type': list_type, 'show': series['show']})
added_shows += 1
else: else:
if profile_tags is not None: # add show to sonarr
log.error("FAILED ADDING: \'%s (%s)\' with Sonarr Tags: %s", series_title, series_year, if sonarr.add_series(
tag_names) series['show']['ids']['tvdb'],
series_title,
series['show']['ids']['slug'],
quality_profile_id,
language_profile_id,
cfg.sonarr.root_folder,
tag_ids,
not no_search,
series_type,
):
if profile_tags is not None and tag_names is not None:
log.info("ADDED: \'%s (%s)\' with Sonarr Tags: %s", series_title, series_year,
tag_names)
else:
log.info("ADDED: \'%s (%s)\'", series_title, series_year)
if notifications:
callback_notify({'event': 'add_show', 'list_type': list_type, 'show': series['show']})
added_shows += 1
else: else:
log.info("FAILED ADDING: \'%s (%s)\'", series_title, series_year) if profile_tags is not None:
continue log.error("FAILED ADDING: \'%s (%s)\' with Sonarr Tags: %s", series_title, series_year,
tag_names)
else:
log.info("FAILED ADDING: \'%s (%s)\'", series_title, series_year)
continue
else: else:
log.info("SKIPPED: \'%s (%s)\'", series_title, series_year) log.info("SKIPPED: \'%s (%s)\'", series_title, series_year)
@ -855,6 +863,10 @@ def movie(
'--remove-rejected-from-recommended', '--remove-rejected-from-recommended',
is_flag=True, is_flag=True,
help='Removes rejected/existing movies from recommended.') help='Removes rejected/existing movies from recommended.')
@click.option(
'--dry-run',
is_flag=True,
help='Shows the list of movies remaining after processing, takes no action on them.')
def movies( def movies(
list_type, list_type,
add_limit=0, add_limit=0,
@ -872,6 +884,7 @@ def movies(
authenticate_user=None, authenticate_user=None,
ignore_blacklist=False, ignore_blacklist=False,
remove_rejected_from_recommended=False, remove_rejected_from_recommended=False,
dry_run=False,
): ):
from media.radarr import Radarr from media.radarr import Radarr
@ -1160,25 +1173,28 @@ def movies(
movie_genres, movie_genres,
) )
# add movie to radarr if dry_run:
if radarr.add_movie( log.info("dry-run: SKIPPING")
sorted_movie['movie']['ids']['tmdb'],
movie_title,
movie_year,
sorted_movie['movie']['ids']['slug'],
quality_profile_id,
cfg.radarr.root_folder,
cfg.radarr.minimum_availability,
not no_search,
):
log.info("ADDED: \'%s (%s)\'", movie_title, movie_year)
if notifications:
callback_notify({'event': 'add_movie', 'list_type': list_type, 'movie': sorted_movie['movie']})
added_movies += 1
else: else:
log.error("FAILED ADDING: \'%s (%s)\'", movie_title, movie_year) # add movie to radarr
continue if radarr.add_movie(
sorted_movie['movie']['ids']['tmdb'],
movie_title,
movie_year,
sorted_movie['movie']['ids']['slug'],
quality_profile_id,
cfg.radarr.root_folder,
cfg.radarr.minimum_availability,
not no_search,
):
log.info("ADDED: \'%s (%s)\'", movie_title, movie_year)
if notifications:
callback_notify({'event': 'add_movie', 'list_type': list_type, 'movie': sorted_movie['movie']})
added_movies += 1
else:
log.error("FAILED ADDING: \'%s (%s)\'", movie_title, movie_year)
continue
else: else:
log.info("SKIPPED: \'%s (%s)\'", movie_title, movie_year) log.info("SKIPPED: \'%s (%s)\'", movie_title, movie_year)
continue continue

Loading…
Cancel
Save