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