diff --git a/SUMMARY.md b/SUMMARY.md
index 2d01f9d..09b87c9 100644
--- a/SUMMARY.md
+++ b/SUMMARY.md
@@ -1,37 +1,27 @@
# NFOGuard Development Summary
-## Current Status: v1.3.6 - NFO Preservation Fix
+## Current Status: v1.3.7 - NFO XML Parsing Fix
-### Latest Updates (v1.3.6)
-- **๐ง NFO MANAGER**: Fixed movie.nfo to preserve existing content instead of overwriting
-- **โ
PRESERVATION**: Existing movie metadata (title, plot, actors, etc.) now maintained
-- **๐ฏ TARGETED**: Only updates NFOGuard-managed fields (dateadded, uniqueid, lockdata)
-- **๐งน CLEANUP**: Removes old NFOGuard elements before adding new ones to avoid duplicates
+### Latest Updates (v1.3.7)
+- **๏ฟฝ FIXED**: XML comment parsing error causing NFO creation to fail
+- **๐ง XML HANDLING**: Improved XML comment insertion and file writing
+- **โ
PRESERVATION**: Existing movie metadata properly preserved during updates
+- **๐ฏ ROBUST**: Better error handling for malformed XML files
-### NFO Management Behavior (Fixed)
-**Before (v1.3.5 and earlier):**
-```xml
-
-โ NFOGuard processing
-
-
-
+### NFO Update Process (Fixed)
+```
+1. โ
Load existing movie.nfo (if exists)
+2. โ
Parse and validate XML structure
+3. โ
Remove old NFOGuard elements to avoid duplicates
+4. โ
Preserve all existing content (title, plot, cast, etc.)
+5. โ
Add/update NFOGuard fields (dateadded, lockdata, uniqueid)
+6. โ
Write properly formatted XML with comment
```
-**After (v1.3.6):**
-```xml
-
-โ NFOGuard processing
-
-
-
- Existing Title
- Existing Plot
-
- 2025-09-14T13:37:14-04:00
- true
-
-```lopment Summary
+### Error Resolution
+- **v1.3.6**: XML comment handling caused `'()` error
+- **v1.3.7**: Fixed comment insertion and XML serialization
+- **Result**: NFO files now update correctly while preserving contentlopment Summary
## Current Status: v1.3.3 - Database Migration & Path Validation Complete
diff --git a/VERSION b/VERSION
index 95b25ae..3336003 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.3.6
+1.3.7
diff --git a/core/nfo_manager.py b/core/nfo_manager.py
index f3c258a..0ca9f17 100644
--- a/core/nfo_manager.py
+++ b/core/nfo_manager.py
@@ -50,19 +50,14 @@ class NFOManager:
# Ensure root element is
if movie.tag != "movie":
raise ValueError("Root element is not ")
-
- # Remove existing NFOGuard elements to avoid duplicates
- for elem in movie.findall(".//comment()"):
- if elem is not None and "NFOGuard" in str(elem):
- movie.remove(elem)
- # Remove existing NFOGuard-managed elements
+ # Remove existing NFOGuard-managed elements to avoid duplicates
for tag in ["dateadded", "lockdata"]:
existing = movie.find(tag)
if existing is not None:
movie.remove(existing)
- # Remove any existing uniqueid with type="imdb"
+ # Remove any existing uniqueid with type="imdb"
for uniqueid in movie.findall("uniqueid[@type='imdb']"):
movie.remove(uniqueid)
@@ -73,10 +68,6 @@ class NFOManager:
# Create new NFO structure
movie = ET.Element("movie")
- # Add/update NFOGuard comment
- comment = ET.Comment(f" Created by {self.manager_brand} - Source: {source} ")
- movie.insert(0, comment)
-
# Add/update IMDb uniqueid
uniqueid = ET.SubElement(movie, "uniqueid", type="imdb", default="true")
uniqueid.text = imdb_id
@@ -96,10 +87,23 @@ class NFOManager:
lockdata = ET.SubElement(movie, "lockdata")
lockdata.text = "true"
- # Write file
+ # 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)
- tree.write(nfo_path, encoding="utf-8", xml_declaration=True)
+
+ # 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
+ with open(nfo_path, 'w', encoding='utf-8') as f:
+ f.write(full_xml)
except Exception as e:
print(f"Error creating/updating movie NFO {nfo_path}: {e}")