diff --git a/README.md b/README.md index 4d247c3..480d74a 100644 --- a/README.md +++ b/README.md @@ -16,40 +16,40 @@ - [Demo](#demo) - [Requirements](#requirements) - [Installation](#installation) - - [1. Base Install](#1-base-install) - - [2. Create a Trakt Application](#2-create-a-trakt-application) - - [3. Authenticate User(s) (optional)](#3-authenticate-users-optional) + - [1. Base Install](#1-base-install) + - [2. Create a Trakt Application](#2-create-a-trakt-application) + - [3. Authenticate User(s) (optional)](#3-authenticate-users-optional) - [Configuration](#configuration) - - [Sample Configuration](#sample-configuration) - - [Core](#core) - - [Automatic](#automatic) - - [Personal Watchlists](#personal-watchlists) - - [Custom Lists](#custom-lists) - - [Public Lists](#public-lists) - - [Private Lists](#private-lists) - - [Filters](#filters) - - [Movies](#movies) - - [Shows](#shows) - - [Notifications](#notifications) - - [Pushover](#pushover) - - [Slack](#slack) - - [Radarr](#radarr) - - [Sonarr](#sonarr) - - [Tags](#tags) - - [Trakt](#trakt) + - [Sample Configuration](#sample-configuration) + - [Core](#core) + - [Automatic](#automatic) + - [Personal Watchlists](#personal-watchlists) + - [Custom Lists](#custom-lists) + - [Public Lists](#public-lists) + - [Private Lists](#private-lists) + - [Filters](#filters) + - [Movies](#movies) + - [Shows](#shows) + - [Notifications](#notifications) + - [Pushover](#pushover) + - [Slack](#slack) + - [Radarr](#radarr) + - [Sonarr](#sonarr) + - [Tags](#tags) + - [Trakt](#trakt) - [Usage](#usage) - - [Automatic (Scheduled)](#automatic-scheduled) - - [Setup](#setup) - - [Customize](#customize) - - [Manual (CLI)](#manual-cli) - - [General](#general) - - [Movie (Single Movie)](#movie-single-movie) - - [Movies (Multiple Movies)](#movies-multiple-movies) - - [Show (Single Show)](#show-single-show) - - [Shows (Multiple Shows)](#shows-multiple-shows) - - [Examples (CLI)](#examples-cli) - - [Movies](#movies) - - [Shows](#shows) + - [Automatic (Scheduled)](#automatic-scheduled) + - [Setup](#setup) + - [Customize](#customize) + - [Manual (CLI)](#manual-cli) + - [General](#general) + - [Movie (Single Movie)](#movie-single-movie) + - [Movies (Multiple Movies)](#movies-multiple-movies) + - [Show (Single Show)](#show-single-show) + - [Shows (Multiple Shows)](#shows-multiple-shows) + - [Examples (CLI)](#examples-cli) + - [Movies](#movies) + - [Shows](#shows) - [Donate](#donate) @@ -281,6 +281,7 @@ You can repeat this process for as many users as you like. }, "radarr": { "api_key": "", + "minimum_availability": "released", "profile": "HD-1080p", "root_folder": "/movies/", "url": "http://localhost:7878/" @@ -714,6 +715,7 @@ Radarr configuration. ```json "radarr": { "api_key": "", + "minimum_availability": "released", "profile": "HD-1080p", "root_folder": "/movies/", "url": "http://localhost:7878" @@ -723,6 +725,12 @@ Radarr configuration. `profile` - Profile that movies are assigned to. +`minimum_availability` - The minimum availability the movies are set to. + + - Choices are `announced`, `in_cinemas`, `released` (Physical/Web), or `predb`. + + - Default is `released` (Physical/Web). + `root_folder` - Root folder for movies. `url` - Radarr's URL. @@ -936,11 +944,26 @@ Usage: traktarr movie [OPTIONS] Options: -id, --movie-id TEXT Trakt Movie ID. [required] -f, --folder TEXT Add movie with this root folder to Radarr. + -ma, --minimum-availability [announced|in_cinemas|released|predb] + Add movies with this minimum availability to Radarr. --no-search Disable search when adding movie to Radarr. --help Show this message and exit. ``` -_Note: This command only works with `-id` or `--show-id` specified (i.e. not with lists), and supports both Trakt and IMDB IDs._ +`-id`, `--movie-id` - ID/slug of the movie to add to Radarr. Supports both Trakt and IMDB IDs. This arguent is required. + +`-f`, `--folder` - Add movie to a specific root folder in Radarr. + + - Example: `-f /mnt/unionfs/Media/Movies/Movies-Kids/` + +`minimum_availability` - The minimum availability the movies are set to. + + - Choices are `announced`, `in_cinemas`, `released` (Physical/Web), or `predb`. + + - Default is `released` (Physical/Web). + +`--no-search` - Tells Radarr to not automatically search for added movies. + ### Movies (Multiple Movies) @@ -965,6 +988,8 @@ Options: -r, --rating INTEGER Set a minimum rating threshold (according to Rotten Tomatoes) -g, --genre TEXT Only add movies from this genre to Radarr. -f, --folder TEXT Add movies with this root folder to Radarr. + -ma, --minimum-availability [announced|in_cinemas|released|predb] + Add movies with this minimum availability to Radarr. -a, --actor TEXT Only add movies from this actor to Radarr. --no-search Disable search when adding movies to Radarr. --notifications Send notifications. @@ -1016,10 +1041,16 @@ Options: - Can find a list [here](assets/list_of_movie_genres.md). -`-f`, `--folder` - Add shows to a specific root folder in Radarr. +`-f`, `--folder` - Add movies to a specific root folder in Radarr. - Example: `-f /mnt/unionfs/Media/Movies/Movies-Kids/` +`minimum_availability` - The minimum availability the movies are set to. + + - Choices are `announced`, `in_cinemas`, `released` (Physical/Web), or `predb`. + + - Default is `released` (Physical/Web). + `-a`, `--actor` - Only add movies with a specific actor to Radarr. `--no-search` - Tells Radarr to not automatically search for added movies. @@ -1028,7 +1059,9 @@ Options: `--authenticate-user` - Specify which authenticated user to retrieve Trakt lists as. Default is the first user in the config. -`--ignore-blacklist` - Ignores blacklist filtering. Equivalent of `disabled_for` in `config.json`. +`--ignore-blacklist` - Ignores blacklist filtering. + + - Equivalent of `disabled_for` in `config.json`. `--remove-rejected-from-recommended` - Removes rejected/existing shows from the recommended list, so that it will be removed from further recommendations. @@ -1052,7 +1085,7 @@ Options: --help Show this message and exit. ``` -_Note: This command only works with `-id` or `--show-id` specified (i.e. not with lists), and supports both Trakt and IMDB IDs._ +`-id`, `--show-id` - ID/slug of the show to add to Sonarr. Supports both Trakt and IMDB IDs. This argument is required. ### Shows (Multiple Shows) diff --git a/config.json.sample b/config.json.sample index a79bd65..3139025 100644 --- a/config.json.sample +++ b/config.json.sample @@ -95,6 +95,7 @@ "radarr": { "api_key": "", "profile": "HD-1080p", + "minimum_availability": "released", "url": "http://localhost:7878/", "root_folder": "/movies/" }, diff --git a/media/radarr.py b/media/radarr.py index 7d52f92..aa7ba38 100644 --- a/media/radarr.py +++ b/media/radarr.py @@ -13,13 +13,23 @@ class Radarr(PVR): @backoff.on_predicate(backoff.expo, lambda x: x is None, max_tries=4, on_backoff=backoff_handler) def add_movie(self, movie_tmdbid, movie_title, movie_year, movie_title_slug, profile_id, root_folder, - search_missing=False): + min_avail, search_missing=False): payload = self._prepare_add_object_payload(movie_title, movie_title_slug, profile_id, root_folder) + # replace radarr minimum_availability if supplied + if min_avail == 'announced': + minimum_availability = 'announced' + elif min_avail == 'in_cinemas': + minimum_availability = 'inCinemas' + elif min_avail == 'predb': + minimum_availability = 'preDB' + else: + minimum_availability = 'released' + payload = dict_merge(payload, { 'tmdbId': movie_tmdbid, 'year': movie_year, - 'minimumAvailability': 'released', + 'minimumAvailability': minimum_availability, 'addOptions': { 'searchForMovie': search_missing } diff --git a/misc/config.py b/misc/config.py index 4ddfe5f..575c2a7 100644 --- a/misc/config.py +++ b/misc/config.py @@ -42,18 +42,19 @@ class Config(object, metaclass=Singleton): 'client_secret': '' }, 'sonarr': { - 'url': 'http://localhost:8989/', 'api_key': '', 'profile': 'HD-1080p', 'root_folder': '/tv/', 'tags': { - } + }, + 'url': 'http://localhost:8989/' }, 'radarr': { - 'url': 'http://localhost:7878/', 'api_key': '', + 'minimum_availability': 'released', 'profile': 'HD-1080p', - 'root_folder': '/movies/' + 'root_folder': '/movies/', + 'url': 'http://localhost:7878/' }, 'omdb': { 'api_key': '' diff --git a/traktarr.py b/traktarr.py index b7ef916..e9be605 100755 --- a/traktarr.py +++ b/traktarr.py @@ -185,7 +185,8 @@ def show(show_id, folder=None, no_search=False): @click.option('--no-search', is_flag=True, help='Disable search when adding shows to Sonarr.') @click.option('--notifications', is_flag=True, help='Send notifications.') @click.option('--authenticate-user', - help='Specify which user to authenticate with to retrieve Trakt lists. Default: first user in the config') + help='Specify which user to authenticate with to retrieve Trakt lists. ' + 'Default: first user in the config') @click.option('--ignore-blacklist', is_flag=True, help='Ignores the blacklist when running the command.') @click.option('--remove-rejected-from-recommended', is_flag=True, help='Removes rejected/existing shows from recommended.') @@ -347,8 +348,11 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folde @app.command(help='Add a single movie to Radarr.', context_settings=dict(max_content_width=100)) @click.option('--movie-id', '-id', help='Trakt Movie ID.', required=True) @click.option('--folder', '-f', default=None, help='Add movie with this root folder to Radarr.') +@click.option('--minimum-availability', '-ma', default='released', + type=click.Choice(['announced', 'in_cinemas', 'released', 'predb']), + help='Add movies with this minimum availability to Radarr.') @click.option('--no-search', is_flag=True, help='Disable search when adding movie to Radarr.') -def movie(movie_id, folder=None, no_search=False): +def movie(movie_id, folder=None, minimum_availability=None, no_search=False): from media.radarr import Radarr from media.trakt import Trakt @@ -377,7 +381,8 @@ def movie(movie_id, folder=None, no_search=False): # add movie to radarr if radarr.add_movie(trakt_movie['ids']['tmdb'], trakt_movie['title'], trakt_movie['year'], - trakt_movie['ids']['slug'], profile_id, cfg.radarr.root_folder, not no_search): + trakt_movie['ids']['slug'], profile_id, cfg.radarr.root_folder, + cfg.radarr.minimum_availability, not no_search): log.info("ADDED %s (%d)", trakt_movie['title'], trakt_movie['year']) else: log.error("FAILED adding %s (%d)", trakt_movie['title'], trakt_movie['year']) @@ -397,17 +402,21 @@ def movie(movie_id, folder=None, no_search=False): help='Set a minimum rating threshold (according to Rotten Tomatoes)') @click.option('--genre', '-g', default=None, help='Only add movies from this genre to Radarr.') @click.option('--folder', '-f', default=None, help='Add movies with this root folder to Radarr.') +@click.option('--minimum-availability', '-ma', default='released', + type=click.Choice(['announced', 'in_cinemas', 'released', 'predb']), + help='Add movies with this minimum availability to Radarr.') @click.option('--actor', '-a', default=None, help='Only add movies from this actor to Radarr.') @click.option('--no-search', is_flag=True, help='Disable search when adding movies to Radarr.') @click.option('--notifications', is_flag=True, help='Send notifications.') @click.option('--authenticate-user', - help='Specify which user to authenticate with to retrieve Trakt lists. Default: first user in the config.') + help='Specify which user to authenticate with to retrieve Trakt lists. ' + 'Default: first user in the config.') @click.option('--ignore-blacklist', is_flag=True, help='Ignores the blacklist when running the command.') @click.option('--remove-rejected-from-recommended', is_flag=True, 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, actor=None, - no_search=False, - notifications=False, authenticate_user=None, ignore_blacklist=False, remove_rejected_from_recommended=False): + minimum_availability=None, no_search=False, notifications=False, authenticate_user=None, + ignore_blacklist=False, remove_rejected_from_recommended=False): from media.radarr import Radarr from media.trakt import Trakt from helpers import misc as misc_helper @@ -536,7 +545,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen # add movie to radarr if radarr.add_movie(movie['movie']['ids']['tmdb'], movie['movie']['title'], movie['movie']['year'], movie['movie']['ids']['slug'], profile_id, cfg.radarr.root_folder, - not no_search): + cfg.radarr.minimum_availability, not no_search): log.info("ADDED %s (%d)", movie['movie']['title'], movie['movie']['year']) if notifications: callback_notify({'event': 'add_movie', 'list_type': list_type, 'movie': movie['movie']})