|
|
@ -2234,179 +2234,183 @@ class CollectionBuilder:
|
|
|
|
logger.trace(f"IDs: {ids}")
|
|
|
|
logger.trace(f"IDs: {ids}")
|
|
|
|
logger.debug("")
|
|
|
|
logger.debug("")
|
|
|
|
for i, input_data in enumerate(ids, 1):
|
|
|
|
for i, input_data in enumerate(ids, 1):
|
|
|
|
input_id, id_type = input_data
|
|
|
|
try:
|
|
|
|
logger.ghost(f"Parsing ID {i}/{total_ids}")
|
|
|
|
input_id, id_type = input_data
|
|
|
|
rating_keys = []
|
|
|
|
logger.ghost(f"Parsing ID {i}/{total_ids}")
|
|
|
|
if id_type == "ratingKey":
|
|
|
|
rating_keys = []
|
|
|
|
rating_keys = int(input_id)
|
|
|
|
if id_type == "ratingKey":
|
|
|
|
elif id_type == "imdb":
|
|
|
|
rating_keys = int(input_id)
|
|
|
|
if input_id not in self.ignore_imdb_ids:
|
|
|
|
elif id_type == "imdb":
|
|
|
|
found = False
|
|
|
|
if input_id not in self.ignore_imdb_ids:
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
found = False
|
|
|
|
if input_id in pl_library.imdb_map:
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
found = True
|
|
|
|
if input_id in pl_library.imdb_map:
|
|
|
|
rating_keys = pl_library.imdb_map[input_id]
|
|
|
|
found = True
|
|
|
|
break
|
|
|
|
rating_keys = pl_library.imdb_map[input_id]
|
|
|
|
if not found and (self.builder_level == "episode" or self.playlist or self.do_missing):
|
|
|
|
break
|
|
|
|
try:
|
|
|
|
if not found and (self.builder_level == "episode" or self.playlist or self.do_missing):
|
|
|
|
_id, tmdb_type = self.config.Convert.imdb_to_tmdb(input_id, fail=True)
|
|
|
|
try:
|
|
|
|
if tmdb_type == "episode" and (self.builder_level == "episode" or self.playlist):
|
|
|
|
_id, tmdb_type = self.config.Convert.imdb_to_tmdb(input_id, fail=True)
|
|
|
|
try:
|
|
|
|
if tmdb_type == "episode" and (self.builder_level == "episode" or self.playlist):
|
|
|
|
tmdb_id, season_num, episode_num = _id.split("_")
|
|
|
|
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
|
|
|
|
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
|
|
|
|
except Failed as e:
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if not self.config.OMDb:
|
|
|
|
tmdb_id, season_num, episode_num = _id.split("_")
|
|
|
|
raise Failed("")
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
|
|
|
|
if self.config.OMDb.limit:
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
raise Failed(" and OMDb limit reached.")
|
|
|
|
except Failed as e:
|
|
|
|
omdb_item = self.config.OMDb.get_omdb(input_id)
|
|
|
|
|
|
|
|
tvdb_id = omdb_item.series_id
|
|
|
|
|
|
|
|
season_num = omdb_item.season_num
|
|
|
|
|
|
|
|
episode_num = omdb_item.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}")
|
|
|
|
|
|
|
|
except Failed as ee:
|
|
|
|
|
|
|
|
logger.error(f"{e}{ee}")
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
|
|
|
|
if tvdb_id in pl_library.show_map:
|
|
|
|
|
|
|
|
found = True
|
|
|
|
|
|
|
|
show_item = pl_library.fetch_item(pl_library.show_map[tvdb_id][0])
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
items.append(show_item.episode(season=int(season_num), episode=int(episode_num)))
|
|
|
|
if not self.config.OMDb:
|
|
|
|
except NotFound:
|
|
|
|
raise Failed("")
|
|
|
|
self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
|
|
|
|
if self.config.OMDb.limit:
|
|
|
|
break
|
|
|
|
raise Failed(" and OMDb limit reached.")
|
|
|
|
if not found and tvdb_id not in self.missing_shows and self.do_missing:
|
|
|
|
omdb_item = self.config.OMDb.get_omdb(input_id)
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
tvdb_id = omdb_item.series_id
|
|
|
|
elif tmdb_type == "movie" and self.do_missing and _id not in self.missing_movies:
|
|
|
|
season_num = omdb_item.season_num
|
|
|
|
self.missing_movies.append(_id)
|
|
|
|
episode_num = omdb_item.episode_num
|
|
|
|
elif tmdb_type in ["show", "episode"] and self.do_missing:
|
|
|
|
if not tvdb_id or not season_num or not episode_num:
|
|
|
|
if tmdb_type == "episode":
|
|
|
|
raise Failed(f" and OMDb metadata lookup Failed for IMDb ID: {input_id}")
|
|
|
|
tmdb_id, _, _ = _id.split("_")
|
|
|
|
except Failed as ee:
|
|
|
|
else:
|
|
|
|
logger.error(f"{e}{ee}")
|
|
|
|
tmdb_id = _id
|
|
|
|
continue
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
if tvdb_id not in self.missing_shows:
|
|
|
|
if tvdb_id in pl_library.show_map:
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
found = True
|
|
|
|
except Failed as e:
|
|
|
|
show_item = pl_library.fetch_item(pl_library.show_map[tvdb_id][0])
|
|
|
|
logger.warning(e)
|
|
|
|
try:
|
|
|
|
continue
|
|
|
|
items.append(show_item.episode(season=int(season_num), episode=int(episode_num)))
|
|
|
|
elif id_type == "tmdb" and not self.parts_collection:
|
|
|
|
except NotFound:
|
|
|
|
input_id = int(input_id)
|
|
|
|
self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
|
|
|
|
if input_id not in self.ignore_ids:
|
|
|
|
break
|
|
|
|
|
|
|
|
if not found and tvdb_id not in self.missing_shows and self.do_missing:
|
|
|
|
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
|
|
|
|
elif tmdb_type == "movie" and self.do_missing and _id not in self.missing_movies:
|
|
|
|
|
|
|
|
self.missing_movies.append(_id)
|
|
|
|
|
|
|
|
elif tmdb_type in ["show", "episode"] and self.do_missing:
|
|
|
|
|
|
|
|
if tmdb_type == "episode":
|
|
|
|
|
|
|
|
tmdb_id, _, _ = _id.split("_")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
tmdb_id = _id
|
|
|
|
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
|
|
|
|
|
|
|
|
if tvdb_id not in self.missing_shows:
|
|
|
|
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
|
|
|
|
except Failed as e:
|
|
|
|
|
|
|
|
logger.warning(e)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
elif id_type == "tmdb" and not self.parts_collection:
|
|
|
|
|
|
|
|
input_id = int(input_id)
|
|
|
|
|
|
|
|
if input_id not in self.ignore_ids:
|
|
|
|
|
|
|
|
found = False
|
|
|
|
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
elif id_type == "tvdb_season" and (self.builder_level == "season" or self.playlist):
|
|
|
|
|
|
|
|
tvdb_id, season_num = input_id.split("_")
|
|
|
|
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
found = False
|
|
|
|
found = False
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
if input_id in pl_library.movie_map:
|
|
|
|
if tvdb_id in pl_library.show_map:
|
|
|
|
found = True
|
|
|
|
found = True
|
|
|
|
rating_keys = pl_library.movie_map[input_id]
|
|
|
|
show_item = pl_library.fetch_item(pl_library.show_map[tvdb_id][0])
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
season_obj = show_item.season(season=int(season_num))
|
|
|
|
|
|
|
|
if self.playlist:
|
|
|
|
|
|
|
|
items.extend(season_obj.episodes())
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
items.append(season_obj)
|
|
|
|
|
|
|
|
except NotFound:
|
|
|
|
|
|
|
|
self.missing_parts.append(f"{show_item.title} Season: {season_num} Missing")
|
|
|
|
break
|
|
|
|
break
|
|
|
|
if not found and input_id not in self.missing_movies:
|
|
|
|
if not found and tvdb_id not in self.missing_shows:
|
|
|
|
self.missing_movies.append(input_id)
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
elif id_type == "tvdb_season" and (self.builder_level == "season" or self.playlist):
|
|
|
|
elif id_type == "tvdb_episode" and (self.builder_level == "episode" or self.playlist):
|
|
|
|
tvdb_id, season_num = input_id.split("_")
|
|
|
|
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.fetch_item(pl_library.show_map[tvdb_id][0])
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
season_obj = show_item.season(season=int(season_num))
|
|
|
|
|
|
|
|
if self.playlist:
|
|
|
|
|
|
|
|
items.extend(season_obj.episodes())
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
items.append(season_obj)
|
|
|
|
|
|
|
|
except NotFound:
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
elif id_type == "tvdb_episode" and (self.builder_level == "episode" or self.playlist):
|
|
|
|
|
|
|
|
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.fetch_item(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)
|
|
|
|
|
|
|
|
elif id_type in ["tvdb", "tmdb_show", "tvdb_season", "tvdb_episode"]:
|
|
|
|
|
|
|
|
tvdb_season = None
|
|
|
|
|
|
|
|
if id_type == "tmdb_show":
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(input_id, fail=True)
|
|
|
|
|
|
|
|
except Failed as e:
|
|
|
|
|
|
|
|
logger.warning(e)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
elif id_type == "tvdb_season":
|
|
|
|
|
|
|
|
tvdb_id, tvdb_season = input_id.split("_")
|
|
|
|
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
|
|
|
|
tvdb_season = int(tvdb_season)
|
|
|
|
|
|
|
|
elif id_type == "tvdb_episode":
|
|
|
|
|
|
|
|
tvdb_id, _, _ = input_id.split("_")
|
|
|
|
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
else:
|
|
|
|
found = False
|
|
|
|
tvdb_id = int(input_id)
|
|
|
|
|
|
|
|
if tvdb_id not in self.ignore_ids:
|
|
|
|
|
|
|
|
found_keys = None
|
|
|
|
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
if tvdb_id in pl_library.show_map:
|
|
|
|
if tvdb_id in pl_library.show_map:
|
|
|
|
found_keys = pl_library.show_map[tvdb_id]
|
|
|
|
found = True
|
|
|
|
break
|
|
|
|
show_item = pl_library.fetch_item(pl_library.show_map[tvdb_id][0])
|
|
|
|
if not found_keys and tvdb_id not in self.missing_shows:
|
|
|
|
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)
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
if found_keys:
|
|
|
|
elif id_type in ["tvdb", "tmdb_show", "tvdb_season", "tvdb_episode"]:
|
|
|
|
if self.parts_collection:
|
|
|
|
tvdb_season = None
|
|
|
|
rating_keys = []
|
|
|
|
if id_type == "tmdb_show":
|
|
|
|
for rk in found_keys:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
tvdb_id = self.config.Convert.tmdb_to_tvdb(input_id, fail=True)
|
|
|
|
item = self.library.fetch_item(rk)
|
|
|
|
except Failed as e:
|
|
|
|
if self.builder_level == "episode" and isinstance(item, Show):
|
|
|
|
logger.warning(e)
|
|
|
|
if tvdb_season is not None:
|
|
|
|
continue
|
|
|
|
item = item.season(season=tvdb_season)
|
|
|
|
elif id_type == "tvdb_season":
|
|
|
|
rating_keys.extend([k.ratingKey for k in item.episodes()])
|
|
|
|
tvdb_id, tvdb_season = input_id.split("_")
|
|
|
|
elif self.builder_level == "season" and isinstance(item, Show):
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
rating_keys.extend([k.ratingKey for k in item.seasons()])
|
|
|
|
tvdb_season = int(tvdb_season)
|
|
|
|
except Failed as e:
|
|
|
|
elif id_type == "tvdb_episode":
|
|
|
|
logger.error(e)
|
|
|
|
tvdb_id, _, _ = input_id.split("_")
|
|
|
|
else:
|
|
|
|
tvdb_id = int(tvdb_id)
|
|
|
|
rating_keys = found_keys
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(rating_keys, list):
|
|
|
|
|
|
|
|
rating_keys = [rating_keys]
|
|
|
|
|
|
|
|
for rk in rating_keys:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
item = self.library.fetch_item(rk)
|
|
|
|
|
|
|
|
if self.playlist and isinstance(item, (Show, Season)):
|
|
|
|
|
|
|
|
items.extend(item.episodes())
|
|
|
|
|
|
|
|
elif self.builder_level == "movie" and not isinstance(item, Movie):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not an Movie")
|
|
|
|
|
|
|
|
elif self.builder_level == "show" and not isinstance(item, Show):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not an Show")
|
|
|
|
|
|
|
|
elif self.builder_level == "episode" and not isinstance(item, Episode):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not an Episode")
|
|
|
|
|
|
|
|
elif self.builder_level == "season" and not isinstance(item, Season):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not a Season")
|
|
|
|
|
|
|
|
elif self.builder_level == "artist" and not isinstance(item, Artist):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not an Artist")
|
|
|
|
|
|
|
|
elif self.builder_level == "album" and not isinstance(item, Album):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not an Album")
|
|
|
|
|
|
|
|
elif self.builder_level == "track" and not isinstance(item, Track):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not a Track")
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
items.append(item)
|
|
|
|
tvdb_id = int(input_id)
|
|
|
|
except Failed as e:
|
|
|
|
if tvdb_id not in self.ignore_ids:
|
|
|
|
logger.error(e)
|
|
|
|
found_keys = None
|
|
|
|
|
|
|
|
for pl_library in self.libraries:
|
|
|
|
|
|
|
|
if tvdb_id in pl_library.show_map:
|
|
|
|
|
|
|
|
found_keys = pl_library.show_map[tvdb_id]
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
if not found_keys and tvdb_id not in self.missing_shows:
|
|
|
|
|
|
|
|
self.missing_shows.append(tvdb_id)
|
|
|
|
|
|
|
|
if found_keys:
|
|
|
|
|
|
|
|
if self.parts_collection:
|
|
|
|
|
|
|
|
rating_keys = []
|
|
|
|
|
|
|
|
for rk in found_keys:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
item = self.library.fetch_item(rk)
|
|
|
|
|
|
|
|
if self.builder_level == "episode" and isinstance(item, Show):
|
|
|
|
|
|
|
|
if tvdb_season is not None:
|
|
|
|
|
|
|
|
item = item.season(season=tvdb_season)
|
|
|
|
|
|
|
|
rating_keys.extend([k.ratingKey for k in item.episodes()])
|
|
|
|
|
|
|
|
elif self.builder_level == "season" and isinstance(item, Show):
|
|
|
|
|
|
|
|
rating_keys.extend([k.ratingKey for k in item.seasons()])
|
|
|
|
|
|
|
|
except Failed as e:
|
|
|
|
|
|
|
|
logger.error(e)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
rating_keys = found_keys
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
if not isinstance(rating_keys, list):
|
|
|
|
|
|
|
|
rating_keys = [rating_keys]
|
|
|
|
|
|
|
|
for rk in rating_keys:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
item = self.library.fetch_item(rk)
|
|
|
|
|
|
|
|
if self.playlist and isinstance(item, (Show, Season)):
|
|
|
|
|
|
|
|
items.extend(item.episodes())
|
|
|
|
|
|
|
|
elif self.builder_level == "movie" and not isinstance(item, Movie):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not an Movie")
|
|
|
|
|
|
|
|
elif self.builder_level == "show" and not isinstance(item, Show):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not an Show")
|
|
|
|
|
|
|
|
elif self.builder_level == "episode" and not isinstance(item, Episode):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not an Episode")
|
|
|
|
|
|
|
|
elif self.builder_level == "season" and not isinstance(item, Season):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not a Season")
|
|
|
|
|
|
|
|
elif self.builder_level == "artist" and not isinstance(item, Artist):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not an Artist")
|
|
|
|
|
|
|
|
elif self.builder_level == "album" and not isinstance(item, Album):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not an Album")
|
|
|
|
|
|
|
|
elif self.builder_level == "track" and not isinstance(item, Track):
|
|
|
|
|
|
|
|
logger.info(f"Item: {item} is not a Track")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
items.append(item)
|
|
|
|
|
|
|
|
except Failed as e:
|
|
|
|
|
|
|
|
logger.error(e)
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
logger.stacktrace()
|
|
|
|
|
|
|
|
logger.error(e)
|
|
|
|
|
|
|
|
logger.info(input_data)
|
|
|
|
logger.exorcise()
|
|
|
|
logger.exorcise()
|
|
|
|
if not items:
|
|
|
|
if not items:
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|