|
|
|
@ -53,11 +53,20 @@ class Radarr:
|
|
|
|
|
tags = options["tag"] if "tag" in options else self.tag
|
|
|
|
|
search = options["search"] if "search" in options else self.search
|
|
|
|
|
|
|
|
|
|
arr_paths = {}
|
|
|
|
|
arr_ids = {}
|
|
|
|
|
for movie in self.api.all_movies():
|
|
|
|
|
if movie.path:
|
|
|
|
|
arr_paths[movie.path] = movie.tmdbId
|
|
|
|
|
arr_ids[movie.tmdbId] = movie
|
|
|
|
|
|
|
|
|
|
added = []
|
|
|
|
|
exists = []
|
|
|
|
|
skipped = []
|
|
|
|
|
invalid = []
|
|
|
|
|
movies = []
|
|
|
|
|
path_lookup = {}
|
|
|
|
|
mismatched = {}
|
|
|
|
|
for i, item in enumerate(tmdb_ids, 1):
|
|
|
|
|
path = item[1] if isinstance(item, tuple) else None
|
|
|
|
|
tmdb_id = item[0] if isinstance(item, tuple) else item
|
|
|
|
@ -68,8 +77,18 @@ class Radarr:
|
|
|
|
|
skipped.append(item)
|
|
|
|
|
continue
|
|
|
|
|
try:
|
|
|
|
|
if tmdb_id in arr_ids:
|
|
|
|
|
exists.append(arr_ids[tmdb_id])
|
|
|
|
|
continue
|
|
|
|
|
if path in arr_paths:
|
|
|
|
|
mismatched[path] = tmdb_id
|
|
|
|
|
continue
|
|
|
|
|
movie = self.api.get_movie(tmdb_id=tmdb_id)
|
|
|
|
|
movies.append((movie, path) if path else movie)
|
|
|
|
|
if path:
|
|
|
|
|
movies.append((movie, path))
|
|
|
|
|
path_lookup[path] = tmdb_id
|
|
|
|
|
else:
|
|
|
|
|
movies.append(movie)
|
|
|
|
|
except ArrException:
|
|
|
|
|
invalid.append(item)
|
|
|
|
|
if len(movies) == 100 or len(tmdb_ids) == i:
|
|
|
|
@ -91,26 +110,29 @@ class Radarr:
|
|
|
|
|
self.config.Cache.update_radarr_adds(movie.tmdbId, self.library.original_mapping_name)
|
|
|
|
|
logger.info(f"{len(added)} Movie{'s' if len(added) > 1 else ''} added to Radarr")
|
|
|
|
|
|
|
|
|
|
if len(exists) > 0:
|
|
|
|
|
if len(exists) > 0 or len(skipped) > 0:
|
|
|
|
|
logger.info("")
|
|
|
|
|
for movie in exists:
|
|
|
|
|
logger.info(f"Already in Radarr | {movie.tmdbId:<6} | {movie.title}")
|
|
|
|
|
if self.config.Cache:
|
|
|
|
|
self.config.Cache.update_radarr_adds(movie.tmdbId, self.library.original_mapping_name)
|
|
|
|
|
logger.info(f"{len(exists)} Movie{'s' if len(exists) > 1 else ''} already existing in Radarr")
|
|
|
|
|
if len(exists) > 0:
|
|
|
|
|
for movie in exists:
|
|
|
|
|
logger.info(f"Already in Radarr | {movie.tmdbId:<6} | {movie.title}")
|
|
|
|
|
if self.config.Cache:
|
|
|
|
|
self.config.Cache.update_radarr_adds(movie.tmdbId, self.library.original_mapping_name)
|
|
|
|
|
if len(skipped) > 0:
|
|
|
|
|
for movie in skipped:
|
|
|
|
|
logger.info(f"Skipped: In Cache | {movie}")
|
|
|
|
|
logger.info(f"{len(exists) + len(skipped)} Movie{'s' if len(skipped) > 1 else ''} already exist in Radarr")
|
|
|
|
|
|
|
|
|
|
if len(skipped) > 0:
|
|
|
|
|
if len(mismatched) > 0:
|
|
|
|
|
logger.info("")
|
|
|
|
|
for movie in skipped:
|
|
|
|
|
logger.info(f"Skipped: In Cache | {movie}")
|
|
|
|
|
if self.config.Cache:
|
|
|
|
|
self.config.Cache.update_radarr_adds(movie[0] if isinstance(movie, tuple) else movie, self.library.original_mapping_name)
|
|
|
|
|
logger.info(f"{len(skipped)} Movie{'s' if len(skipped) > 1 else ''} already existing in Radarr")
|
|
|
|
|
for path, tmdb_id in mismatched.items():
|
|
|
|
|
logger.info(f"Plex TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path]:<7} | Path: {path}")
|
|
|
|
|
logger.info(f"{len(mismatched)} Movie{'s' if len(mismatched) > 1 else ''} with mismatched TMDb IDs")
|
|
|
|
|
|
|
|
|
|
if len(invalid) > 0:
|
|
|
|
|
logger.info("")
|
|
|
|
|
for tmdb_id in invalid:
|
|
|
|
|
logger.info(f"Invalid TMDb ID | {tmdb_id}")
|
|
|
|
|
logger.info(f"{len(invalid)} Movie{'s' if len(invalid) > 1 else ''} with Invalid IDs")
|
|
|
|
|
|
|
|
|
|
return len(added)
|
|
|
|
|
|
|
|
|
|