Fix #608 checks preferences before changing advance settings

pull/652/head
meisnate12 3 years ago
parent 6178667455
commit 914082aea4

@ -2074,10 +2074,11 @@ class CollectionBuilder:
path = path[:-1] if path.endswith(('/', '\\')) else path path = path[:-1] if path.endswith(('/', '\\')) else path
tvdb_paths.append((self.library.show_rating_key_map[item.ratingKey], path)) tvdb_paths.append((self.library.show_rating_key_map[item.ratingKey], path))
advance_edits = {} advance_edits = {}
prefs = [p.id for p in item.preferences()]
for method_name, method_data in self.item_details.items(): for method_name, method_data in self.item_details.items():
if method_name in plex.item_advance_keys: if method_name in plex.item_advance_keys:
key, options = plex.item_advance_keys[method_name] key, options = plex.item_advance_keys[method_name]
if getattr(item, key) != options[method_data]: if key in prefs and getattr(item, key) != options[method_data]:
advance_edits[key] = options[method_data] advance_edits[key] = options[method_data]
self.library.edit_item(item, item.title, self.collection_level.capitalize(), advance_edits, advanced=True) self.library.edit_item(item, item.title, self.collection_level.capitalize(), advance_edits, advanced=True)

@ -294,7 +294,6 @@ class MetadataFile(DataFile):
updated = False updated = False
edits = {} edits = {}
advance_edits = {}
def add_edit(name, current_item, group, alias, key=None, value=None, var_type="str"): def add_edit(name, current_item, group, alias, key=None, value=None, var_type="str"):
if value or name in alias: if value or name in alias:
@ -334,21 +333,6 @@ class MetadataFile(DataFile):
else: else:
logger.error(f"Metadata Error: {name} attribute is blank") logger.error(f"Metadata Error: {name} attribute is blank")
def add_advanced_edit(attr, obj, group, alias, new_agent=False):
key, options = plex.item_advance_keys[f"item_{attr}"]
if attr in alias:
if new_agent and self.library.agent not in plex.new_plex_agents:
logger.error(f"Metadata Error: {attr} attribute only works for with the New Plex Movie Agent and New Plex TV Agent")
elif group[alias[attr]]:
method_data = str(group[alias[attr]]).lower()
if method_data not in options:
logger.error(f"Metadata Error: {group[alias[attr]]} {attr} attribute invalid")
elif getattr(obj, key) != options[method_data]:
advance_edits[key] = options[method_data]
logger.info(f"Detail: {attr} updated to {method_data}")
else:
logger.error(f"Metadata Error: {attr} attribute is blank")
logger.info("") logger.info("")
util.separator() util.separator()
logger.info("") logger.info("")
@ -454,9 +438,21 @@ class MetadataFile(DataFile):
updated = True updated = True
advance_edits = {} advance_edits = {}
prefs = [p.id for p in item.preferences()]
for advance_edit in advance_tags_to_edit[self.library.type]: for advance_edit in advance_tags_to_edit[self.library.type]:
is_new_agent = advance_edit in ["metadata_language", "use_original_title"] key, options = plex.item_advance_keys[f"item_{advance_edit}"]
add_advanced_edit(advance_edit, item, meta, methods, new_agent=is_new_agent) if advance_edit in methods:
if advance_edit in ["metadata_language", "use_original_title"] and self.library.agent not in plex.new_plex_agents:
logger.error(f"Metadata Error: {advance_edit} attribute only works for with the New Plex Movie Agent and New Plex TV Agent")
elif meta[methods[advance_edit]]:
method_data = str(meta[methods[advance_edit]]).lower()
if method_data not in options:
logger.error(f"Metadata Error: {meta[methods[advance_edit]]} {advance_edit} attribute invalid")
elif key in prefs and getattr(item, key) != options[method_data]:
advance_edits[key] = options[method_data]
logger.info(f"Detail: {advance_edit} updated to {method_data}")
else:
logger.error(f"Metadata Error: {advance_edit} attribute is blank")
if self.library.edit_item(item, mapping_name, self.library.type, advance_edits, advanced=True): if self.library.edit_item(item, mapping_name, self.library.type, advance_edits, advanced=True):
updated = True updated = True

Loading…
Cancel
Save