From 7fb07fcddf4e5763f0670c58bd6500c58758c665 Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Thu, 23 Oct 2025 10:53:35 -0400 Subject: [PATCH] fix: nfoguard data at bottom of file --- core/nfo_manager.py | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/core/nfo_manager.py b/core/nfo_manager.py index 5dd4854..3ba6cf8 100644 --- a/core/nfo_manager.py +++ b/core/nfo_manager.py @@ -509,22 +509,14 @@ class NFOManager: lockdata = ET.SubElement(season, "lockdata") lockdata.text = "true" - # Add NFOGuard comment at the beginning - comment_text = f" Created by {self.manager_brand} " + # Add NFOGuard comment at the bottom + comment = ET.Comment(f" Created by {self.manager_brand} ") + season.append(comment) # Write file with proper formatting tree = ET.ElementTree(season) ET.indent(tree, space=" ", level=0) - - # Write to string first to add comment - xml_str = ET.tostring(season, encoding='unicode') - - # Add XML declaration and comment - full_xml = f'\n\n{xml_str}' - - # Write to file - with open(nfo_path, 'w', encoding='utf-8') as f: - f.write(full_xml) + tree.write(nfo_path, encoding='utf-8', xml_declaration=True) print(f"✅ Successfully created/updated season NFO: {nfo_path}") print(f" Season: {season_number}") @@ -709,22 +701,14 @@ class NFOManager: lockdata = ET.SubElement(episode, "lockdata") lockdata.text = "true" - # Add NFOGuard comment at the beginning - comment_text = f" Created by {self.manager_brand} - Source: {source} " + # Add NFOGuard comment at the bottom + comment = ET.Comment(f" Created by {self.manager_brand} - Source: {source} ") + episode.append(comment) # Write file with proper formatting tree = ET.ElementTree(episode) ET.indent(tree, space=" ", level=0) - - # Write to string first to add comment - xml_str = ET.tostring(episode, encoding='unicode') - - # Add XML declaration and comment - full_xml = f'\n\n{xml_str}' - - # Write to file - with open(nfo_path, 'w', encoding='utf-8') as f: - f.write(full_xml) + tree.write(nfo_path, encoding='utf-8', xml_declaration=True) print(f"✅ Successfully created/updated episode NFO: {nfo_path}") print(f" S{season_num:02d}E{episode_num:02d}, Aired: {aired}, Date Added: {dateadded}")