update sync labels

This commit is contained in:
meisnate12 2021-08-20 09:13:54 -04:00
parent 975ce56b18
commit ddc81cde11
2 changed files with 7 additions and 18 deletions

View file

@ -746,7 +746,7 @@ class Plex:
return False return False
def edit_tags(self, attr, obj, add_tags=None, remove_tags=None, sync_tags=None): def edit_tags(self, attr, obj, add_tags=None, remove_tags=None, sync_tags=None):
updated = False display = ""
key = builder.filter_translation[attr] if attr in builder.filter_translation else attr key = builder.filter_translation[attr] if attr in builder.filter_translation else attr
if add_tags or remove_tags or sync_tags: if add_tags or remove_tags or sync_tags:
_add_tags = add_tags if add_tags else [] _add_tags = add_tags if add_tags else []
@ -760,14 +760,14 @@ class Plex:
_add = [f"{t[:1].upper()}{t[1:]}" for t in _add_tags + _sync_tags if t.lower() not in _item_tags] _add = [f"{t[:1].upper()}{t[1:]}" for t in _add_tags + _sync_tags if t.lower() not in _item_tags]
_remove = [t for t in _item_tags if (_sync_tags and t not in _sync_tags) or t in _remove_tags] _remove = [t for t in _item_tags if (_sync_tags and t not in _sync_tags) or t in _remove_tags]
if _add: if _add:
updated = True
self.query_data(getattr(obj, f"add{attr.capitalize()}"), _add) self.query_data(getattr(obj, f"add{attr.capitalize()}"), _add)
logger.info(f"Detail: {attr.capitalize()} {','.join(_add)} added to {obj.title}") display += f"+{', +'.join(_add)}"
if _remove: if _remove:
updated = True
self.query_data(getattr(obj, f"remove{attr.capitalize()}"), _remove) self.query_data(getattr(obj, f"remove{attr.capitalize()}"), _remove)
logger.info(f"Detail: {attr.capitalize()} {','.join(_remove)} removed to {obj.title}") display += f"-{', -'.join(_remove)}"
return updated if len(display) > 0:
logger.info(f"{obj.title[:25]:<25} | {attr.capitalize()} | {display}")
return len(display) > 0
def update_item_from_assets(self, item, overlay=None, create=False): def update_item_from_assets(self, item, overlay=None, create=False):
name = os.path.basename(os.path.dirname(str(item.locations[0])) if self.is_movie else str(item.locations[0])) name = os.path.basename(os.path.dirname(str(item.locations[0])) if self.is_movie else str(item.locations[0]))

View file

@ -366,18 +366,7 @@ def mass_metadata(config, library, items):
new_genres = tvdb_item.genres new_genres = tvdb_item.genres
else: else:
raise Failed raise Failed
item_genres = [genre.tag for genre in item.genres] library.edit_tags("genre", item, sync_tags=new_genres)
display_str = ""
add_genre = [genre for genre in (g for g in new_genres if g not in item_genres)]
if len(add_genre) > 0:
display_str += f"+{', +'.join(add_genre)}"
library.query_data(item.addGenre, add_genre)
remove_genre = [genre for genre in (g for g in item_genres if g not in new_genres)]
if len(remove_genre) > 0:
display_str += f"-{', -'.join(remove_genre)}"
library.query_data(item.removeGenre, remove_genre)
if len(display_str) > 0:
logger.info(util.adjust_space(f"{item.title[:25]:<25} | Genres | {display_str}"))
except Failed: except Failed:
pass pass
if library.mass_audience_rating_update: if library.mass_audience_rating_update: