|
|
@ -196,15 +196,65 @@ music_attributes = [
|
|
|
|
] + details + summary_details + poster_details + background_details
|
|
|
|
] + details + summary_details + poster_details + background_details
|
|
|
|
|
|
|
|
|
|
|
|
class CollectionBuilder:
|
|
|
|
class CollectionBuilder:
|
|
|
|
def __init__(self, config, library, metadata, name, no_missing, data, playlist=False, valid_users=None):
|
|
|
|
def __init__(self, config, metadata, name, no_missing, data, library=None):
|
|
|
|
self.config = config
|
|
|
|
self.config = config
|
|
|
|
self.library = library
|
|
|
|
|
|
|
|
self.metadata = metadata
|
|
|
|
self.metadata = metadata
|
|
|
|
self.mapping_name = name
|
|
|
|
self.mapping_name = name
|
|
|
|
self.no_missing = no_missing
|
|
|
|
self.no_missing = no_missing
|
|
|
|
self.data = data
|
|
|
|
self.data = data
|
|
|
|
self.playlist = playlist
|
|
|
|
self.library = library
|
|
|
|
self.valid_users = valid_users
|
|
|
|
self.libraries = []
|
|
|
|
|
|
|
|
self.playlist = library is None
|
|
|
|
|
|
|
|
methods = {m.lower(): m for m in self.data}
|
|
|
|
|
|
|
|
self.type = "playlist" if self.playlist else "collection"
|
|
|
|
|
|
|
|
self.Type = self.type.capitalize()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if "name" in methods:
|
|
|
|
|
|
|
|
name = self.data[methods["name"]]
|
|
|
|
|
|
|
|
elif f"{self.type}_name" in methods:
|
|
|
|
|
|
|
|
logger.warning(f"Config Warning: Running {self.type}_name as name")
|
|
|
|
|
|
|
|
name = self.data[methods[f"{self.type}_name"]]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
name = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if name:
|
|
|
|
|
|
|
|
logger.debug("")
|
|
|
|
|
|
|
|
logger.debug("Validating Method: name")
|
|
|
|
|
|
|
|
if not name:
|
|
|
|
|
|
|
|
raise Failed(f"{self.Type} Error: name attribute is blank")
|
|
|
|
|
|
|
|
logger.debug(f"Value: {name}")
|
|
|
|
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.name = self.mapping_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if "template" in methods:
|
|
|
|
|
|
|
|
logger.debug("")
|
|
|
|
|
|
|
|
logger.debug("Validating Method: template")
|
|
|
|
|
|
|
|
new_attributes = self.metadata.apply_template(self.name, self.data, self.data[methods["template"]])
|
|
|
|
|
|
|
|
for attr in new_attributes:
|
|
|
|
|
|
|
|
if attr.lower() not in methods:
|
|
|
|
|
|
|
|
self.data[attr] = new_attributes[attr]
|
|
|
|
|
|
|
|
methods[attr.lower()] = attr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.playlist:
|
|
|
|
|
|
|
|
if "libraries" in methods:
|
|
|
|
|
|
|
|
logger.debug("")
|
|
|
|
|
|
|
|
logger.debug("Validating Method: libraries")
|
|
|
|
|
|
|
|
if not self.data[methods["libraries"]]:
|
|
|
|
|
|
|
|
raise Failed(f"{self.Type} Error: libraries attribute is blank")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.debug(f"Value: {self.data[methods['libraries']]}")
|
|
|
|
|
|
|
|
for pl_library in util.get_list(self.data[methods["libraries"]]):
|
|
|
|
|
|
|
|
if str(pl_library) in config.library_map:
|
|
|
|
|
|
|
|
self.libraries.append(config.library_map[pl_library])
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise Failed(f"Playlist Error: Library: {pl_library} not defined")
|
|
|
|
|
|
|
|
self.library = self.libraries[0]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise Failed("Playlist Error: libraries attribute is required")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.libraries.append(self.library)
|
|
|
|
|
|
|
|
|
|
|
|
self.language = self.library.Plex.language
|
|
|
|
self.language = self.library.Plex.language
|
|
|
|
self.details = {
|
|
|
|
self.details = {
|
|
|
|
"show_filtered": self.library.show_filtered,
|
|
|
|
"show_filtered": self.library.show_filtered,
|
|
|
@ -253,37 +303,41 @@ class CollectionBuilder:
|
|
|
|
self.exists = False
|
|
|
|
self.exists = False
|
|
|
|
self.created = False
|
|
|
|
self.created = False
|
|
|
|
self.deleted = False
|
|
|
|
self.deleted = False
|
|
|
|
self.type = "playlist" if self.playlist else "collection"
|
|
|
|
self.sync_to_users = None
|
|
|
|
self.Type = self.type.capitalize()
|
|
|
|
self.valid_users = []
|
|
|
|
|
|
|
|
|
|
|
|
methods = {m.lower(): m for m in self.data}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if "name" in methods:
|
|
|
|
if self.playlist:
|
|
|
|
name = self.data[methods["name"]]
|
|
|
|
server_check = None
|
|
|
|
elif f"{self.type}_name" in methods:
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
logger.warning(f"Config Warning: Running {self.type}_name as name")
|
|
|
|
if server_check:
|
|
|
|
name = self.data[methods[f"{self.type}_name"]]
|
|
|
|
if pl_library.PlexServer.machineIdentifier != server_check:
|
|
|
|
|
|
|
|
raise Failed("Playlist Error: All defined libraries must be on the same server")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
name = None
|
|
|
|
server_check = pl_library.PlexServer.machineIdentifier
|
|
|
|
|
|
|
|
|
|
|
|
if name:
|
|
|
|
self.sync_to_users = config.general["playlist_sync_to_users"]
|
|
|
|
|
|
|
|
if "sync_to_users" in methods or "sync_to_user" in methods:
|
|
|
|
|
|
|
|
s_attr = f"sync_to_user{'s' if 'sync_to_users' in methods else ''}"
|
|
|
|
logger.debug("")
|
|
|
|
logger.debug("")
|
|
|
|
logger.debug("Validating Method: name")
|
|
|
|
logger.debug("Validating Method: sync_to_users")
|
|
|
|
if not name:
|
|
|
|
if self.data[methods[s_attr]]:
|
|
|
|
raise Failed(f"{self.Type} Error: name attribute is blank")
|
|
|
|
logger.warning(f"Playlist Error: sync_to_users attribute is blank defaulting to playlist_sync_to_user: {self.sync_to_users}")
|
|
|
|
logger.debug(f"Value: {name}")
|
|
|
|
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.name = self.mapping_name
|
|
|
|
logger.debug(f"Value: {self.data[methods[s_attr]]}")
|
|
|
|
|
|
|
|
self.sync_to_users = self.data[methods[s_attr]]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.warning(f"Playlist Error: sync_to_users attribute not found defaulting to playlist_sync_to_user: {self.sync_to_users}")
|
|
|
|
|
|
|
|
|
|
|
|
if "template" in methods:
|
|
|
|
plex_users = self.library.users
|
|
|
|
logger.debug("")
|
|
|
|
if self.sync_to_users:
|
|
|
|
logger.debug("Validating Method: template")
|
|
|
|
if str(self.sync_to_users) == "all":
|
|
|
|
new_attributes = self.metadata.apply_template(self.name, self.data, self.data[methods["template"]])
|
|
|
|
self.valid_users = plex_users
|
|
|
|
for attr in new_attributes:
|
|
|
|
else:
|
|
|
|
if attr.lower() not in methods:
|
|
|
|
for user in util.get_list(self.sync_to_users):
|
|
|
|
self.data[attr] = new_attributes[attr]
|
|
|
|
if user in plex_users:
|
|
|
|
methods[attr.lower()] = attr
|
|
|
|
self.valid_users.append(user)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise Failed(f"Playlist Error: User: {user} not found in plex\nOptions: {plex_users}")
|
|
|
|
|
|
|
|
|
|
|
|
if "delete_not_scheduled" in methods:
|
|
|
|
if "delete_not_scheduled" in methods:
|
|
|
|
logger.debug("")
|
|
|
|
logger.debug("")
|
|
|
@ -594,7 +648,7 @@ class CollectionBuilder:
|
|
|
|
raise Failed(f"{self.Type} Error: No builders allowed with blank_collection")
|
|
|
|
raise Failed(f"{self.Type} Error: No builders allowed with blank_collection")
|
|
|
|
|
|
|
|
|
|
|
|
if self.custom_sort is True and (len(self.builders) > 1 or self.builders[0][0] not in custom_sort_builders):
|
|
|
|
if self.custom_sort is True and (len(self.builders) > 1 or self.builders[0][0] not in custom_sort_builders):
|
|
|
|
raise Failed(f"{self.Type} Error: " + ('Playlists' if playlist else 'collection_order: custom') +
|
|
|
|
raise Failed(f"{self.Type} Error: " + ('Playlists' if self.playlist else 'collection_order: custom') +
|
|
|
|
(f" can only be used with a single builder per {self.type}" if len(self.builders) > 1 else f" cannot be used with {self.builders[0][0]}"))
|
|
|
|
(f" can only be used with a single builder per {self.type}" if len(self.builders) > 1 else f" cannot be used with {self.builders[0][0]}"))
|
|
|
|
|
|
|
|
|
|
|
|
if "add_missing" not in self.radarr_details:
|
|
|
|
if "add_missing" not in self.radarr_details:
|
|
|
@ -1254,13 +1308,8 @@ class CollectionBuilder:
|
|
|
|
self.config.Cache.update_list_ids(list_key, ids)
|
|
|
|
self.config.Cache.update_list_ids(list_key, ids)
|
|
|
|
return ids
|
|
|
|
return ids
|
|
|
|
|
|
|
|
|
|
|
|
def find_rating_keys(self):
|
|
|
|
def filter_and_save_items(self, ids):
|
|
|
|
for method, value in self.builders:
|
|
|
|
|
|
|
|
logger.debug("")
|
|
|
|
|
|
|
|
logger.debug(f"Builder: {method}: {value}")
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
items = []
|
|
|
|
items = []
|
|
|
|
ids = self.gather_ids(method, value)
|
|
|
|
|
|
|
|
if len(ids) > 0:
|
|
|
|
if len(ids) > 0:
|
|
|
|
total_ids = len(ids)
|
|
|
|
total_ids = len(ids)
|
|
|
|
logger.debug("")
|
|
|
|
logger.debug("")
|
|
|
@ -1269,118 +1318,139 @@ class CollectionBuilder:
|
|
|
|
for i, input_data in enumerate(ids, 1):
|
|
|
|
for i, input_data in enumerate(ids, 1):
|
|
|
|
input_id, id_type = input_data
|
|
|
|
input_id, id_type = input_data
|
|
|
|
util.print_return(f"Parsing ID {i}/{total_ids}")
|
|
|
|
util.print_return(f"Parsing ID {i}/{total_ids}")
|
|
|
|
if id_type == "tvdb_season" and self.collection_level == "season":
|
|
|
|
rating_keys = []
|
|
|
|
show_id, season_num = input_id.split("_")
|
|
|
|
if id_type == "ratingKey":
|
|
|
|
show_id = int(show_id)
|
|
|
|
rating_keys = int(input_id)
|
|
|
|
if show_id in self.library.show_map:
|
|
|
|
elif id_type == "imdb":
|
|
|
|
show_item = self.library.fetchItem(self.library.show_map[show_id][0])
|
|
|
|
if input_id not in self.ignore_imdb_ids:
|
|
|
|
try:
|
|
|
|
found = False
|
|
|
|
items.append(show_item.season(season=int(season_num)))
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
except NotFound:
|
|
|
|
if input_id in pl_library.imdb_map:
|
|
|
|
self.missing_parts.append(f"{show_item.title} Season: {season_num} Missing")
|
|
|
|
found = True
|
|
|
|
elif show_id not in self.missing_shows:
|
|
|
|
rating_keys = pl_library.imdb_map[input_id]
|
|
|
|
self.missing_shows.append(show_id)
|
|
|
|
break
|
|
|
|
elif id_type in ["tvdb_episode", "imdb"] and self.collection_level == "episode":
|
|
|
|
if not found and (self.collection_level == "episode" or self.playlist or self.do_missing):
|
|
|
|
if id_type == "tvdb_episode":
|
|
|
|
|
|
|
|
show_id, season_num, episode_num = input_id.split("_")
|
|
|
|
|
|
|
|
show_id = int(show_id)
|
|
|
|
|
|
|
|
elif id_type == "imdb" and input_id not in self.ignore_imdb_ids:
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
_id, tmdb_type = self.config.Convert.imdb_to_tmdb(input_id, fail=True)
|
|
|
|
_id, tmdb_type = self.config.Convert.imdb_to_tmdb(input_id, fail=True)
|
|
|
|
if tmdb_type != "episode":
|
|
|
|
if tmdb_type == "episode" and (self.collection_level == "episode" or self.playlist):
|
|
|
|
raise Failed
|
|
|
|
try:
|
|
|
|
tmdb_id, season_num, episode_num = _id.split("_")
|
|
|
|
tmdb_id, season_num, episode_num = _id.split("_")
|
|
|
|
show_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
|
|
|
|
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
except Failed as e:
|
|
|
|
except Failed as e:
|
|
|
|
if self.config.OMDb:
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
if not self.config.OMDb:
|
|
|
|
|
|
|
|
raise Failed("")
|
|
|
|
if self.config.OMDb.limit:
|
|
|
|
if self.config.OMDb.limit:
|
|
|
|
raise Failed(f" and OMDb limit reached.")
|
|
|
|
raise Failed(" and OMDb limit reached.")
|
|
|
|
omdb_item = self.config.OMDb.get_omdb(input_id)
|
|
|
|
omdb_item = self.config.OMDb.get_omdb(input_id)
|
|
|
|
show_id = omdb_item.series_id
|
|
|
|
tvdb_id = omdb_item.series_id
|
|
|
|
season_num = omdb_item.season_num
|
|
|
|
season_num = omdb_item.season_num
|
|
|
|
episode_num = omdb_item.episode_num
|
|
|
|
episode_num = omdb_item.episode_num
|
|
|
|
if not show_id or not season_num or not episode_num:
|
|
|
|
if not tvdb_id or not season_num or not episode_num:
|
|
|
|
raise Failed(f" and OMDb metadata lookup Failed for IMDb ID: {input_id}")
|
|
|
|
raise Failed(f" and OMDb metadata lookup Failed for IMDb ID: {input_id}")
|
|
|
|
except Failed as ee:
|
|
|
|
except Failed as ee:
|
|
|
|
logger.error(f"{e}{ee}")
|
|
|
|
logger.error(f"{e}{ee}")
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
logger.error(e)
|
|
|
|
if tvdb_id in pl_library.show_map:
|
|
|
|
continue
|
|
|
|
found = True
|
|
|
|
else:
|
|
|
|
show_item = pl_library.fetchItem(pl_library.show_map[tvdb_id][0])
|
|
|
|
continue
|
|
|
|
|
|
|
|
if show_id in self.library.show_map or show_id in self.library.imdb_map:
|
|
|
|
|
|
|
|
show_item = self.library.fetchItem(self.library.show_map[show_id][0] if show_id in self.library.show_map else self.library.imdb_map[show_id][0])
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
items.append(show_item.episode(season=int(season_num), episode=int(episode_num)))
|
|
|
|
items.append(show_item.episode(season=int(season_num), episode=int(episode_num)))
|
|
|
|
except NotFound:
|
|
|
|
except NotFound:
|
|
|
|
self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
|
|
|
|
self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
if isinstance(show_id, str) and self.do_missing:
|
|
|
|
if not found and tvdb_id not in self.missing_shows and self.do_missing:
|
|
|
|
try:
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
tmdb_id, _ = self.config.Convert.imdb_to_tmdb(input_id, fail=True)
|
|
|
|
elif tmdb_type == "movie" and self.do_missing and _id not in self.missing_movies:
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
|
|
|
|
self.missing_movies.append(_id)
|
|
|
|
|
|
|
|
elif tmdb_type == "show" and self.do_missing:
|
|
|
|
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(_id, fail=True)
|
|
|
|
if tvdb_id not in self.missing_shows:
|
|
|
|
if tvdb_id not in self.missing_shows:
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
except Failed as e:
|
|
|
|
except Failed as e:
|
|
|
|
logger.warning(e)
|
|
|
|
logger.warning(e)
|
|
|
|
elif show_id not in self.missing_shows:
|
|
|
|
continue
|
|
|
|
self.missing_shows.append(show_id)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
rating_keys = []
|
|
|
|
|
|
|
|
if id_type == "ratingKey":
|
|
|
|
|
|
|
|
rating_keys = int(input_id)
|
|
|
|
|
|
|
|
elif id_type == "tmdb" and not self.parts_collection:
|
|
|
|
elif id_type == "tmdb" and not self.parts_collection:
|
|
|
|
input_id = int(input_id)
|
|
|
|
input_id = int(input_id)
|
|
|
|
if input_id not in self.ignore_ids:
|
|
|
|
if input_id not in self.ignore_ids:
|
|
|
|
if input_id in self.library.movie_map:
|
|
|
|
found = False
|
|
|
|
rating_keys = self.library.movie_map[input_id]
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
elif input_id not in self.missing_movies:
|
|
|
|
if input_id in pl_library.movie_map:
|
|
|
|
|
|
|
|
found = True
|
|
|
|
|
|
|
|
rating_keys = pl_library.movie_map[input_id]
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
if not found and input_id not in self.missing_movies:
|
|
|
|
self.missing_movies.append(input_id)
|
|
|
|
self.missing_movies.append(input_id)
|
|
|
|
elif id_type in ["tvdb", "tmdb_show"] and not self.parts_collection:
|
|
|
|
elif id_type in ["tvdb", "tmdb_show"] and not self.parts_collection:
|
|
|
|
input_id = int(input_id)
|
|
|
|
|
|
|
|
if id_type == "tmdb_show":
|
|
|
|
if id_type == "tmdb_show":
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
input_id = self.config.Convert.tmdb_to_tvdb(input_id, fail=True)
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(input_id, fail=True)
|
|
|
|
except Failed as e:
|
|
|
|
except Failed as e:
|
|
|
|
logger.warning(e)
|
|
|
|
logger.warning(e)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
if input_id not in self.ignore_ids:
|
|
|
|
else:
|
|
|
|
if input_id in self.library.show_map:
|
|
|
|
tvdb_id = int(input_id)
|
|
|
|
rating_keys = self.library.show_map[input_id]
|
|
|
|
if tvdb_id not in self.ignore_ids:
|
|
|
|
elif input_id not in self.missing_shows:
|
|
|
|
found = False
|
|
|
|
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
|
|
|
|
if tvdb_id in pl_library.show_map:
|
|
|
|
|
|
|
|
found = True
|
|
|
|
|
|
|
|
rating_keys = pl_library.show_map[tvdb_id]
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
if not found and tvdb_id not in self.missing_shows:
|
|
|
|
self.missing_shows.append(input_id)
|
|
|
|
self.missing_shows.append(input_id)
|
|
|
|
elif id_type == "imdb" and not self.parts_collection:
|
|
|
|
elif id_type == "tvdb_season" and (self.collection_level == "season" or self.playlist):
|
|
|
|
if input_id not in self.ignore_imdb_ids:
|
|
|
|
tvdb_id, season_num = input_id.split("_")
|
|
|
|
if input_id in self.library.imdb_map:
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
rating_keys = self.library.imdb_map[input_id]
|
|
|
|
found = False
|
|
|
|
elif self.do_missing:
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
|
|
|
|
if tvdb_id in pl_library.show_map:
|
|
|
|
|
|
|
|
found = True
|
|
|
|
|
|
|
|
show_item = pl_library.fetchItem(pl_library.show_map[tvdb_id][0])
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
tmdb_id, tmdb_type = self.config.Convert.imdb_to_tmdb(input_id, fail=True)
|
|
|
|
season_obj = show_item.season(season=int(season_num))
|
|
|
|
if tmdb_type == "movie":
|
|
|
|
if self.playlist:
|
|
|
|
if tmdb_id not in self.missing_movies:
|
|
|
|
items.extend(season_obj.episodes())
|
|
|
|
self.missing_movies.append(tmdb_id)
|
|
|
|
else:
|
|
|
|
elif tmdb_type == "show":
|
|
|
|
items.append(season_obj)
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
|
|
|
|
except NotFound:
|
|
|
|
if tvdb_id not in self.missing_shows:
|
|
|
|
self.missing_parts.append(f"{show_item.title} Season: {season_num} Missing")
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
if not found and tvdb_id not in self.missing_shows:
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
except Failed as e:
|
|
|
|
elif id_type == "tvdb_episode" and (self.collection_level == "episode" or self.playlist):
|
|
|
|
logger.warning(e)
|
|
|
|
tvdb_id, season_num, episode_num = input_id.split("_")
|
|
|
|
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
|
|
|
|
found = False
|
|
|
|
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
|
|
|
|
if tvdb_id in pl_library.show_map:
|
|
|
|
|
|
|
|
found = True
|
|
|
|
|
|
|
|
show_item = pl_library.fetchItem(pl_library.show_map[tvdb_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")
|
|
|
|
|
|
|
|
if not found and tvdb_id not in self.missing_shows and self.do_missing:
|
|
|
|
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
|
|
|
|
else:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(rating_keys, list):
|
|
|
|
if not isinstance(rating_keys, list):
|
|
|
|
rating_keys = [rating_keys]
|
|
|
|
rating_keys = [rating_keys]
|
|
|
|
for rk in rating_keys:
|
|
|
|
for rk in rating_keys:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
items.append(self.fetch_item(rk))
|
|
|
|
item = self.fetch_item(rk)
|
|
|
|
|
|
|
|
if self.playlist and isinstance(item, (Show, Season)):
|
|
|
|
|
|
|
|
items.extend(item.episodes())
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
items.append(item)
|
|
|
|
except Failed as e:
|
|
|
|
except Failed as e:
|
|
|
|
logger.error(e)
|
|
|
|
logger.error(e)
|
|
|
|
util.print_end()
|
|
|
|
util.print_end()
|
|
|
|
|
|
|
|
if not items:
|
|
|
|
if len(items) > 0:
|
|
|
|
return None
|
|
|
|
self.filter_and_save_items(items)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def filter_and_save_items(self, items):
|
|
|
|
|
|
|
|
name = self.obj.title if self.obj else self.name
|
|
|
|
name = self.obj.title if self.obj else self.name
|
|
|
|
total = len(items)
|
|
|
|
total = len(items)
|
|
|
|
max_length = len(str(total))
|
|
|
|
max_length = len(str(total))
|
|
|
|