CLI: New argument --include-non-acting-roles

Use with person/actor search to filter out non-major-acting roles, eg As Himself, Narrator, etc
pull/105/head
desimaniac 5 years ago
parent 56fbb780c9
commit fb645779f2

@ -1157,19 +1157,24 @@ 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, boxoffice, person, watched, recommended, played, '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. [default: 0] -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 rating threshold (according to Rotten Tomatoes) -r, --rating INTEGER Set a minimum Rotten Tomatoes score.
-g, --genre TEXT Only add movies from this genre to Radarr. -g, --genre TEXT Only add movies from this genre to Radarr. 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. Add movies with this minimum availability to Radarr. Default is
-a, --actor TEXT Only add movies from this actor to Radarr. 'released'.
-a, --actor TEXT Only add movies from this actor to Radarr. Requires the 'person'
list.
--include-non-acting-roles Include non-acting roles such as 'As Himself', 'Narrator', etc.
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.
@ -1234,6 +1239,10 @@ Options:
- Requires the list type `person`. - Requires the list type `person`.
`--include-non-acting-roles` - Include non-acting roles of the specified actor.
- Requires the list type `person` used with the `-a`/`--actor` option.
`--no-search` - Tells Radarr to not automatically search for added movies. `--no-search` - Tells Radarr to not automatically search for added movies.
`--notifications` - To enable notifications. Default is `disabled`. `--notifications` - To enable notifications. Default is `disabled`.
@ -1282,20 +1291,24 @@ 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, watchlist or any 'popular', 'person', 'watched', 'played', 'recommended',
URL to a list [required] 'watchlist', or any URL to a list [required]
-l, --add-limit INTEGER Limit number of shows added to Sonarr. [default: 0] -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. -g, --genre TEXT Only add shows from this genre to Sonarr. 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. -a, --actor TEXT Only add movies from this actor to Radarr. Requires the 'person'
list option.
--include-non-acting-roles Include non-acting roles such as 'As Himself', 'Narrator', etc.
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.
--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 shows from recommended. Removes rejected/existing shows from recommended.
@ -1347,6 +1360,10 @@ Options:
- Requires the list type `person`. - Requires the list type `person`.
`--include-non-acting-roles` - Include non-acting roles of the specified actor.
- Requires the list type `person` used with the `-a`/`--actor` option.
`--no-search` - Tells Sonarr to not automatically search for added shows. `--no-search` - Tells Sonarr to not automatically search for added shows.
`--notifications` - To enable notifications. Default is `disabled`. `--notifications` - To enable notifications. Default is `disabled`.
@ -1410,10 +1427,16 @@ Options:
traktarr movies -t trending -r 80 traktarr movies -t trending -r 80
``` ```
- Add movies, with actor 'Tom Cruise', limited to 10 items. - Add movies, with actor 'Keanu Reeves', limited to 10 items.
```
traktarr movies -t person -a 'keanu reeves' -l 10
```
- Add movies, with actor 'Tom Cruise', including movies where he has non-acting roles, limited to 10 items.
``` ```
traktarr movies -t person -a 'tom cruise' -l 10 traktarr movies -t person -a 'tom cruise' --include_non_acting_roles -l 10
``` ```
### Shows ### Shows

@ -72,7 +72,7 @@ class Trakt:
@backoff.on_predicate(backoff.expo, lambda x: x is None, max_tries=6, on_backoff=backoff_handler) @backoff.on_predicate(backoff.expo, lambda x: x is None, max_tries=6, on_backoff=backoff_handler)
def _make_items_request(self, url, limit, languages, type_name, object_name, authenticate_user=None, payload={}, def _make_items_request(self, url, limit, languages, type_name, object_name, authenticate_user=None, payload={},
sleep_between=5, genres=None): sleep_between=5, genres=None, include_non_acting_roles=False):
if not languages: if not languages:
languages = ['en'] languages = ['en']
@ -128,8 +128,13 @@ class Trakt:
resp_json = json.loads(resp_data) resp_json = json.loads(resp_data)
if type_name == 'person' and 'cast' in resp_json: if type_name == 'person' and 'cast' in resp_json:
# handle person results
for item in resp_json['cast']: for item in resp_json['cast']:
# filter out non-acting roles
if not include_non_acting_roles and \
((item['character'].strip() == '') or
'narrat' in item['character'].lower() or
'himself' in item['character'].lower()):
continue
if item not in processed: if item not in processed:
if object_name.rstrip('s') not in item and 'title' in item: if object_name.rstrip('s') not in item and 'title' in item:
processed.append({object_name.rstrip('s'): item}) processed.append({object_name.rstrip('s'): item})
@ -415,14 +420,15 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_person_shows(self, person, limit=1000, languages=None, genres=None): 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, limit=limit,
languages=languages, languages=languages,
object_name='shows', object_name='shows',
type_name='person', type_name='person',
genres=genres genres=genres,
include_non_acting_roles=include_non_acting_roles
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
@ -527,14 +533,15 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_person_movies(self, person, limit=1000, languages=None, genres=None): 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, limit=limit,
languages=languages, languages=languages,
object_name='movies', object_name='movies',
type_name='person', type_name='person',
genres=genres genres=genres,
include_non_acting_roles=include_non_acting_roles
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)

@ -226,7 +226,13 @@ def show(show_id, folder=None, no_search=False):
@click.option( @click.option(
'--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. '
'Requires the \'person\' list option.')
@click.option(
'--include-non-acting-roles',
is_flag=True,
help='Include non-acting roles such as \'As Himself\', \'Narrator\', etc. '
'Requires the \'person\' list option with the \'actor\' argument.')
@click.option( @click.option(
'--no-search', '--no-search',
is_flag=True, is_flag=True,
@ -248,7 +254,8 @@ def show(show_id, folder=None, no_search=False):
is_flag=True, is_flag=True,
help='Removes rejected/existing shows from recommended.') help='Removes rejected/existing shows from recommended.')
def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folder=None, actor=None, no_search=False, def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folder=None, actor=None, no_search=False,
notifications=False, authenticate_user=None, ignore_blacklist=False, remove_rejected_from_recommended=False): include_non_acting_roles=False, notifications=False, authenticate_user=None, ignore_blacklist=False,
remove_rejected_from_recommended=False):
from media.sonarr import Sonarr from media.sonarr import Sonarr
from media.trakt import Trakt from media.trakt import Trakt
from helpers import misc as misc_helper from helpers import misc as misc_helper
@ -301,7 +308,8 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folde
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 if genre and
'ignore' not in genre.lower() else None, '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)
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 if genre
@ -544,7 +552,13 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False):
@click.option( @click.option(
'--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. '
'Requires the \'person\' list.')
@click.option(
'--include-non-acting-roles',
is_flag=True,
help='Include non-acting roles such as \'As Himself\', \'Narrator\', etc. '
'Requires the \'person\' list option with the \'actor\' argument.')
@click.option( @click.option(
'--no-search', '--no-search',
is_flag=True, is_flag=True,
@ -566,8 +580,8 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False):
is_flag=True, is_flag=True,
help='Removes rejected/existing movies from recommended.') help='Removes rejected/existing movies from recommended.')
def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, genre=None, folder=None, def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, genre=None, folder=None,
minimum_availability=None, actor=None, no_search=False, notifications=False, authenticate_user=None, minimum_availability=None, actor=None, include_non_acting_roles=False, no_search=False, notifications=False,
ignore_blacklist=False, remove_rejected_from_recommended=False): authenticate_user=None, ignore_blacklist=False, remove_rejected_from_recommended=False):
from media.radarr import Radarr from media.radarr import Radarr
from media.trakt import Trakt from media.trakt import Trakt
from helpers import misc as misc_helper from helpers import misc as misc_helper
@ -634,7 +648,8 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
trakt_objects_list = trakt.get_person_movies(person=actor, trakt_objects_list = trakt.get_person_movies(person=actor,
genres=genre if genre genres=genre if genre
and 'ignore' not in genre.lower() else None, 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)
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,

Loading…
Cancel
Save