[13] fix tmdb episode metadata

pull/960/head
meisnate12 2 years ago
parent a7ef2d9040
commit d150d52dbd

@ -1 +1 @@
1.17.1-develop12 1.17.1-develop13

@ -2472,7 +2472,7 @@ class CollectionBuilder:
sync_tags.append("PMM") sync_tags.append("PMM")
else: else:
add_tags.append("PMM") add_tags.append("PMM")
tag_results = self.library.edit_tags('label', self.obj, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags, do_print=False)[28:] tag_results = self.library.edit_tags('label', self.obj, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags, do_print=False)
if tag_results: if tag_results:
batch_display += f"\n{tag_results}" batch_display += f"\n{tag_results}"

@ -85,7 +85,8 @@ class Operations:
except Failed as e: except Failed as e:
logger.error(e) logger.error(e)
continue continue
logger.ghost(f"Processing: {i}/{len(items)} {item.title}") logger.info("")
logger.info(f"Processing: {i}/{len(items)} {item.title}")
current_labels = [la.tag for la in self.library.item_labels(item)] if self.library.assets_for_all or self.library.mass_imdb_parental_labels else [] current_labels = [la.tag for la in self.library.item_labels(item)] if self.library.assets_for_all or self.library.mass_imdb_parental_labels else []
if self.library.assets_for_all and self.library.asset_directory: if self.library.assets_for_all and self.library.asset_directory:
@ -132,7 +133,7 @@ class Operations:
if self.config.OMDb.limit is not False: if self.config.OMDb.limit is not False:
logger.error("Daily OMDb Limit Reached") logger.error("Daily OMDb Limit Reached")
elif not imdb_id: elif not imdb_id:
logger.info(f"{item.title[:25]:<25} | No IMDb ID for Guid: {item.guid}") logger.info(f" No IMDb ID for Guid: {item.guid}")
else: else:
try: try:
omdb_item = self.config.OMDb.get_omdb(imdb_id) omdb_item = self.config.OMDb.get_omdb(imdb_id)
@ -150,7 +151,7 @@ class Operations:
except Failed as e: except Failed as e:
logger.error(str(e)) logger.error(str(e))
else: else:
logger.info(f"{item.title[:25]:<25} | No TVDb ID for Guid: {item.guid}") logger.info(f"No TVDb ID for Guid: {item.guid}")
anidb_item = None anidb_item = None
if any([o == "anidb" for o in self.library.meta_operations]): if any([o == "anidb" for o in self.library.meta_operations]):
@ -162,7 +163,7 @@ class Operations:
anidb_id = self.config.Convert._imdb_to_anidb[imdb_id] anidb_id = self.config.Convert._imdb_to_anidb[imdb_id]
else: else:
anidb_id = None anidb_id = None
logger.info(f"{item.title[:25]:<25} | No AniDB ID for Guid: {item.guid}") logger.info(f"No AniDB ID for Guid: {item.guid}")
if anidb_id: if anidb_id:
try: try:
anidb_item = self.config.AniDB.get_anime(anidb_id) anidb_item = self.config.AniDB.get_anime(anidb_id)
@ -185,7 +186,7 @@ class Operations:
logger.error(f"IMDb ID: {imdb_id}") logger.error(f"IMDb ID: {imdb_id}")
raise raise
else: else:
logger.info(f"{item.title[:25]:<25} | No IMDb ID for Guid: {item.guid}") logger.info(f"No IMDb ID for Guid: {item.guid}")
def get_rating(attribute): def get_rating(attribute):
if tmdb_item and attribute == "tmdb": if tmdb_item and attribute == "tmdb":
@ -243,7 +244,7 @@ class Operations:
else: else:
raise Failed raise Failed
if not new_genres: if not new_genres:
logger.info(f"{item.title[:25]:<25} | No Genres Found") logger.info(f"No Genres Found")
if self.library.genre_mapper: if self.library.genre_mapper:
if not new_genres: if not new_genres:
new_genres = [g.tag for g in item.genres] new_genres = [g.tag for g in item.genres]
@ -264,27 +265,27 @@ class Operations:
new_rating = get_rating(self.library.mass_audience_rating_update) new_rating = get_rating(self.library.mass_audience_rating_update)
if str(item.audienceRating) != str(new_rating): if str(item.audienceRating) != str(new_rating):
item.editField("audienceRating", new_rating) item.editField("audienceRating", new_rating)
batch_display += f"\n{item.title[:25]:<25} | Audience Rating | {new_rating}" batch_display += f"\nAudience Rating | {new_rating}"
except Failed: except Failed:
logger.info(f"{item.title[:25]:<25} | No Rating Found") logger.info(f"No Audience Rating Found")
if self.library.mass_critic_rating_update: if self.library.mass_critic_rating_update:
try: try:
new_rating = get_rating(self.library.mass_critic_rating_update) new_rating = get_rating(self.library.mass_critic_rating_update)
if str(item.rating) != str(new_rating): if str(item.rating) != str(new_rating):
item.editField("rating", new_rating) item.editField("rating", new_rating)
batch_display += f"\n{item.title[:25]:<25} | Critic Rating | {new_rating}" batch_display += f"\nCritic Rating | {new_rating}"
except Failed: except Failed:
logger.info(f"{item.title[:25]:<25} | No Rating Found") logger.info(f"No Critic Rating Found")
if self.library.mass_user_rating_update: if self.library.mass_user_rating_update:
try: try:
new_rating = get_rating(self.library.mass_user_rating_update) new_rating = get_rating(self.library.mass_user_rating_update)
if str(item.userRating) != str(new_rating): if str(item.userRating) != str(new_rating):
item.editField("userRating", new_rating) item.editField("userRating", new_rating)
batch_display += f"\n{item.title[:25]:<25} | User Rating | {new_rating}" batch_display += f"\nUser Rating | {new_rating}"
except Failed: except Failed:
logger.info(f"{item.title[:25]:<25} | No Rating Found") logger.info(f"No User Rating Found")
if self.library.mass_content_rating_update or self.library.content_rating_mapper: if self.library.mass_content_rating_update or self.library.content_rating_mapper:
try: try:
@ -304,10 +305,10 @@ class Operations:
if new_rating in self.library.content_rating_mapper: if new_rating in self.library.content_rating_mapper:
new_rating = self.library.content_rating_mapper[new_rating] new_rating = self.library.content_rating_mapper[new_rating]
if not new_rating: if not new_rating:
logger.info(f"{item.title[:25]:<25} | No Content Rating Found") logger.info(f"No Content Rating Found")
elif str(item.contentRating) != str(new_rating): elif str(item.contentRating) != str(new_rating):
item.editContentRating(new_rating) item.editContentRating(new_rating)
batch_display += f"\n{item.title[:25]:<25} | Content Rating | {new_rating}" batch_display += f"\nContent Rating | {new_rating}"
except Failed: except Failed:
pass pass
if self.library.mass_originally_available_update: if self.library.mass_originally_available_update:
@ -325,10 +326,10 @@ class Operations:
else: else:
raise Failed raise Failed
if not new_date: if not new_date:
logger.info(f"{item.title[:25]:<25} | No Originally Available Date Found") logger.info(f"No Originally Available Date Found")
elif str(item.originallyAvailableAt) != str(new_date): elif str(item.originallyAvailableAt) != str(new_date):
item.editOriginallyAvailable(new_date) item.editOriginallyAvailable(new_date)
batch_display += f"\n{item.title[:25]:<25} | Originally Available Date | {new_date.strftime('%Y-%m-%d')}" batch_display += f"\nOriginally Available Date | {new_date.strftime('%Y-%m-%d')}"
except Failed: except Failed:
pass pass
@ -341,17 +342,18 @@ class Operations:
if any([x is not None for x in episode_ops]): if any([x is not None for x in episode_ops]):
if any([x == "imdb" for x in episode_ops]) and not imdb_id: if any([x == "imdb" for x in episode_ops]) and not imdb_id:
logger.info(f"{item.title[:25]:<25} | No IMDb ID for Guid: {item.guid}") logger.info(f"No IMDb ID for Guid: {item.guid}")
for ep in item.episodes(): for ep in item.episodes():
ep.batchEdits() ep.batchEdits()
batch_display = "" batch_display = ""
item_title = self.library.get_item_sort_title(ep, atr="title") item_title = self.library.get_item_sort_title(ep, atr="title")
logger.info("")
logger.info(f"Processing {item_title}")
def get_episode_rating(attribute): def get_episode_rating(attribute):
if tmdb_id and attribute == "tmdb": if tmdb_item and attribute == "tmdb":
try: try:
return self.config.TMDb.get_episode(tmdb_id, ep.seasonNumber, ep.episodeNumber).vote_average return self.config.TMDb.get_episode(tmdb_item.tmdb_id, ep.seasonNumber, ep.episodeNumber).vote_average
except Failed as er: except Failed as er:
logger.error(er) logger.error(er)
elif imdb_id and attribute == "imdb": elif imdb_id and attribute == "imdb":
@ -362,39 +364,39 @@ class Operations:
if self.library.mass_episode_audience_rating_update: if self.library.mass_episode_audience_rating_update:
try: try:
new_rating = get_episode_rating(self.library.mass_episode_audience_rating_update) new_rating = get_episode_rating(self.library.mass_episode_audience_rating_update)
if new_rating is None: if not new_rating:
logger.info(f"{item_title[:25]:<25} | No Rating Found") logger.info(f"No Audience Rating Found")
elif str(ep.audienceRating) != str(new_rating): elif str(ep.audienceRating) != str(new_rating):
ep.editField("audienceRating", new_rating) ep.editField("audienceRating", new_rating)
batch_display += f"\n{item_title[:25]:<25} | Audience Rating | {new_rating}" batch_display += f"\nAudience Rating | {new_rating}"
except Failed: except Failed:
pass pass
if self.library.mass_episode_critic_rating_update: if self.library.mass_episode_critic_rating_update:
try: try:
new_rating = get_episode_rating(self.library.mass_episode_critic_rating_update) new_rating = get_episode_rating(self.library.mass_episode_critic_rating_update)
if new_rating is None: if not new_rating:
logger.info(f"{item_title[:25]:<25} | No Rating Found") logger.info(f"No Critic Rating Found")
elif str(ep.rating) != str(new_rating): elif str(ep.rating) != str(new_rating):
ep.editField("rating", new_rating) ep.editField("rating", new_rating)
batch_display += f"\n{item_title[:25]:<25} | Critic Rating | {new_rating}" batch_display += f"\nCritic Rating | {new_rating}"
except Failed: except Failed:
pass pass
if self.library.mass_episode_user_rating_update: if self.library.mass_episode_user_rating_update:
try: try:
new_rating = get_episode_rating(self.library.mass_episode_user_rating_update) new_rating = get_episode_rating(self.library.mass_episode_user_rating_update)
if new_rating is None: if not new_rating:
logger.info(f"{item_title[:25]:<25} | No Rating Found") logger.info(f"No User Rating Found")
elif str(ep.userRating) != str(new_rating): elif str(ep.userRating) != str(new_rating):
ep.editField("userRating", new_rating) ep.editField("userRating", new_rating)
batch_display += f"\n{item_title[:25]:<25} | User Rating | {new_rating}" batch_display += f"\nUser Rating | {new_rating}"
except Failed: except Failed:
pass pass
ep.saveEdits() ep.saveEdits()
if len(batch_display) > 0: if len(batch_display) > 0:
logger.info(f"Batch Edits{batch_display}") logger.info(f"Batch Edits:{batch_display}")
if self.library.Radarr and self.library.radarr_add_all_existing: if self.library.Radarr and self.library.radarr_add_all_existing:
try: try:

@ -919,7 +919,7 @@ class Plex(Library):
final = f"{obj.title[:25]:<25} | {attr_display} | {display}" if display else display final = f"{obj.title[:25]:<25} | {attr_display} | {display}" if display else display
if do_print and final: if do_print and final:
logger.info(final) logger.info(final)
return final return final[28:] if final else final
def item_images(self, item, group, alias, asset_location=None, title=None, image_name=None, folder_name=None): def item_images(self, item, group, alias, asset_location=None, title=None, image_name=None, folder_name=None):
if title is None: if title is None:

Loading…
Cancel
Save