Skip to content

Commit

Permalink
update sync labels
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Aug 20, 2021
1 parent 975ce56 commit ddc81cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
12 changes: 6 additions & 6 deletions modules/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def edit_item(self, item, name, item_type, edits, advanced=False):
return False

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
if add_tags or remove_tags or sync_tags:
_add_tags = add_tags if add_tags else []
Expand All @@ -760,14 +760,14 @@ def edit_tags(self, attr, obj, add_tags=None, remove_tags=None, sync_tags=None):
_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]
if _add:
updated = True
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:
updated = True
self.query_data(getattr(obj, f"remove{attr.capitalize()}"), _remove)
logger.info(f"Detail: {attr.capitalize()} {','.join(_remove)} removed to {obj.title}")
return updated
display += f"-{', -'.join(_remove)}"
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):
name = os.path.basename(os.path.dirname(str(item.locations[0])) if self.is_movie else str(item.locations[0]))
Expand Down
13 changes: 1 addition & 12 deletions plex_meta_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,7 @@ def mass_metadata(config, library, items):
new_genres = tvdb_item.genres
else:
raise Failed
item_genres = [genre.tag for genre in item.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}"))
library.edit_tags("genre", item, sync_tags=new_genres)
except Failed:
pass
if library.mass_audience_rating_update:
Expand Down

0 comments on commit ddc81cd

Please sign in to comment.