New Feature: Minimum Availability

pull/87/head
desimaniac 6 years ago
parent a34b4b0f30
commit 8ccfdb78a6

@ -281,6 +281,7 @@ You can repeat this process for as many users as you like.
}, },
"radarr": { "radarr": {
"api_key": "", "api_key": "",
"minimum_availability": "released",
"profile": "HD-1080p", "profile": "HD-1080p",
"root_folder": "/movies/", "root_folder": "/movies/",
"url": "http://localhost:7878/" "url": "http://localhost:7878/"
@ -714,6 +715,7 @@ Radarr configuration.
```json ```json
"radarr": { "radarr": {
"api_key": "", "api_key": "",
"minimum_availability": "released",
"profile": "HD-1080p", "profile": "HD-1080p",
"root_folder": "/movies/", "root_folder": "/movies/",
"url": "http://localhost:7878" "url": "http://localhost:7878"
@ -723,6 +725,12 @@ Radarr configuration.
`profile` - Profile that movies are assigned to. `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. `root_folder` - Root folder for movies.
`url` - Radarr's URL. `url` - Radarr's URL.
@ -936,11 +944,26 @@ Usage: traktarr movie [OPTIONS]
Options: Options:
-id, --movie-id TEXT Trakt Movie ID. [required] -id, --movie-id TEXT Trakt Movie ID. [required]
-f, --folder TEXT Add movie with this root folder to Radarr. -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. --no-search Disable search when adding movie to Radarr.
--help Show this message and exit. --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) ### Movies (Multiple Movies)
@ -965,6 +988,8 @@ Options:
-r, --rating INTEGER Set a minimum rating threshold (according to Rotten Tomatoes) -r, --rating INTEGER Set a minimum rating threshold (according to Rotten Tomatoes)
-g, --genre TEXT Only add movies from this genre to Radarr. -g, --genre TEXT Only add movies from this genre to Radarr.
-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]
Add movies with this minimum availability to Radarr.
-a, --actor TEXT Only add movies from this actor to Radarr. -a, --actor TEXT Only add movies from this actor to Radarr.
--no-search Disable search when adding movies to Radarr. --no-search Disable search when adding movies to Radarr.
--notifications Send notifications. --notifications Send notifications.
@ -1016,10 +1041,16 @@ Options:
- Can find a list [here](assets/list_of_movie_genres.md). - 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/` - 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. `-a`, `--actor` - Only add movies with a specific actor to Radarr.
`--no-search` - Tells Radarr to not automatically search for added movies. `--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. `--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. `--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. --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) ### Shows (Multiple Shows)

@ -95,6 +95,7 @@
"radarr": { "radarr": {
"api_key": "", "api_key": "",
"profile": "HD-1080p", "profile": "HD-1080p",
"minimum_availability": "released",
"url": "http://localhost:7878/", "url": "http://localhost:7878/",
"root_folder": "/movies/" "root_folder": "/movies/"
}, },

@ -13,13 +13,23 @@ class Radarr(PVR):
@backoff.on_predicate(backoff.expo, lambda x: x is None, max_tries=4, on_backoff=backoff_handler) @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, 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) 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, { payload = dict_merge(payload, {
'tmdbId': movie_tmdbid, 'tmdbId': movie_tmdbid,
'year': movie_year, 'year': movie_year,
'minimumAvailability': 'released', 'minimumAvailability': minimum_availability,
'addOptions': { 'addOptions': {
'searchForMovie': search_missing 'searchForMovie': search_missing
} }

@ -42,18 +42,19 @@ class Config(object, metaclass=Singleton):
'client_secret': '' 'client_secret': ''
}, },
'sonarr': { 'sonarr': {
'url': 'http://localhost:8989/',
'api_key': '', 'api_key': '',
'profile': 'HD-1080p', 'profile': 'HD-1080p',
'root_folder': '/tv/', 'root_folder': '/tv/',
'tags': { 'tags': {
} },
'url': 'http://localhost:8989/'
}, },
'radarr': { 'radarr': {
'url': 'http://localhost:7878/',
'api_key': '', 'api_key': '',
'minimum_availability': 'released',
'profile': 'HD-1080p', 'profile': 'HD-1080p',
'root_folder': '/movies/' 'root_folder': '/movies/',
'url': 'http://localhost:7878/'
}, },
'omdb': { 'omdb': {
'api_key': '' 'api_key': ''

@ -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('--no-search', is_flag=True, help='Disable search when adding shows to Sonarr.')
@click.option('--notifications', is_flag=True, help='Send notifications.') @click.option('--notifications', is_flag=True, help='Send notifications.')
@click.option('--authenticate-user', @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('--ignore-blacklist', is_flag=True, help='Ignores the blacklist when running the command.')
@click.option('--remove-rejected-from-recommended', is_flag=True, @click.option('--remove-rejected-from-recommended', is_flag=True,
help='Removes rejected/existing shows from recommended.') 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)) @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('--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('--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.') @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.radarr import Radarr
from media.trakt import Trakt from media.trakt import Trakt
@ -377,7 +381,8 @@ def movie(movie_id, folder=None, no_search=False):
# add movie to radarr # add movie to radarr
if radarr.add_movie(trakt_movie['ids']['tmdb'], trakt_movie['title'], trakt_movie['year'], 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']) log.info("ADDED %s (%d)", trakt_movie['title'], trakt_movie['year'])
else: else:
log.error("FAILED adding %s (%d)", trakt_movie['title'], trakt_movie['year']) 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)') 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('--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('--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('--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('--no-search', is_flag=True, help='Disable search when adding movies to Radarr.')
@click.option('--notifications', is_flag=True, help='Send notifications.') @click.option('--notifications', is_flag=True, help='Send notifications.')
@click.option('--authenticate-user', @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('--ignore-blacklist', is_flag=True, help='Ignores the blacklist when running the command.')
@click.option('--remove-rejected-from-recommended', is_flag=True, @click.option('--remove-rejected-from-recommended', 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, actor=None, def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, genre=None, folder=None, actor=None,
no_search=False, minimum_availability=None, no_search=False, notifications=False, authenticate_user=None,
notifications=False, authenticate_user=None, ignore_blacklist=False, remove_rejected_from_recommended=False): 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
@ -536,7 +545,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
# add movie to radarr # add movie to radarr
if radarr.add_movie(movie['movie']['ids']['tmdb'], movie['movie']['title'], movie['movie']['year'], if radarr.add_movie(movie['movie']['ids']['tmdb'], movie['movie']['title'], movie['movie']['year'],
movie['movie']['ids']['slug'], profile_id, cfg.radarr.root_folder, 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']) log.info("ADDED %s (%d)", movie['movie']['title'], movie['movie']['year'])
if notifications: if notifications:
callback_notify({'event': 'add_movie', 'list_type': list_type, 'movie': movie['movie']}) callback_notify({'event': 'add_movie', 'list_type': list_type, 'movie': movie['movie']})

Loading…
Cancel
Save