|
|
@ -194,9 +194,9 @@ class CollectionBuilder:
|
|
|
|
self.name = name
|
|
|
|
self.name = name
|
|
|
|
self.data = data
|
|
|
|
self.data = data
|
|
|
|
self.details = {
|
|
|
|
self.details = {
|
|
|
|
"show_filtered": library.show_filtered,
|
|
|
|
"show_filtered": self.library.show_filtered,
|
|
|
|
"show_missing": library.show_missing,
|
|
|
|
"show_missing": self.library.show_missing,
|
|
|
|
"save_missing": library.save_missing
|
|
|
|
"save_missing": self.library.save_missing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.item_details = {}
|
|
|
|
self.item_details = {}
|
|
|
|
self.radarr_options = {}
|
|
|
|
self.radarr_options = {}
|
|
|
@ -480,7 +480,7 @@ class CollectionBuilder:
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
logger.debug(f"Value: {self.data[methods['smart_url']]}")
|
|
|
|
logger.debug(f"Value: {self.data[methods['smart_url']]}")
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
self.smart_url, self.smart_type_key = library.get_smart_filter_from_uri(self.data[methods["smart_url"]])
|
|
|
|
self.smart_url, self.smart_type_key = self.library.get_smart_filter_from_uri(self.data[methods["smart_url"]])
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
raise Failed("Collection Error: smart_url is incorrectly formatted")
|
|
|
|
raise Failed("Collection Error: smart_url is incorrectly formatted")
|
|
|
|
|
|
|
|
|
|
|
@ -1302,19 +1302,19 @@ class CollectionBuilder:
|
|
|
|
|
|
|
|
|
|
|
|
if self.build_collection:
|
|
|
|
if self.build_collection:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
self.obj = library.get_collection(self.name)
|
|
|
|
self.obj = self.library.get_collection(self.name)
|
|
|
|
collection_smart = library.smart(self.obj)
|
|
|
|
collection_smart = self.library.smart(self.obj)
|
|
|
|
if (self.smart and not collection_smart) or (not self.smart and collection_smart):
|
|
|
|
if (self.smart and not collection_smart) or (not self.smart and collection_smart):
|
|
|
|
logger.info("")
|
|
|
|
logger.info("")
|
|
|
|
logger.error(f"Collection Error: Converting {self.obj.title} to a {'smart' if self.smart else 'normal'} collection")
|
|
|
|
logger.error(f"Collection Error: Converting {self.obj.title} to a {'smart' if self.smart else 'normal'} collection")
|
|
|
|
library.query(self.obj.delete)
|
|
|
|
self.library.query(self.obj.delete)
|
|
|
|
self.obj = None
|
|
|
|
self.obj = None
|
|
|
|
except Failed:
|
|
|
|
except Failed:
|
|
|
|
self.obj = None
|
|
|
|
self.obj = None
|
|
|
|
|
|
|
|
|
|
|
|
self.plex_map = {}
|
|
|
|
self.plex_map = {}
|
|
|
|
if self.sync and self.obj:
|
|
|
|
if self.sync and self.obj:
|
|
|
|
for item in library.get_collection_items(self.obj, self.smart_label_collection):
|
|
|
|
for item in self.library.get_collection_items(self.obj, self.smart_label_collection):
|
|
|
|
self.plex_map[item.ratingKey] = item
|
|
|
|
self.plex_map[item.ratingKey] = item
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.sync = False
|
|
|
|
self.sync = False
|
|
|
@ -1322,7 +1322,7 @@ class CollectionBuilder:
|
|
|
|
logger.info("")
|
|
|
|
logger.info("")
|
|
|
|
logger.info("Validation Successful")
|
|
|
|
logger.info("Validation Successful")
|
|
|
|
|
|
|
|
|
|
|
|
def collect_rating_keys(self, movie_map, show_map):
|
|
|
|
def collect_rating_keys(self):
|
|
|
|
def add_rating_keys(keys):
|
|
|
|
def add_rating_keys(keys):
|
|
|
|
if not isinstance(keys, list):
|
|
|
|
if not isinstance(keys, list):
|
|
|
|
keys = [keys]
|
|
|
|
keys = [keys]
|
|
|
@ -1338,15 +1338,15 @@ class CollectionBuilder:
|
|
|
|
if len(movie_ids) > 0:
|
|
|
|
if len(movie_ids) > 0:
|
|
|
|
items_found_inside += len(movie_ids)
|
|
|
|
items_found_inside += len(movie_ids)
|
|
|
|
for movie_id in movie_ids:
|
|
|
|
for movie_id in movie_ids:
|
|
|
|
if movie_id in movie_map:
|
|
|
|
if movie_id in self.library.movie_map:
|
|
|
|
add_rating_keys(movie_map[movie_id])
|
|
|
|
add_rating_keys(self.library.movie_map[movie_id])
|
|
|
|
elif movie_id not in self.missing_movies:
|
|
|
|
elif movie_id not in self.missing_movies:
|
|
|
|
self.missing_movies.append(movie_id)
|
|
|
|
self.missing_movies.append(movie_id)
|
|
|
|
if len(show_ids) > 0:
|
|
|
|
if len(show_ids) > 0:
|
|
|
|
items_found_inside += len(show_ids)
|
|
|
|
items_found_inside += len(show_ids)
|
|
|
|
for show_id in show_ids:
|
|
|
|
for show_id in show_ids:
|
|
|
|
if show_id in show_map:
|
|
|
|
if show_id in self.library.show_map:
|
|
|
|
add_rating_keys(show_map[show_id])
|
|
|
|
add_rating_keys(self.library.show_map[show_id])
|
|
|
|
elif show_id not in self.missing_shows:
|
|
|
|
elif show_id not in self.missing_shows:
|
|
|
|
self.missing_shows.append(show_id)
|
|
|
|
self.missing_shows.append(show_id)
|
|
|
|
return items_found_inside
|
|
|
|
return items_found_inside
|
|
|
@ -1365,7 +1365,7 @@ class CollectionBuilder:
|
|
|
|
elif "trakt" in method: check_map(self.config.Trakt.get_items(method, value, self.library.is_movie))
|
|
|
|
elif "trakt" in method: check_map(self.config.Trakt.get_items(method, value, self.library.is_movie))
|
|
|
|
else: logger.error(f"Collection Error: {method} method not supported")
|
|
|
|
else: logger.error(f"Collection Error: {method} method not supported")
|
|
|
|
|
|
|
|
|
|
|
|
def add_to_collection(self, movie_map):
|
|
|
|
def add_to_collection(self):
|
|
|
|
name, collection_items = self.library.get_collection_name_and_items(self.obj if self.obj else self.name, self.smart_label_collection)
|
|
|
|
name, collection_items = self.library.get_collection_name_and_items(self.obj if self.obj else self.name, self.smart_label_collection)
|
|
|
|
total = len(self.rating_keys)
|
|
|
|
total = len(self.rating_keys)
|
|
|
|
max_length = len(str(total))
|
|
|
|
max_length = len(str(total))
|
|
|
@ -1391,7 +1391,7 @@ class CollectionBuilder:
|
|
|
|
break
|
|
|
|
break
|
|
|
|
elif method_name == "original_language":
|
|
|
|
elif method_name == "original_language":
|
|
|
|
movie = None
|
|
|
|
movie = None
|
|
|
|
for key, value in movie_map.items():
|
|
|
|
for key, value in self.library.movie_map.items():
|
|
|
|
if current.ratingKey in value:
|
|
|
|
if current.ratingKey in value:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
movie = self.config.TMDb.get_movie(key)
|
|
|
|
movie = self.config.TMDb.get_movie(key)
|
|
|
@ -1435,7 +1435,7 @@ class CollectionBuilder:
|
|
|
|
elif modifier in [".gte", ".lte"]:
|
|
|
|
elif modifier in [".gte", ".lte"]:
|
|
|
|
if method_name == "vote_count":
|
|
|
|
if method_name == "vote_count":
|
|
|
|
tmdb_item = None
|
|
|
|
tmdb_item = None
|
|
|
|
for key, value in movie_map.items():
|
|
|
|
for key, value in self.library.movie_map.items():
|
|
|
|
if current.ratingKey in value:
|
|
|
|
if current.ratingKey in value:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
tmdb_item = self.config.TMDb.get_movie(key) if self.library.is_movie else self.config.TMDb.get_show(key)
|
|
|
|
tmdb_item = self.config.TMDb.get_movie(key) if self.library.is_movie else self.config.TMDb.get_show(key)
|
|
|
@ -1736,17 +1736,17 @@ class CollectionBuilder:
|
|
|
|
elif "tmdb_show_details" in self.backgrounds: set_image("tmdb_show_details", self.backgrounds, is_background=True)
|
|
|
|
elif "tmdb_show_details" in self.backgrounds: set_image("tmdb_show_details", self.backgrounds, is_background=True)
|
|
|
|
else: logger.info("No background to update")
|
|
|
|
else: logger.info("No background to update")
|
|
|
|
|
|
|
|
|
|
|
|
def run_collections_again(self, movie_map, show_map):
|
|
|
|
def run_collections_again(self):
|
|
|
|
self.obj = self.library.get_collection(self.name)
|
|
|
|
self.obj = self.library.get_collection(self.name)
|
|
|
|
name, collection_items = self.library.get_collection_name_and_items(self.obj, self.smart_label_collection)
|
|
|
|
name, collection_items = self.library.get_collection_name_and_items(self.obj, self.smart_label_collection)
|
|
|
|
rating_keys = []
|
|
|
|
rating_keys = []
|
|
|
|
for mm in self.run_again_movies:
|
|
|
|
for mm in self.run_again_movies:
|
|
|
|
if mm in movie_map:
|
|
|
|
if mm in self.library.movie_map:
|
|
|
|
rating_keys.extend(movie_map[mm])
|
|
|
|
rating_keys.extend(self.library.movie_map[mm])
|
|
|
|
if self.library.is_show:
|
|
|
|
if self.library.is_show:
|
|
|
|
for sm in self.run_again_shows:
|
|
|
|
for sm in self.run_again_shows:
|
|
|
|
if sm in show_map:
|
|
|
|
if sm in self.library.show_map:
|
|
|
|
rating_keys.extend(show_map[sm])
|
|
|
|
rating_keys.extend(self.library.show_map[sm])
|
|
|
|
if len(rating_keys) > 0:
|
|
|
|
if len(rating_keys) > 0:
|
|
|
|
for rating_key in rating_keys:
|
|
|
|
for rating_key in rating_keys:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -1766,7 +1766,7 @@ class CollectionBuilder:
|
|
|
|
if len(self.run_again_movies) > 0:
|
|
|
|
if len(self.run_again_movies) > 0:
|
|
|
|
logger.info("")
|
|
|
|
logger.info("")
|
|
|
|
for missing_id in self.run_again_movies:
|
|
|
|
for missing_id in self.run_again_movies:
|
|
|
|
if missing_id not in movie_map:
|
|
|
|
if missing_id not in self.library.movie_map:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
movie = self.config.TMDb.get_movie(missing_id)
|
|
|
|
movie = self.config.TMDb.get_movie(missing_id)
|
|
|
|
except Failed as e:
|
|
|
|
except Failed as e:
|
|
|
@ -1780,7 +1780,7 @@ class CollectionBuilder:
|
|
|
|
if len(self.run_again_shows) > 0 and self.library.is_show:
|
|
|
|
if len(self.run_again_shows) > 0 and self.library.is_show:
|
|
|
|
logger.info("")
|
|
|
|
logger.info("")
|
|
|
|
for missing_id in self.run_again_shows:
|
|
|
|
for missing_id in self.run_again_shows:
|
|
|
|
if missing_id not in show_map:
|
|
|
|
if missing_id not in self.library.show_map:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
title = str(self.config.TVDb.get_series(self.library.Plex.language, missing_id).title.encode("ascii", "replace").decode())
|
|
|
|
title = str(self.config.TVDb.get_series(self.library.Plex.language, missing_id).title.encode("ascii", "replace").decode())
|
|
|
|
except Failed as e:
|
|
|
|
except Failed as e:
|
|
|
|