nfo fix again
This commit is contained in:
+18
-28
@@ -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
|
||||
<!-- Full existing NFO with title, plot, cast, etc. -->
|
||||
↓ NFOGuard processing
|
||||
<movie>
|
||||
<!-- Only NFOGuard fields - ALL EXISTING CONTENT LOST -->
|
||||
</movie>
|
||||
### 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
|
||||
<!-- Full existing NFO with title, plot, cast, etc. -->
|
||||
↓ NFOGuard processing
|
||||
<movie>
|
||||
<!-- NFOGuard comment and fields added -->
|
||||
<!-- ALL EXISTING CONTENT PRESERVED -->
|
||||
<title>Existing Title</title>
|
||||
<plot>Existing Plot</plot>
|
||||
<!-- ... existing content ... -->
|
||||
<dateadded>2025-09-14T13:37:14-04:00</dateadded>
|
||||
<lockdata>true</lockdata>
|
||||
</movie>
|
||||
```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
|
||||
|
||||
|
||||
+17
-13
@@ -50,19 +50,14 @@ class NFOManager:
|
||||
# Ensure root element is <movie>
|
||||
if movie.tag != "movie":
|
||||
raise ValueError("Root element is not <movie>")
|
||||
|
||||
# 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'<?xml version="1.0" encoding="utf-8"?>\n<!--{comment_text}-->\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}")
|
||||
|
||||
Reference in New Issue
Block a user