mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
#235 Add all items to Radarr/Sonarr
This commit is contained in:
parent
e4ec252903
commit
fc4930a00d
3 changed files with 39 additions and 6 deletions
|
@ -390,6 +390,16 @@ class Config:
|
|||
else:
|
||||
params["mass_critic_rating_update"] = None
|
||||
|
||||
if lib and "radarr_add_all" in lib and lib["radarr_add_all"]:
|
||||
params["radarr_add_all"] = check_for_attribute(lib, "radarr_add_all", var_type="bool", default=False, save=False)
|
||||
else:
|
||||
params["radarr_add_all"] = None
|
||||
|
||||
if lib and "sonarr_add_all" in lib and lib["sonarr_add_all"]:
|
||||
params["sonarr_add_all"] = check_for_attribute(lib, "sonarr_add_all", var_type="bool", default=False, save=False)
|
||||
else:
|
||||
params["sonarr_add_all"] = None
|
||||
|
||||
try:
|
||||
if lib and "metadata_path" in lib:
|
||||
params["metadata_path"] = []
|
||||
|
|
|
@ -338,7 +338,9 @@ class PlexAPI:
|
|||
self.mass_genre_update = params["mass_genre_update"]
|
||||
self.mass_audience_rating_update = params["mass_audience_rating_update"]
|
||||
self.mass_critic_rating_update = params["mass_critic_rating_update"]
|
||||
self.mass_update = self.mass_genre_update or self.mass_audience_rating_update or self.mass_critic_rating_update
|
||||
self.radarr_add_all = params["radarr_add_all"]
|
||||
self.sonarr_add_all = params["sonarr_add_all"]
|
||||
self.mass_update = self.mass_genre_update or self.mass_audience_rating_update or self.mass_critic_rating_update or self.radarr_add_all or self.sonarr_add_all
|
||||
self.plex = params["plex"]
|
||||
self.url = params["plex"]["url"]
|
||||
self.token = params["plex"]["token"]
|
||||
|
|
|
@ -259,6 +259,8 @@ def mass_metadata(config, library, movie_map, show_map):
|
|||
logger.info("")
|
||||
util.separator(f"Mass Editing {'Movie' if library.is_movie else 'Show'} Library: {library.name}")
|
||||
logger.info("")
|
||||
radarr_adds = []
|
||||
sonarr_adds = []
|
||||
items = library.Plex.all()
|
||||
for i, item in enumerate(items, 1):
|
||||
length = util.print_return(length, f"Processing: {i}/{len(items)} {item.title}")
|
||||
|
@ -282,14 +284,16 @@ def mass_metadata(config, library, movie_map, show_map):
|
|||
if item.ratingKey in rating_keys:
|
||||
tvdb_id = tvdb
|
||||
break
|
||||
if tmdb_id:
|
||||
imdb_id = config.Convert.tmdb_to_imdb(tmdb_id)
|
||||
elif tvdb_id:
|
||||
tmdb_id = config.Convert.tvdb_to_tmdb(tvdb_id)
|
||||
imdb_id = config.Convert.tvdb_to_imdb(tvdb_id)
|
||||
|
||||
if library.Radarr and library.radarr_add_all and tmdb_id:
|
||||
radarr_adds.append(tmdb_id)
|
||||
if library.Sonarr and library.sonarr_add_all and tvdb_id:
|
||||
sonarr_adds.append(tvdb_id)
|
||||
|
||||
tmdb_item = None
|
||||
if library.mass_genre_update == "tmdb" or library.mass_audience_rating_update == "tmdb" or library.mass_critic_rating_update == "tmdb":
|
||||
if tvdb_id and not tmdb_id:
|
||||
tmdb_id = config.Convert.tvdb_to_tmdb(tvdb_id)
|
||||
if tmdb_id:
|
||||
try:
|
||||
tmdb_item = config.TMDb.get_movie(tmdb_id) if library.is_movie else config.TMDb.get_show(tmdb_id)
|
||||
|
@ -301,6 +305,10 @@ def mass_metadata(config, library, movie_map, show_map):
|
|||
omdb_item = None
|
||||
if library.mass_genre_update in ["omdb", "imdb"] or library.mass_audience_rating_update in ["omdb", "imdb"] or library.mass_critic_rating_update in ["omdb", "imdb"]:
|
||||
if config.OMDb.limit is False:
|
||||
if tmdb_id and not imdb_id:
|
||||
imdb_id = config.Convert.tmdb_to_imdb(tmdb_id)
|
||||
elif tvdb_id and not imdb_id:
|
||||
imdb_id = config.Convert.tvdb_to_imdb(tvdb_id)
|
||||
if imdb_id:
|
||||
try:
|
||||
omdb_item = config.OMDb.get_omdb(imdb_id)
|
||||
|
@ -352,6 +360,19 @@ def mass_metadata(config, library, movie_map, show_map):
|
|||
except Failed:
|
||||
pass
|
||||
|
||||
if library.Radarr and library.radarr_add_all:
|
||||
try:
|
||||
library.Radarr.add_tmdb(radarr_adds)
|
||||
except Failed as e:
|
||||
logger.error(e)
|
||||
|
||||
if library.Sonarr and library.sonarr_add_all:
|
||||
try:
|
||||
library.Sonarr.add_tvdb(sonarr_adds)
|
||||
except Failed as e:
|
||||
logger.error(e)
|
||||
|
||||
|
||||
def run_collection(config, library, metadata, requested_collections, is_test, resume_from, movie_map, show_map):
|
||||
logger.info("")
|
||||
for mapping_name, collection_attrs in requested_collections.items():
|
||||
|
|
Loading…
Reference in a new issue