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}")