|
|
|
@ -1348,7 +1348,7 @@ class CollectionBuilder:
|
|
|
|
|
logger.debug("")
|
|
|
|
|
logger.debug(f"Builder: {method}: {value}")
|
|
|
|
|
logger.info("")
|
|
|
|
|
rating_keys = []
|
|
|
|
|
items = []
|
|
|
|
|
ids = self.gather_ids(method, value)
|
|
|
|
|
if len(ids) > 0:
|
|
|
|
|
total_ids = len(ids)
|
|
|
|
@ -1357,12 +1357,37 @@ class CollectionBuilder:
|
|
|
|
|
for i, input_data in enumerate(ids, 1):
|
|
|
|
|
input_id, id_type = input_data
|
|
|
|
|
util.print_return(f"Parsing ID {i}/{total_ids}")
|
|
|
|
|
if id_type == "tvdb_season" and self.collection_level == "season":
|
|
|
|
|
show_id, season_num = input_id.split("_")
|
|
|
|
|
show_id = int(show_id)
|
|
|
|
|
if show_id in self.library.show_map:
|
|
|
|
|
show_item = self.library.fetchItem(self.library.show_map[show_id][0])
|
|
|
|
|
try:
|
|
|
|
|
items.append(show_item.season(season=int(season_num)))
|
|
|
|
|
except NotFound:
|
|
|
|
|
self.missing_parts.append(f"{show_item.title} Season: {season_num} Missing")
|
|
|
|
|
elif show_id not in self.missing_shows:
|
|
|
|
|
self.missing_shows.append(show_id)
|
|
|
|
|
elif id_type == "tvdb_episode" and self.collection_level == "episode":
|
|
|
|
|
show_id, season_num, episode_num = input_id.split("_")
|
|
|
|
|
show_id = int(show_id)
|
|
|
|
|
if show_id in self.library.show_map:
|
|
|
|
|
show_item = self.library.fetchItem(self.library.show_map[show_id][0])
|
|
|
|
|
try:
|
|
|
|
|
items.append(show_item.episode(season=int(season_num), episode=int(episode_num)))
|
|
|
|
|
except NotFound:
|
|
|
|
|
self.missing_parts.append(
|
|
|
|
|
f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
|
|
|
|
|
elif show_id not in self.missing_shows:
|
|
|
|
|
self.missing_shows.append(show_id)
|
|
|
|
|
else:
|
|
|
|
|
rating_keys = []
|
|
|
|
|
if id_type == "ratingKey":
|
|
|
|
|
rating_keys.append(input_id)
|
|
|
|
|
rating_keys = input_id
|
|
|
|
|
elif id_type == "tmdb" and not self.parts_collection:
|
|
|
|
|
if input_id not in self.ignore_ids:
|
|
|
|
|
if input_id in self.library.movie_map:
|
|
|
|
|
rating_keys.extend(self.library.movie_map[input_id])
|
|
|
|
|
rating_keys = self.library.movie_map[input_id]
|
|
|
|
|
elif input_id not in self.missing_movies:
|
|
|
|
|
self.missing_movies.append(input_id)
|
|
|
|
|
elif id_type in ["tvdb", "tmdb_show"] and not self.parts_collection:
|
|
|
|
@ -1374,13 +1399,13 @@ class CollectionBuilder:
|
|
|
|
|
continue
|
|
|
|
|
if input_id not in self.ignore_ids:
|
|
|
|
|
if input_id in self.library.show_map:
|
|
|
|
|
rating_keys.extend(self.library.show_map[input_id])
|
|
|
|
|
rating_keys = self.library.show_map[input_id]
|
|
|
|
|
elif input_id not in self.missing_shows:
|
|
|
|
|
self.missing_shows.append(input_id)
|
|
|
|
|
elif id_type == "imdb" and not self.parts_collection:
|
|
|
|
|
if input_id not in self.ignore_imdb_ids:
|
|
|
|
|
if input_id in self.library.imdb_map:
|
|
|
|
|
rating_keys.extend(self.library.imdb_map[input_id])
|
|
|
|
|
rating_keys = self.library.imdb_map[input_id]
|
|
|
|
|
elif self.do_missing:
|
|
|
|
|
try:
|
|
|
|
|
tmdb_id, tmdb_type = self.config.Convert.imdb_to_tmdb(input_id, fail=True)
|
|
|
|
@ -1394,59 +1419,41 @@ class CollectionBuilder:
|
|
|
|
|
except Failed as e:
|
|
|
|
|
logger.error(e)
|
|
|
|
|
continue
|
|
|
|
|
elif id_type == "tvdb_season" and self.collection_level == "season":
|
|
|
|
|
show_id, season_num = input_id.split("_")
|
|
|
|
|
show_id = int(show_id)
|
|
|
|
|
if show_id in self.library.show_map:
|
|
|
|
|
show_item = self.library.fetchItem(self.library.show_map[show_id][0])
|
|
|
|
|
try:
|
|
|
|
|
season_item = show_item.season(season=int(season_num))
|
|
|
|
|
rating_keys.append(season_item.ratingKey)
|
|
|
|
|
except NotFound:
|
|
|
|
|
self.missing_parts.append(f"{show_item.title} Season: {season_num} Missing")
|
|
|
|
|
elif show_id not in self.missing_shows:
|
|
|
|
|
self.missing_shows.append(show_id)
|
|
|
|
|
elif id_type == "tvdb_episode" and self.collection_level == "episode":
|
|
|
|
|
show_id, season_num, episode_num = input_id.split("_")
|
|
|
|
|
show_id = int(show_id)
|
|
|
|
|
if show_id in self.library.show_map:
|
|
|
|
|
show_item = self.library.fetchItem(self.library.show_map[show_id][0])
|
|
|
|
|
if not isinstance(rating_keys, list):
|
|
|
|
|
rating_keys = [rating_keys]
|
|
|
|
|
for rk in rating_keys:
|
|
|
|
|
try:
|
|
|
|
|
episode_item = show_item.episode(season=int(season_num), episode=int(episode_num))
|
|
|
|
|
rating_keys.append(episode_item.ratingKey)
|
|
|
|
|
except NotFound:
|
|
|
|
|
self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
|
|
|
|
|
elif show_id not in self.missing_shows:
|
|
|
|
|
self.missing_shows.append(show_id)
|
|
|
|
|
items.append(self.fetch_item(rk))
|
|
|
|
|
except Failed as e:
|
|
|
|
|
logger.error(e)
|
|
|
|
|
util.print_end()
|
|
|
|
|
|
|
|
|
|
if len(rating_keys) > 0:
|
|
|
|
|
if len(items) > 0:
|
|
|
|
|
self.filter_and_save_items(items)
|
|
|
|
|
|
|
|
|
|
def filter_and_save_items(self, items):
|
|
|
|
|
name = self.obj.title if self.obj else self.name
|
|
|
|
|
if not isinstance(rating_keys, list):
|
|
|
|
|
rating_keys = [rating_keys]
|
|
|
|
|
total = len(rating_keys)
|
|
|
|
|
total = len(items)
|
|
|
|
|
max_length = len(str(total))
|
|
|
|
|
if (self.filters or self.tmdb_filters) and self.details["show_filtered"] is True:
|
|
|
|
|
logger.info("")
|
|
|
|
|
logger.info("Filtering Builder:")
|
|
|
|
|
for i, key in enumerate(rating_keys, 1):
|
|
|
|
|
if key not in self.rating_keys:
|
|
|
|
|
if key in self.filtered_keys:
|
|
|
|
|
logger.info("Filtering Builders:")
|
|
|
|
|
for i, item in enumerate(items, 1):
|
|
|
|
|
if not isinstance(item, (Movie, Show, Season, Episode)):
|
|
|
|
|
logger.error(f"{self.Type} Error: Item: {item} must be Movie, Show, Season, or Episode")
|
|
|
|
|
continue
|
|
|
|
|
if item.ratingKey not in self.rating_keys:
|
|
|
|
|
if item.ratingKey in self.filtered_keys:
|
|
|
|
|
if self.details["show_filtered"] is True:
|
|
|
|
|
logger.info(f"{name} Collection | X | {self.filtered_keys[key]}")
|
|
|
|
|
logger.info(f"{name} {self.Type} | X | {self.filtered_keys[item.ratingKey]}")
|
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
current = self.fetch_item(key)
|
|
|
|
|
except Failed as e:
|
|
|
|
|
logger.error(e)
|
|
|
|
|
continue
|
|
|
|
|
current_title = self.item_title(current)
|
|
|
|
|
if self.check_filters(current, f"{(' ' * (max_length - len(str(i))))}{i}/{total}"):
|
|
|
|
|
self.rating_keys.append(key)
|
|
|
|
|
current_title = self.item_title(item)
|
|
|
|
|
if self.check_filters(item, f"{(' ' * (max_length - len(str(i))))}{i}/{total}"):
|
|
|
|
|
self.rating_keys.append(item.ratingKey)
|
|
|
|
|
else:
|
|
|
|
|
self.filtered_keys[key] = current_title
|
|
|
|
|
self.filtered_keys[item.ratingKey] = current_title
|
|
|
|
|
if self.details["show_filtered"] is True:
|
|
|
|
|
logger.info(f"{name} Collection | X | {current_title}")
|
|
|
|
|
logger.info(f"{name} {self.Type} | X | {current_title}")
|
|
|
|
|
|
|
|
|
|
def build_filter(self, method, plex_filter, smart=False, type_override=None):
|
|
|
|
|
if smart:
|
|
|
|
|