CLI: Cleanup of genre argument code

- Made note that only one genre and one actor/actress can be specified.
pull/105/head
desimaniac 5 years ago
parent ee50a2c4e6
commit cd389796d7

@ -1163,28 +1163,32 @@ Usage: traktarr movies [OPTIONS]
Add multiple movies to Radarr. Add multiple movies to Radarr.
Options: Options:
-t, --list-type TEXT Trakt list to process. For example, 'anticipated', 'trending', -t, --list-type TEXT Trakt list to process.
For example, 'anticipated', 'trending',
'popular', 'person', 'watched', 'played', 'recommended', 'popular', 'person', 'watched', 'played', 'recommended',
'watchlist', or any URL to a list [required] 'watchlist', or any URL to a list. [required]
-l, --add-limit INTEGER Limit number of movies added to Radarr. -l, --add-limit INTEGER Limit number of movies added to Radarr.
-d, --add-delay FLOAT Seconds between each add request to Radarr. [default: 2.5] -d, --add-delay FLOAT Seconds between each add request to Radarr. [default: 2.5]
-s, --sort [rating|release|votes] -s, --sort [rating|release|votes]
Sort list to process. [default: votes] Sort list to process. [default: votes]
-r, --rating INTEGER Set a minimum Rotten Tomatoes score. -r, --rating INTEGER Set a minimum Rotten Tomatoes score.
-g, --genre TEXT Only add movies from this genre to Radarr. Use 'ignore' to add -g, --genre TEXT Only add movies from this genre to Radarr. Only one genre can be
movies from any genre, including ones with no genre specified. specified.
Use 'ignore' to add movies from any genre, including
ones with no genre specified.
-f, --folder TEXT Add movies with this root folder to Radarr. -f, --folder TEXT Add movies with this root folder to Radarr.
-ma, --minimum-availability [announced|in_cinemas|released|predb] -ma, --minimum-availability [announced|in_cinemas|released|predb]
Add movies with this minimum availability to Radarr. Default is Add movies with this minimum availability to Radarr. Default is
'released'. 'released'.
-a, --actor TEXT Only add movies from this actor to Radarr. Requires the 'person' -a, --actor TEXT Only add movies from this actor to Radarr.Only one actor can be
list. specified.
Requires the 'person' list.
--include-non-acting-roles Include non-acting roles such as 'As Himself', 'Narrator', etc. --include-non-acting-roles Include non-acting roles such as 'As Himself', 'Narrator', etc.
Requires the 'person' list option with the 'actor' argument. Requires the 'person' list option with the 'actor' argument.
--no-search Disable search when adding movies to Radarr. --no-search Disable search when adding movies to Radarr.
--notifications Send notifications. --notifications Send notifications.
--authenticate-user TEXT Specify which user to authenticate with to retrieve Trakt lists. --authenticate-user TEXT Specify which user to authenticate with to retrieve Trakt lists.
Default: first user in the config. Defaults to first user in the config.
--ignore-blacklist Ignores the blacklist when running the command. --ignore-blacklist Ignores the blacklist when running the command.
--remove-rejected-from-recommended --remove-rejected-from-recommended
Removes rejected/existing movies from recommended. Removes rejected/existing movies from recommended.
@ -1297,18 +1301,22 @@ Usage: traktarr shows [OPTIONS]
Add multiple shows to Sonarr. Add multiple shows to Sonarr.
Options: Options:
-t, --list-type TEXT Trakt list to process. For example, 'anticipated', 'trending', -t, --list-type TEXT Trakt list to process.
For example, 'anticipated', 'trending',
'popular', 'person', 'watched', 'played', 'recommended', 'popular', 'person', 'watched', 'played', 'recommended',
'watchlist', or any URL to a list [required] 'watchlist', or any URL to a list. [required]
-l, --add-limit INTEGER Limit number of shows added to Sonarr. -l, --add-limit INTEGER Limit number of shows added to Sonarr.
-d, --add-delay FLOAT Seconds between each add request to Sonarr. [default: 2.5] -d, --add-delay FLOAT Seconds between each add request to Sonarr. [default: 2.5]
-s, --sort [rating|release|votes] -s, --sort [rating|release|votes]
Sort list to process. [default: votes] Sort list to process. [default: votes]
-g, --genre TEXT Only add shows from this genre to Sonarr. Use 'ignore' to add -g, --genre TEXT Only add shows from this genre to Sonarr. Only one genre can be
shows from any genre, including ones with no genre specified. specified.
Use 'ignore' to add shows from any genre, including
ones with no genre specified.
-f, --folder TEXT Add shows with this root folder to Sonarr. -f, --folder TEXT Add shows with this root folder to Sonarr.
-a, --actor TEXT Only add movies from this actor to Radarr. Requires the 'person' -a, --actor TEXT Only add movies from this actor to Radarr. Only one actor can be
list option. specified.
Requires the 'person' list option.
--include-non-acting-roles Include non-acting roles such as 'As Himself', 'Narrator', etc. --include-non-acting-roles Include non-acting roles such as 'As Himself', 'Narrator', etc.
Requires the 'person' list option with the 'actor' argument. Requires the 'person' list option with the 'actor' argument.
--no-search Disable search when adding shows to Sonarr. --no-search Disable search when adding shows to Sonarr.

@ -13,6 +13,7 @@ from misc.config import Config
log = logger.get_logger(__name__) log = logger.get_logger(__name__)
cachefile = Config().cachefile cachefile = Config().cachefile
class Trakt: class Trakt:
non_user_lists = ['anticipated', 'trending', 'popular', 'boxoffice', 'watched', 'played'] non_user_lists = ['anticipated', 'trending', 'popular', 'boxoffice', 'watched', 'played']
@ -76,7 +77,14 @@ class Trakt:
if not languages: if not languages:
languages = ['en'] languages = ['en']
payload = dict_merge(payload, {'extended': 'full', 'limit': limit, 'page': 1, 'languages': ','.join(languages)}) payload = dict_merge(payload, {
'extended': 'full',
'limit': limit,
'page': 1,
'languages': ','.join(languages),
})
# currently only support for one genre item, despite name
if genres: if genres:
payload['genres'] = genres payload['genres'] = genres
@ -153,13 +161,13 @@ class Trakt:
# check if we have fetched the last page, break if so # check if we have fetched the last page, break if so
if total_pages == 0: if total_pages == 0:
log.debug("There were no more pages left to retrieve") log.debug("There were no more pages left to retrieve.")
break break
elif current_page >= total_pages: elif current_page >= total_pages:
log.debug("There are no more pages left to retrieve results from") log.debug("There are no more pages left to retrieve results from.")
break break
else: else:
log.info("There are %d page(s) left to retrieve results from", total_pages - current_page) log.info("There are %d page(s) left to retrieve results from.", total_pages - current_page)
payload['page'] += 1 payload['page'] += 1
time.sleep(sleep_between) time.sleep(sleep_between)
@ -390,88 +398,89 @@ class Trakt:
def get_trending_shows(self, limit=1000, languages=None, genres=None): def get_trending_shows(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/shows/trending', url='https://api.trakt.tv/shows/trending',
limit=limit,
languages=languages,
object_name='shows', object_name='shows',
type_name='trending', type_name='trending',
genres=genres limit=limit,
languages=languages,
genres=genres,
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_popular_shows(self, limit=1000, languages=None, genres=None): def get_popular_shows(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/shows/popular', url='https://api.trakt.tv/shows/popular',
limit=limit,
languages=languages,
object_name='shows', object_name='shows',
type_name='popular', type_name='popular',
genres=genres limit=limit,
languages=languages,
genres=genres,
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_anticipated_shows(self, limit=1000, languages=None, genres=None): def get_anticipated_shows(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/shows/anticipated', url='https://api.trakt.tv/shows/anticipated',
limit=limit,
languages=languages,
object_name='shows', object_name='shows',
type_name='anticipated', type_name='anticipated',
genres=genres limit=limit,
languages=languages,
genres=genres,
) )
def get_person_shows(self, person, limit=1000, languages=None, genres=None, include_non_acting_roles=False): def get_person_shows(self, person, limit=1000, languages=None, genres=None,
include_non_acting_roles=False):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/people/%s/shows' % person.replace(' ', '-').lower(), url='https://api.trakt.tv/people/%s/shows' % person.replace(' ', '-').lower(),
limit=limit,
languages=languages,
object_name='shows', object_name='shows',
type_name='person', type_name='person',
limit=limit,
languages=languages,
genres=genres, genres=genres,
include_non_acting_roles=include_non_acting_roles include_non_acting_roles=include_non_acting_roles,
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_most_played_shows(self, limit=1000, languages=None, genres=None, most_type=None): def get_most_played_shows(self, limit=1000, languages=None, genres=None, most_type=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/shows/played/%s' % ('weekly' if not most_type else most_type), url='https://api.trakt.tv/shows/played/%s' % ('weekly' if not most_type else most_type),
limit=limit,
languages=languages,
object_name='shows', object_name='shows',
type_name='played', type_name='played',
genres=genres limit=limit,
languages=languages,
genres=genres,
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_most_watched_shows(self, limit=1000, languages=None, genres=None, most_type=None): def get_most_watched_shows(self, limit=1000, languages=None, genres=None, most_type=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/shows/watched/%s' % ('weekly' if not most_type else most_type), url='https://api.trakt.tv/shows/watched/%s' % ('weekly' if not most_type else most_type),
limit=limit,
languages=languages,
object_name='shows', object_name='shows',
type_name='watched', type_name='watched',
genres=genres limit=limit,
languages=languages,
genres=genres,
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_recommended_shows(self, authenticate_user=None, limit=1000, languages=None, genres=None): def get_recommended_shows(self, authenticate_user=None, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/recommendations/shows', url='https://api.trakt.tv/recommendations/shows',
object_name='shows',
type_name='recommended from {authenticate_user}',
authenticate_user=authenticate_user, authenticate_user=authenticate_user,
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='shows', genres=genres,
type_name='recommended from {authenticate_user}',
genres=genres
) )
def get_watchlist_shows(self, authenticate_user=None, limit=1000, languages=None): def get_watchlist_shows(self, authenticate_user=None, limit=1000, languages=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/users/{authenticate_user}/watchlist/shows', url='https://api.trakt.tv/users/{authenticate_user}/watchlist/shows',
object_name='shows',
type_name='watchlist from {authenticate_user}',
authenticate_user=authenticate_user, authenticate_user=authenticate_user,
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='shows',
type_name='watchlist from {authenticate_user}',
) )
def get_user_list_shows(self, list_url, authenticate_user=None, limit=1000, languages=None): def get_user_list_shows(self, list_url, authenticate_user=None, limit=1000, languages=None):
@ -481,11 +490,11 @@ class Trakt:
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/users/' + list_user + '/lists/' + list_key + '/items/shows', url='https://api.trakt.tv/users/' + list_user + '/lists/' + list_key + '/items/shows',
object_name='shows',
type_name=(list_key + ' from ' + list_user),
authenticate_user=authenticate_user, authenticate_user=authenticate_user,
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='shows',
type_name=(list_key + ' from ' + list_user),
) )
############################################################ ############################################################
@ -502,96 +511,98 @@ class Trakt:
def get_trending_movies(self, limit=1000, languages=None, genres=None): def get_trending_movies(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/trending', url='https://api.trakt.tv/movies/trending',
limit=limit,
languages=languages,
object_name='movies', object_name='movies',
type_name='trending', type_name='trending',
genres=genres limit=limit,
languages=languages,
genres=genres,
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_popular_movies(self, limit=1000, languages=None, genres=None): def get_popular_movies(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/popular', url='https://api.trakt.tv/movies/popular',
limit=limit,
languages=languages,
object_name='movies', object_name='movies',
type_name='popular', type_name='popular',
genres=genres limit=limit,
languages=languages,
genres=genres,
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_anticipated_movies(self, limit=1000, languages=None, genres=None): def get_anticipated_movies(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/anticipated', url='https://api.trakt.tv/movies/anticipated',
limit=limit,
languages=languages,
object_name='movies', object_name='movies',
type_name='anticipated', type_name='anticipated',
genres=genres limit=limit,
languages=languages,
genres=genres,
) )
def get_person_movies(self, person, limit=1000, languages=None, genres=None, include_non_acting_roles=False): def get_person_movies(self, person, limit=1000, languages=None, genres=None,
include_non_acting_roles=False):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/people/%s/movies' % person.replace(' ', '-').lower(), url='https://api.trakt.tv/people/%s/movies' % person.replace(' ', '-').lower(),
limit=limit,
languages=languages,
object_name='movies', object_name='movies',
type_name='person', type_name='person',
limit=limit,
languages=languages,
genres=genres, genres=genres,
include_non_acting_roles=include_non_acting_roles include_non_acting_roles=include_non_acting_roles,
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_most_played_movies(self, limit=1000, languages=None, genres=None, most_type=None): def get_most_played_movies(self, limit=1000, languages=None, genres=None, most_type=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/played/%s' % ('weekly' if not most_type else most_type), url='https://api.trakt.tv/movies/played/%s' % ('weekly' if not most_type else most_type),
limit=limit,
languages=languages,
object_name='movies', object_name='movies',
type_name='played', type_name='played',
genres=genres limit=limit,
languages=languages,
genres=genres,
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_most_watched_movies(self, limit=1000, languages=None, genres=None, most_type=None): def get_most_watched_movies(self, limit=1000, languages=None, genres=None, most_type=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/watched/%s' % ('weekly' if not most_type else most_type), url='https://api.trakt.tv/movies/watched/%s' % ('weekly' if not most_type else most_type),
limit=limit,
languages=languages,
object_name='movies', object_name='movies',
type_name='watched', type_name='watched',
genres=genres limit=limit,
languages=languages,
genres=genres,
) )
def get_boxoffice_movies(self, limit=1000, languages=None): def get_boxoffice_movies(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/boxoffice', url='https://api.trakt.tv/movies/boxoffice',
limit=limit,
languages=languages,
object_name='movies', object_name='movies',
type_name='anticipated', type_name='anticipated',
limit=limit,
languages=languages,
genres=genres,
) )
def get_recommended_movies(self, authenticate_user=None, limit=1000, languages=None, genres=None): def get_recommended_movies(self, authenticate_user=None, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/recommendations/movies', url='https://api.trakt.tv/recommendations/movies',
object_name='movies',
type_name='recommended from {authenticate_user}',
authenticate_user=authenticate_user, authenticate_user=authenticate_user,
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='movies', genres=genres,
type_name='recommended from {authenticate_user}',
genres=genres
) )
def get_watchlist_movies(self, authenticate_user=None, limit=1000, languages=None): def get_watchlist_movies(self, authenticate_user=None, limit=1000, languages=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/users/{authenticate_user}/watchlist/movies', url='https://api.trakt.tv/users/{authenticate_user}/watchlist/movies',
object_name='movies',
type_name='watchlist from {authenticate_user}',
authenticate_user=authenticate_user, authenticate_user=authenticate_user,
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='movies',
type_name='watchlist from {authenticate_user}',
) )
def get_user_list_movies(self, list_url, authenticate_user=None, limit=1000, languages=None): def get_user_list_movies(self, list_url, authenticate_user=None, limit=1000, languages=None):
@ -601,9 +612,9 @@ class Trakt:
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/users/' + list_user + '/lists/' + list_key + '/items/movies', url='https://api.trakt.tv/users/' + list_user + '/lists/' + list_key + '/items/movies',
object_name='movies',
type_name=(list_key + ' from ' + list_user),
authenticate_user=authenticate_user, authenticate_user=authenticate_user,
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='movies',
type_name=(list_key + ' from ' + list_user),
) )

@ -209,9 +209,9 @@ def show(show_id, folder=None, no_search=False):
@app.command(help='Add multiple shows to Sonarr.', context_settings=dict(max_content_width=100)) @app.command(help='Add multiple shows to Sonarr.', context_settings=dict(max_content_width=100))
@click.option( @click.option(
'--list-type', '-t', '--list-type', '-t',
help='Trakt list to process. ' help='Trakt list to process. \n'
'For example, \'anticipated\', \'trending\', \'popular\', \'person\', \'watched\', \'played\', ' 'For example, \'anticipated\', \'trending\', \'popular\', \'person\', \'watched\', \'played\', '
'\'recommended\', \'watchlist\', or any URL to a list', '\'recommended\', \'watchlist\', or any URL to a list.',
required=True) required=True)
@click.option( @click.option(
'--add-limit', '-l', '--add-limit', '-l',
@ -232,6 +232,7 @@ def show(show_id, folder=None, no_search=False):
'--genre', '-g', '--genre', '-g',
default=None, default=None,
help='Only add shows from this genre to Sonarr. ' help='Only add shows from this genre to Sonarr. '
'Only one genre can be specified. \n'
'Use \'ignore\' to add shows from any genre, including ones with no genre specified.') 'Use \'ignore\' to add shows from any genre, including ones with no genre specified.')
@click.option( @click.option(
'--folder', '-f', '--folder', '-f',
@ -241,11 +242,12 @@ def show(show_id, folder=None, no_search=False):
'--actor', '-a', '--actor', '-a',
default=None, default=None,
help='Only add movies from this actor to Radarr. ' help='Only add movies from this actor to Radarr. '
'Only one actor can be specified. \n'
'Requires the \'person\' list option.') 'Requires the \'person\' list option.')
@click.option( @click.option(
'--include-non-acting-roles', '--include-non-acting-roles',
is_flag=True, is_flag=True,
help='Include non-acting roles such as \'As Himself\', \'Narrator\', etc. ' help='Include non-acting roles such as \'As Himself\', \'Narrator\', etc. \n'
'Requires the \'person\' list option with the \'actor\' argument.') 'Requires the \'person\' list option with the \'actor\' argument.')
@click.option( @click.option(
'--no-search', '--no-search',
@ -257,7 +259,7 @@ def show(show_id, folder=None, no_search=False):
help='Send notifications.') help='Send notifications.')
@click.option( @click.option(
'--authenticate-user', '--authenticate-user',
help='Specify which user to authenticate with to retrieve Trakt lists. ' help='Specify which user to authenticate with to retrieve Trakt lists. \n'
'Defaults to first user in the config') 'Defaults to first user in the config')
@click.option( @click.option(
'--ignore-blacklist', '--ignore-blacklist',
@ -279,11 +281,14 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folde
added_shows = 0 added_shows = 0
# set special genre keyword 'ignore' if supplied # process genre
if genre and genre.lower == 'ignore': if genre:
# set special genre keyword to show's blacklisted_genres list
if genre.lower() == 'ignore':
cfg['filters']['shows']['blacklisted_genres'] = ['ignore'] cfg['filters']['shows']['blacklisted_genres'] = ['ignore']
# remove genre from shows blacklisted_genres if supplied genre = None
elif genre: # remove genre from show's blacklisted_genres list
else:
misc_helper.unblacklist_genres(genre, cfg['filters']['shows']['blacklisted_genres']) misc_helper.unblacklist_genres(genre, cfg['filters']['shows']['blacklisted_genres'])
# replace sonarr root_folder if folder is supplied # replace sonarr root_folder if folder is supplied
@ -304,16 +309,13 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folde
# get trakt series list # get trakt series list
if list_type.lower() == 'anticipated': if list_type.lower() == 'anticipated':
trakt_objects_list = trakt.get_anticipated_shows(genres=genre if genre and trakt_objects_list = trakt.get_anticipated_shows(genres=genre,
'ignore' not in genre.lower() else None,
languages=cfg.filters.shows.allowed_languages) languages=cfg.filters.shows.allowed_languages)
elif list_type.lower() == 'trending': elif list_type.lower() == 'trending':
trakt_objects_list = trakt.get_trending_shows(genres=genre if genre and trakt_objects_list = trakt.get_trending_shows(genres=genre,
'ignore' not in genre.lower() else None,
languages=cfg.filters.shows.allowed_languages) languages=cfg.filters.shows.allowed_languages)
elif list_type.lower() == 'popular': elif list_type.lower() == 'popular':
trakt_objects_list = trakt.get_popular_shows(genres=genre if genre and trakt_objects_list = trakt.get_popular_shows(genres=genre,
'ignore' not in genre.lower() else None,
languages=cfg.filters.shows.allowed_languages) languages=cfg.filters.shows.allowed_languages)
elif list_type.lower() == 'person': elif list_type.lower() == 'person':
if not actor: if not actor:
@ -321,25 +323,21 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folde
" list type!") " list type!")
return None return None
trakt_objects_list = trakt.get_person_shows(person=actor, trakt_objects_list = trakt.get_person_shows(person=actor,
genres=genre if genre and genres=genre,
'ignore' not in genre.lower() else None,
languages=cfg.filters.shows.allowed_languages, languages=cfg.filters.shows.allowed_languages,
include_non_acting_roles=include_non_acting_roles) include_non_acting_roles=include_non_acting_roles)
elif list_type.lower() == 'recommended': elif list_type.lower() == 'recommended':
trakt_objects_list = trakt.get_recommended_shows(authenticate_user, trakt_objects_list = trakt.get_recommended_shows(authenticate_user,
genres=genre if genre genres=genre,
and 'ignore' not in genre.lower() else None,
languages=cfg.filters.shows.allowed_languages) languages=cfg.filters.shows.allowed_languages)
elif list_type.lower().startswith('played'): elif list_type.lower().startswith('played'):
most_type = misc_helper.substring_after(list_type.lower(), "_") most_type = misc_helper.substring_after(list_type.lower(), "_")
trakt_objects_list = trakt.get_most_played_shows(genres=genre if genre trakt_objects_list = trakt.get_most_played_shows(genres=genre,
and 'ignore' not in genre.lower() else None,
languages=cfg.filters.shows.allowed_languages, languages=cfg.filters.shows.allowed_languages,
most_type=most_type if most_type else None) most_type=most_type if most_type else None)
elif list_type.lower().startswith('watched'): elif list_type.lower().startswith('watched'):
most_type = misc_helper.substring_after(list_type.lower(), "_") most_type = misc_helper.substring_after(list_type.lower(), "_")
trakt_objects_list = trakt.get_most_watched_shows(genres=genre if genre trakt_objects_list = trakt.get_most_watched_shows(genres=genre,
and 'ignore' not in genre.lower() else None,
languages=cfg.filters.shows.allowed_languages, languages=cfg.filters.shows.allowed_languages,
most_type=most_type if most_type else None) most_type=most_type if most_type else None)
elif list_type.lower() == 'watchlist': elif list_type.lower() == 'watchlist':
@ -550,9 +548,9 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False):
@app.command(help='Add multiple movies to Radarr.', context_settings=dict(max_content_width=100)) @app.command(help='Add multiple movies to Radarr.', context_settings=dict(max_content_width=100))
@click.option( @click.option(
'--list-type', '-t', '--list-type', '-t',
help='Trakt list to process. ' help='Trakt list to process. \n'
'For example, \'anticipated\', \'trending\', \'popular\', \'person\', \'watched\', \'played\', ' 'For example, \'anticipated\', \'trending\', \'popular\', \'person\', \'watched\', \'played\', '
'\'recommended\', \'watchlist\', or any URL to a list', '\'recommended\', \'watchlist\', or any URL to a list.',
required=True) required=True)
@click.option( @click.option(
'--add-limit', '-l', '--add-limit', '-l',
@ -577,6 +575,7 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False):
'--genre', '-g', '--genre', '-g',
default=None, default=None,
help='Only add movies from this genre to Radarr. ' help='Only add movies from this genre to Radarr. '
'Only one genre can be specified. \n'
'Use \'ignore\' to add movies from any genre, including ones with no genre specified.') 'Use \'ignore\' to add movies from any genre, including ones with no genre specified.')
@click.option( @click.option(
'--folder', '-f', '--folder', '-f',
@ -590,11 +589,12 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False):
'--actor', '-a', '--actor', '-a',
default=None, default=None,
help='Only add movies from this actor to Radarr.' help='Only add movies from this actor to Radarr.'
'Only one actor can be specified. \n'
'Requires the \'person\' list.') 'Requires the \'person\' list.')
@click.option( @click.option(
'--include-non-acting-roles', '--include-non-acting-roles',
is_flag=True, is_flag=True,
help='Include non-acting roles such as \'As Himself\', \'Narrator\', etc. ' help='Include non-acting roles such as \'As Himself\', \'Narrator\', etc. \n'
'Requires the \'person\' list option with the \'actor\' argument.') 'Requires the \'person\' list option with the \'actor\' argument.')
@click.option( @click.option(
'--no-search', '--no-search',
@ -606,8 +606,8 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False):
help='Send notifications.') help='Send notifications.')
@click.option( @click.option(
'--authenticate-user', '--authenticate-user',
help='Specify which user to authenticate with to retrieve Trakt lists. ' help='Specify which user to authenticate with to retrieve Trakt lists. \n'
'Default: first user in the config.') 'Defaults to first user in the config.')
@click.option( @click.option(
'--ignore-blacklist', '--ignore-blacklist',
is_flag=True, is_flag=True,
@ -629,11 +629,14 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
added_movies = 0 added_movies = 0
# set special genre keyword 'ignore' if supplied # process genre
if genre and genre.lower() == 'ignore': if genre:
# set special genre keyword to movies's blacklisted_genres list
if genre.lower() == 'ignore':
cfg['filters']['movies']['blacklisted_genres'] = ['ignore'] cfg['filters']['movies']['blacklisted_genres'] = ['ignore']
# remove genre from movies blacklisted_genres if supplied genre = None
elif genre: # remove genre from movies's blacklisted_genres list
else:
misc_helper.unblacklist_genres(genre, cfg['filters']['movies']['blacklisted_genres']) misc_helper.unblacklist_genres(genre, cfg['filters']['movies']['blacklisted_genres'])
# replace radarr root_folder if folder is supplied # replace radarr root_folder if folder is supplied
@ -664,45 +667,39 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
# get trakt movies list # get trakt movies list
if list_type.lower() == 'anticipated': if list_type.lower() == 'anticipated':
trakt_objects_list = trakt.get_anticipated_movies(genres=genre if genre trakt_objects_list = trakt.get_anticipated_movies(genres=genre,
and 'ignore' not in genre.lower() else None,
languages=cfg.filters.movies.allowed_languages) languages=cfg.filters.movies.allowed_languages)
elif list_type.lower() == 'trending': elif list_type.lower() == 'trending':
trakt_objects_list = trakt.get_trending_movies(genres=genre if genre trakt_objects_list = trakt.get_trending_movies(genres=genre,
and 'ignore' not in genre.lower() else None,
languages=cfg.filters.movies.allowed_languages) languages=cfg.filters.movies.allowed_languages)
elif list_type.lower() == 'popular': elif list_type.lower() == 'popular':
trakt_objects_list = trakt.get_popular_movies(genres=genre if genre trakt_objects_list = trakt.get_popular_movies(genres=genre,
and 'ignore' not in genre.lower() else None,
languages=cfg.filters.movies.allowed_languages) languages=cfg.filters.movies.allowed_languages)
elif list_type.lower() == 'boxoffice': elif list_type.lower() == 'boxoffice':
trakt_objects_list = trakt.get_boxoffice_movies() trakt_objects_list = trakt.get_boxoffice_movies(genres=genre,
languages=cfg.filters.movies.allowed_languages)
elif list_type.lower() == 'person': elif list_type.lower() == 'person':
if not actor: if not actor:
log.error("You must specify an actor with the \'--actor\' / \'-a\' parameter when using the \'person\'" + log.error("You must specify an actor with the \'--actor\' / \'-a\' parameter when using the \'person\'" +
" list type!") " list type!")
return None return None
trakt_objects_list = trakt.get_person_movies(person=actor, trakt_objects_list = trakt.get_person_movies(person=actor,
genres=genre if genre genres=genre,
and 'ignore' not in genre.lower() else None,
languages=cfg.filters.movies.allowed_languages, languages=cfg.filters.movies.allowed_languages,
include_non_acting_roles=include_non_acting_roles) include_non_acting_roles=include_non_acting_roles)
elif list_type.lower() == 'recommended': elif list_type.lower() == 'recommended':
trakt_objects_list = trakt.get_recommended_movies(authenticate_user, trakt_objects_list = trakt.get_recommended_movies(authenticate_user,
genres=genre if genre genres=genre,
and 'ignore' not in genre.lower() else None,
languages=cfg.filters.movies.allowed_languages) languages=cfg.filters.movies.allowed_languages)
elif list_type.lower().startswith('played'): elif list_type.lower().startswith('played'):
most_type = misc_helper.substring_after(list_type.lower(), "_") most_type = misc_helper.substring_after(list_type.lower(), "_")
trakt_objects_list = trakt.get_most_played_movies(genres=genre if genre trakt_objects_list = trakt.get_most_played_movies(genres=genre,
and 'ignore' not in genre.lower() else None,
languages=cfg.filters.movies.allowed_languages, languages=cfg.filters.movies.allowed_languages,
most_type=most_type if most_type else None) most_type=most_type if most_type else None)
elif list_type.lower().startswith('watched'): elif list_type.lower().startswith('watched'):
most_type = misc_helper.substring_after(list_type.lower(), "_") most_type = misc_helper.substring_after(list_type.lower(), "_")
trakt_objects_list = trakt.get_most_watched_movies(genres=genre if genre trakt_objects_list = trakt.get_most_watched_movies(genres=genre,
and 'ignore' not in genre.lower() else None,
languages=cfg.filters.movies.allowed_languages, languages=cfg.filters.movies.allowed_languages,
most_type=most_type if most_type else None) most_type=most_type if most_type else None)
elif list_type.lower() == 'watchlist': elif list_type.lower() == 'watchlist':

Loading…
Cancel
Save