[53] #497 add upgrade_existing for radarr/sonarr

This commit is contained in:
meisnate12 2022-04-30 19:57:26 -04:00
parent 2b6e6f1cec
commit 2995269805
8 changed files with 90 additions and 51 deletions

View file

@ -1 +1 @@
1.16.5-develop52
1.16.5-develop53

View file

@ -26,11 +26,12 @@ radarr:
```
| Attribute | Allowed Values | Default | Required |
|:-------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------:|:--------:|
|:-------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------:|:--------:|
| `url` | Radarr URL (Including URL Base if set).<br>**Example:** http://192.168.1.12:32788 | N/A | &#9989; |
| `token` | Radarr API Token. | N/A | &#9989; |
| `add_missing` | Adds all missing movies found from all collections to Radarr.<br>Use the `radarr_add_missing` [Radarr Details](../metadata/details/arr.md#radarr-details) in the collection definition to add missing per collection.<br>**boolean:** true or false | false | &#10060; |
| `add_existing` | Adds all existing movies in collections to Radarr.<br>Use the `radarr_add_existing` [Radarr Details](../metadata/details/arr.md#radarr-details) in the collection definition to add existing per collection.<br>**boolean:** true or false | false | &#10060; |
| `upgrade_existing` | Upgrades all existing movies in collections to match the Quality Profile of the collection.<br>Use the `radarr_upgrade_existing` [Radarr Details](../metadata/details/arr.md#radarr-details) in the collection definition to upgrade the Quality Profile per collection.<br>**boolean:** true or false | false | &#10060; |
| `root_folder_path` | Default Root Folder Path to use when adding new movies.<br>Use the `radarr_folder` [Radarr Details](../metadata/details/arr.md#radarr-details) in the collection definition to set the Root Folder per collection. | N/A | &#9989; |
| `monitor` | Monitor the movie when adding new movies.<br>Use the `radarr_monitor` [Radarr Details](../metadata/details/arr.md#radarr-details) in the collection definition to set the Monitor value per collection. | true | &#10060; |
| `availability` | Default Minimum Availability to use when adding new movies.<br>Use the `radarr_availability` [Radarr Details](../metadata/details/arr.md#radarr-details) in the collection definition to set the Availability per collection.<br>**Options:** `announced`, `cinemas`, `released`, `db` | `announced` | &#9989; |
@ -71,15 +72,16 @@ libraries:
radarr:
url: https://radarr.bing.bang
token: SOME_TOKEN
add_missing: true
add_existing: false
upgrade_existing: false
root_folder_path: /movies
monitor: true
availability: released
quality_profile: Any
tag:
search: false
add_existing: false
radarr_path:
plex_path:
add_missing: true
...
```

View file

@ -34,6 +34,7 @@ sonarr:
| `token` | Sonarr API Token. | N/A | &#9989; |
| `add_missing` | Adds all missing shows found from all collections to Sonarr.<br>Use the `sonarr_add_missing` [Sonarr Details](../metadata/details/arr.md#sonarr-details) in the collection definition to add missing per collection.<br>**boolean:** true or false | false | &#10060; |
| `add_existing` | Adds all existing shows in collections to Sonarr.<br>Use the `sonarr_add_existing` [Sonarr Details](../metadata/details/arr.md#sonarr-details) in the collection definition to add existing per collection.<br>**boolean:** true or false | false | &#10060; |
| `upgrade_existing` | Upgrades all existing shows in collections to match the Quality Profile of the collection.<br>Use the `sonarr_upgrade_existing` [Sonarr Details](../metadata/details/arr.md#sonarr-details) in the collection definition to upgrade the Quality Profile per collection.<br>**boolean:** true or false | false | &#10060; |
| `root_folder_path` | Default Root Folder Path to use when adding new shows.<br>Use the `sonarr_folder` [Sonarr Details](../metadata/details/arr.md#sonarr-details) in the collection definition to set the Root Folder per collection. | N/A | &#9989; |
| `monitor` | Default Monitor to use when adding new shows.<br>Use the `sonarr_monitor` [Sonarr Details](../metadata/details/arr.md#sonarr-details) in the collection definition to set the Monitor value per collection.<br>**Values:** <table class="clearTable"><tr><td>`all`</td><td>All episodes except specials</td></tr><tr><td>`future`</td><td>Episodes that have not aired yet</td></tr><tr><td>`missing`</td><td>Episodes that do not have files or have not aired yet</td></tr><tr><td>`existing`</td><td>Episodes that have files or have not aired yet</td></tr><tr><td>`pilot`</td><td>The first episode, all others will be ignored</td></tr><tr><td>`first`</td><td>All episodes of the first season, all others will be ignored</td></tr><tr><td>`latest`</td><td>All episodes of the latest season and future seasons</td></tr><tr><td>`none`</td><td>No episodes</td></tr></table> | `all` | &#10060; |
| `quality_profile` | Default Quality Profile to use when adding new shows.<br>Use the `sonarr_quality` [Sonarr Details](../metadata/details/arr.md#sonarr-details) in the collection definition to set the Quality Profile per collection. | N/A | &#9989; |
@ -82,6 +83,7 @@ sonarr:
token: SOME_TOKEN
add_missing: false
add_existing: false
upgrade_existing: false
root_folder_path: /shows
monitor: all
quality_profile: HD-1080p

View file

@ -5,9 +5,10 @@
All the following attributes can override the global/library [Radarr](../../config/radarr) attributes which are the default unless otherwise specified.
| Attribute | Description & Values |
|:-------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|:--------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `radarr_add_missing` | **Description:** Override Radarr `add_missing` attribute<hr>**Values:** `true` or `false` |
| `radarr_add_existing` | **Description:** Override Radarr `add_existing` attribute<hr>**Values:** `true` or `false` |
| `radarr_upgrade_existing` | **Description:** Override Radarr `upgrade_existing` attribute<hr>**Values:** `true` or `false` |
| `radarr_folder` | **Description:** Override Radarr `root_folder_path` attribute<hr>**Values:** Folder Path |
| `radarr_monitor` | **Description:** Override Radarr `monitor` attribute<hr>**Values:** `true` or `false` |
| `radarr_availability` | **Description:** Override Radarr `availability` attribute<hr>**Values:** `announced`, `cinemas`, `released`, `db` |
@ -23,9 +24,10 @@ All the following attributes can override the global/library [Radarr](../../conf
All the following attributes can override the global/library [Sonarr](../../config/sonarr) attributes which are the default unless otherwise specified.
| Attribute | Description & Values |
|:-------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|:--------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sonarr_add_missing` | **Description:** Override Sonarr `add_missing` attribute<hr>**Values:** `true` or `false` |
| `sonarr_add_existing` | **Description:** Override Sonarr `add_existing` attribute<hr>**Values:** `true` or `false` |
| `sonarr_upgrade_existing` | **Description:** Override Sonarr `upgrade_existing` attribute<hr>**Values:** `true` or `false` |
| `sonarr_folder` | **Description:** Override Sonarr `root_folder_path` attribute<hr>**Values:** Folder Path |
| `sonarr_monitor` | **Description:** Override Sonarr `monitor` attribute<hr>**Values:** `all`, `future`, `missing`, `existing`, `pilot`, `first`, `latest`, `none` |
| `sonarr_quality` | **Description:** Override Sonarr `quality_profile` attribute<hr>**Values:** Sonarr Quality Profile |

View file

@ -51,10 +51,13 @@ item_false_details = ["item_lock_background", "item_lock_poster", "item_lock_tit
item_bool_details = ["item_tmdb_season_titles", "revert_overlay", "item_refresh"] + item_false_details
item_details = ["non_item_remove_label", "item_label", "item_radarr_tag", "item_sonarr_tag", "item_overlay", "item_refresh_delay"] + item_bool_details + list(plex.item_advance_keys.keys())
none_details = ["label.sync", "item_label.sync"]
radarr_details = ["radarr_add_missing", "radarr_add_existing", "radarr_folder", "radarr_monitor", "radarr_search", "radarr_availability", "radarr_quality", "radarr_tag"]
radarr_details = [
"radarr_add_missing", "radarr_add_existing", "radarr_upgrade_existing", "radarr_folder", "radarr_monitor",
"radarr_search", "radarr_availability", "radarr_quality", "radarr_tag", "item_radarr_tag"
]
sonarr_details = [
"sonarr_add_missing", "sonarr_add_existing", "sonarr_folder", "sonarr_monitor", "sonarr_language", "sonarr_series",
"sonarr_quality", "sonarr_season", "sonarr_search", "sonarr_cutoff_search", "sonarr_tag"
"sonarr_add_missing", "sonarr_add_existing", "sonarr_upgrade_existing", "sonarr_folder", "sonarr_monitor", "sonarr_language",
"sonarr_series", "sonarr_quality", "sonarr_season", "sonarr_search", "sonarr_cutoff_search", "sonarr_tag", "item_sonarr_tag"
]
album_details = ["non_item_remove_label", "item_label", "item_album_sorting"]
discover_types = {
@ -1002,7 +1005,7 @@ class CollectionBuilder:
self.item_details[method_name] = str(method_data).lower()
def _radarr(self, method_name, method_data):
if method_name in ["radarr_add_missing", "radarr_add_existing", "radarr_monitor", "radarr_search"]:
if method_name in ["radarr_add_missing", "radarr_add_existing", "radarr_upgrade_existing", "radarr_monitor", "radarr_search"]:
self.radarr_details[method_name[7:]] = util.parse(self.Type, method_name, method_data, datatype="bool")
elif method_name == "radarr_folder":
self.radarr_details["folder"] = method_data
@ -1017,7 +1020,7 @@ class CollectionBuilder:
self.radarr_details["tag"] = util.get_list(method_data, lower=True)
def _sonarr(self, method_name, method_data):
if method_name in ["sonarr_add_missing", "sonarr_add_existing", "sonarr_season", "sonarr_search", "sonarr_cutoff_search"]:
if method_name in ["sonarr_add_missing", "sonarr_add_existing", "sonarr_upgrade_existing", "sonarr_season", "sonarr_search", "sonarr_cutoff_search"]:
self.sonarr_details[method_name[7:]] = util.parse(self.Type, method_name, method_data, datatype="bool")
elif method_name in ["sonarr_folder", "sonarr_quality", "sonarr_language"]:
self.sonarr_details[method_name[7:]] = method_data

View file

@ -528,6 +528,7 @@ class ConfigFile:
"token": check_for_attribute(self.data, "token", parent="radarr", default_is_none=True),
"add_missing": check_for_attribute(self.data, "add_missing", parent="radarr", var_type="bool", default=False),
"add_existing": check_for_attribute(self.data, "add_existing", parent="radarr", var_type="bool", default=False),
"upgrade_existing": check_for_attribute(self.data, "upgrade_existing", parent="radarr", var_type="bool", default=False),
"root_folder_path": check_for_attribute(self.data, "root_folder_path", parent="radarr", default_is_none=True),
"monitor": check_for_attribute(self.data, "monitor", parent="radarr", var_type="bool", default=True),
"availability": check_for_attribute(self.data, "availability", parent="radarr", test_list=radarr.availability_descriptions, default="announced"),
@ -542,6 +543,7 @@ class ConfigFile:
"token": check_for_attribute(self.data, "token", parent="sonarr", default_is_none=True),
"add_missing": check_for_attribute(self.data, "add_missing", parent="sonarr", var_type="bool", default=False),
"add_existing": check_for_attribute(self.data, "add_existing", parent="sonarr", var_type="bool", default=False),
"upgrade_existing": check_for_attribute(self.data, "upgrade_existing", parent="sonarr", var_type="bool", default=False),
"root_folder_path": check_for_attribute(self.data, "root_folder_path", parent="sonarr", default_is_none=True),
"monitor": check_for_attribute(self.data, "monitor", parent="sonarr", test_list=sonarr.monitor_descriptions, default="all"),
"quality_profile": check_for_attribute(self.data, "quality_profile", parent="sonarr", default_is_none=True),
@ -817,6 +819,7 @@ class ConfigFile:
"token": check_for_attribute(lib, "token", parent="radarr", default=self.general["radarr"]["token"], req_default=True, save=False),
"add_missing": check_for_attribute(lib, "add_missing", parent="radarr", var_type="bool", default=self.general["radarr"]["add_missing"], save=False),
"add_existing": check_for_attribute(lib, "add_existing", parent="radarr", var_type="bool", default=self.general["radarr"]["add_existing"], save=False),
"upgrade_existing": check_for_attribute(lib, "upgrade_existing", parent="radarr", var_type="bool", default=self.general["radarr"]["upgrade_existing"], save=False),
"root_folder_path": check_for_attribute(lib, "root_folder_path", parent="radarr", default=self.general["radarr"]["root_folder_path"], req_default=True, save=False),
"monitor": check_for_attribute(lib, "monitor", parent="radarr", var_type="bool", default=self.general["radarr"]["monitor"], save=False),
"availability": check_for_attribute(lib, "availability", parent="radarr", test_list=radarr.availability_descriptions, default=self.general["radarr"]["availability"], save=False),
@ -844,6 +847,7 @@ class ConfigFile:
"token": check_for_attribute(lib, "token", parent="sonarr", default=self.general["sonarr"]["token"], req_default=True, save=False),
"add_missing": check_for_attribute(lib, "add_missing", parent="sonarr", var_type="bool", default=self.general["sonarr"]["add_missing"], save=False),
"add_existing": check_for_attribute(lib, "add_existing", parent="sonarr", var_type="bool", default=self.general["sonarr"]["add_existing"], save=False),
"upgrade_existing": check_for_attribute(lib, "upgrade_existing", parent="sonarr", var_type="bool", default=self.general["sonarr"]["upgrade_existing"], save=False),
"root_folder_path": check_for_attribute(lib, "root_folder_path", parent="sonarr", default=self.general["sonarr"]["root_folder_path"], req_default=True, save=False),
"monitor": check_for_attribute(lib, "monitor", parent="sonarr", test_list=sonarr.monitor_descriptions, default=self.general["sonarr"]["monitor"], save=False),
"quality_profile": check_for_attribute(lib, "quality_profile", parent="sonarr", default=self.general["sonarr"]["quality_profile"], req_default=True, save=False),

View file

@ -21,10 +21,12 @@ class Radarr:
self.api = RadarrAPI(self.url, self.token, session=self.config.session)
self.api.respect_list_exclusions_when_adding()
self.api._validate_add_options(params["root_folder_path"], params["quality_profile"])
self.profiles = self.api.quality_profile()
except ArrException as e:
raise Failed(e)
self.add_missing = params["add_missing"]
self.add_existing = params["add_existing"]
self.upgrade_existing = params["upgrade_existing"]
self.root_folder_path = params["root_folder_path"]
self.monitor = params["monitor"]
self.availability = params["availability"]
@ -48,6 +50,7 @@ class Radarr:
logger.debug(f"Radarr Adds: {_ids if _ids else ''}")
for tmdb_id in _paths:
logger.debug(tmdb_id)
upgrade_existing = options["upgrade_existing"] if "upgrade_existing" in options else self.upgrade_existing
folder = options["folder"] if "folder" in options else self.root_folder_path
monitor = options["monitor"] if "monitor" in options else self.monitor
availability = availability_translation[options["availability"] if "availability" in options else self.availability]
@ -125,6 +128,11 @@ class Radarr:
mass_add()
movies = []
qp = None
for profile in self.profiles:
if (isinstance(quality_profile, int) and profile.id == quality_profile) or profile.name == quality_profile:
qp = profile
if len(added) > 0:
logger.info("")
for movie in added:
@ -136,10 +144,15 @@ class Radarr:
if len(exists) > 0 or len(skipped) > 0:
logger.info("")
if len(exists) > 0:
upgrade_qp = []
for movie in exists:
logger.info(f"Already in Radarr | {movie.tmdbId:<7} | {movie.title}")
if movie.qualityProfileId != qp.id:
upgrade_qp.append(movie)
if self.config.Cache:
self.config.Cache.update_radarr_adds(movie.tmdbId, self.library.original_mapping_name)
if upgrade_qp and upgrade_existing:
self.api.edit_multiple_movies(upgrade_qp, quality_profile=qp)
if len(skipped) > 0:
for movie in skipped:
logger.info(f"Skipped: In Cache | {movie}")

View file

@ -39,10 +39,12 @@ class Sonarr:
self.api = SonarrAPI(self.url, self.token, session=self.config.session)
self.api.respect_list_exclusions_when_adding()
self.api._validate_add_options(params["root_folder_path"], params["quality_profile"], params["language_profile"])
self.profiles = self.api.quality_profile()
except ArrException as e:
raise Failed(e)
self.add_missing = params["add_missing"]
self.add_existing = params["add_existing"]
self.upgrade_existing = params["upgrade_existing"]
self.root_folder_path = params["root_folder_path"]
self.monitor = params["monitor"]
self.quality_profile = params["quality_profile"]
@ -70,6 +72,7 @@ class Sonarr:
logger.debug(f"Sonarr Adds: {_ids if _ids else ''}")
for tvdb_id in _paths:
logger.debug(tvdb_id)
upgrade_existing = options["upgrade_existing"] if "upgrade_existing" in options else self.upgrade_existing
folder = options["folder"] if "folder" in options else self.root_folder_path
monitor = monitor_translation[options["monitor"] if "monitor" in options else self.monitor]
quality_profile = options["quality"] if "quality" in options else self.quality_profile
@ -151,6 +154,11 @@ class Sonarr:
mass_add()
shows = []
qp = None
for profile in self.profiles:
if (isinstance(quality_profile, int) and profile.id == quality_profile) or profile.name == quality_profile:
qp = profile
if len(added) > 0:
logger.info("")
for series in added:
@ -162,10 +170,15 @@ class Sonarr:
if len(exists) > 0 or len(skipped) > 0:
logger.info("")
if len(exists) > 0:
upgrade_qp = []
for series in exists:
logger.info(f"Already in Sonarr | {series.tvdbId:<7} | {series.title}")
if series.qualityProfileId != qp.id:
upgrade_qp.append(series)
if self.config.Cache:
self.config.Cache.update_sonarr_adds(series.tvdbId, self.library.original_mapping_name)
if upgrade_qp and upgrade_existing:
self.api.edit_multiple_series(upgrade_qp, quality_profile=qp)
if len(skipped) > 0:
for series in skipped:
logger.info(f"Skipped: In Cache | {series}")