[13] fix tmdb episode metadata

This commit is contained in:
meisnate12 2022-07-06 14:38:26 -04:00
parent a7ef2d9040
commit d150d52dbd
4 changed files with 35 additions and 33 deletions

View file

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

View file

@ -2472,7 +2472,7 @@ class CollectionBuilder:
sync_tags.append("PMM")
else:
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:
batch_display += f"\n{tag_results}"

View file

@ -85,7 +85,8 @@ class Operations:
except Failed as e:
logger.error(e)
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 []
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:
logger.error("Daily OMDb Limit Reached")
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:
try:
omdb_item = self.config.OMDb.get_omdb(imdb_id)
@ -150,7 +151,7 @@ class Operations:
except Failed as e:
logger.error(str(e))
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
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]
else:
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:
try:
anidb_item = self.config.AniDB.get_anime(anidb_id)
@ -185,7 +186,7 @@ class Operations:
logger.error(f"IMDb ID: {imdb_id}")
raise
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):
if tmdb_item and attribute == "tmdb":
@ -243,7 +244,7 @@ class Operations:
else:
raise Failed
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 not new_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)
if str(item.audienceRating) != str(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:
logger.info(f"{item.title[:25]:<25} | No Rating Found")
logger.info(f"No Audience Rating Found")
if self.library.mass_critic_rating_update:
try:
new_rating = get_rating(self.library.mass_critic_rating_update)
if str(item.rating) != str(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:
logger.info(f"{item.title[:25]:<25} | No Rating Found")
logger.info(f"No Critic Rating Found")
if self.library.mass_user_rating_update:
try:
new_rating = get_rating(self.library.mass_user_rating_update)
if str(item.userRating) != str(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:
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:
try:
@ -304,10 +305,10 @@ class Operations:
if new_rating in self.library.content_rating_mapper:
new_rating = self.library.content_rating_mapper[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):
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:
pass
if self.library.mass_originally_available_update:
@ -325,10 +326,10 @@ class Operations:
else:
raise Failed
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):
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:
pass
@ -341,17 +342,18 @@ class Operations:
if any([x is not None for x in episode_ops]):
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():
ep.batchEdits()
batch_display = ""
item_title = self.library.get_item_sort_title(ep, atr="title")
logger.info("")
logger.info(f"Processing {item_title}")
def get_episode_rating(attribute):
if tmdb_id and attribute == "tmdb":
if tmdb_item and attribute == "tmdb":
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:
logger.error(er)
elif imdb_id and attribute == "imdb":
@ -362,39 +364,39 @@ class Operations:
if self.library.mass_episode_audience_rating_update:
try:
new_rating = get_episode_rating(self.library.mass_episode_audience_rating_update)
if new_rating is None:
logger.info(f"{item_title[:25]:<25} | No Rating Found")
if not new_rating:
logger.info(f"No Audience Rating Found")
elif str(ep.audienceRating) != str(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:
pass
if self.library.mass_episode_critic_rating_update:
try:
new_rating = get_episode_rating(self.library.mass_episode_critic_rating_update)
if new_rating is None:
logger.info(f"{item_title[:25]:<25} | No Rating Found")
if not new_rating:
logger.info(f"No Critic Rating Found")
elif str(ep.rating) != str(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:
pass
if self.library.mass_episode_user_rating_update:
try:
new_rating = get_episode_rating(self.library.mass_episode_user_rating_update)
if new_rating is None:
logger.info(f"{item_title[:25]:<25} | No Rating Found")
if not new_rating:
logger.info(f"No User Rating Found")
elif str(ep.userRating) != str(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:
pass
ep.saveEdits()
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:
try:

View file

@ -919,7 +919,7 @@ class Plex(Library):
final = f"{obj.title[:25]:<25} | {attr_display} | {display}" if display else display
if do_print and 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):
if title is None: