From ed03f23272f921099436c817fb4b916c96af54ec Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Wed, 24 Sep 2025 10:08:10 -0400 Subject: [PATCH] fix: Move NFOGuard comment to bottom with other fields Moved the NFOGuard source comment from the top of the XML file to just before our field additions at the bottom. This creates a clear separation showing where NFOGuard's modifications begin. Expected structure: [existing rich metadata] tt123 2024-08-20 2024-08-20T00:00:00+00:00 true --- core/nfo_manager.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/core/nfo_manager.py b/core/nfo_manager.py index 93f7464..fbaf6f9 100644 --- a/core/nfo_manager.py +++ b/core/nfo_manager.py @@ -186,6 +186,10 @@ class NFOManager: # Now append ALL NFOGuard fields at the VERY END of the file # Create elements and explicitly append them to ensure they're at the bottom + # Add NFOGuard comment marker as the first of our additions + nfoguard_comment = ET.Comment(f" NFOGuard - Source: {source} ") + movie.append(nfoguard_comment) + # Add IMDb uniqueid at the end (after all existing content) uniqueid = ET.Element("uniqueid", type="imdb", default="true") uniqueid.text = imdb_id @@ -220,23 +224,14 @@ class NFOManager: lockdata.text = "true" movie.append(lockdata) - # Add NFOGuard comment at the beginning - comment_text = f" Created by {self.manager_brand} - Source: {source} " - # Write file with proper formatting tree = ET.ElementTree(movie) ET.indent(tree, space=" ", level=0) - # Write to string first to add comment - import xml.etree.ElementTree as ET_temp - xml_str = ET.tostring(movie, encoding='unicode') - - # Add XML declaration and comment - full_xml = f'\n\n{xml_str}' - - # Write to file + # Write directly to file (comment is already embedded in XML) with open(nfo_path, 'w', encoding='utf-8') as f: - f.write(full_xml) + f.write('\n') + tree.write(f, encoding='unicode', xml_declaration=False) print(f"✅ Successfully created/updated movie NFO: {nfo_path}") print(f" IMDb ID: {imdb_id}, Date Added: {dateadded}, Source: {source}")