dates at bottom

This commit is contained in:
2025-09-14 13:54:04 -04:00
parent 179f8f51d7
commit d7db924510
3 changed files with 46 additions and 30 deletions
+22 -18
View File
@@ -1,36 +1,40 @@
# NFOGuard Development Summary
## Current Status: v1.3.8 - NFO Field Ordering Fix
## Current Status: v1.4.0 - Complete Date Field Management
### Latest Updates (v1.3.8)
- **🎯 FIELD ORDERING**: NFOGuard fields now append at bottom of existing NFO content
- **📋 STRUCTURE**: Date fields (premiered, dateadded, lockdata) appear after all existing metadata
- **✅ PRESERVATION**: All existing content (actors, plot, ratings, etc.) maintained in original order
- **🧹 SMART CLEANUP**: Only removes NFOGuard-added elements, preserves existing uniqueid[tmdb]
### Latest Updates (v1.4.0)
- **🎯 ALL DATE FIELDS**: Now moves premiered, year, dateadded, and lockdata to bottom
- **📋 COMPREHENSIVE**: Removes existing premiered/year fields and re-adds at bottom
- **✅ PRESERVATION**: Preserves existing premiered date if no new release date provided
- **🧹 CLEAN STRUCTURE**: All date/metadata fields grouped together at bottom
### NFO Field Order (Fixed)
**Now places NFOGuard fields at the bottom:**
### Complete NFO Structure (Fixed)
```xml
<movie>
<!-- All existing Radarr/Jellyfin content preserved -->
<title>Movie Title</title>
<title>Annabelle Comes Home</title>
<plot>Plot content...</plot>
<uniqueid type="tmdb" default="true">521029</uniqueid> <!-- preserved -->
<genre>Horror</genre>
<director>Gary Dauberman</director>
<actor>...</actor>
<!-- ... all existing fields ... -->
<!-- ... all existing fields including all actors ... -->
<!-- NFOGuard fields appended at bottom -->
<!-- ALL date/metadata fields at absolute bottom -->
<uniqueid type="imdb" default="true">tt8350360</uniqueid>
<premiered>2019-06-26</premiered> <!-- only if missing -->
<dateadded>2025-09-14T13:45:54-04:00</dateadded>
<premiered>2019-06-26</premiered>
<year>2019</year>
<dateadded>2025-09-14T13:50:34-04:00</dateadded>
<lockdata>true</lockdata>
</movie>
```
### Smart Element Management
- Preserves existing `uniqueid[tmdb]` and other IDs
-Only removes NFOGuard-managed `uniqueid[imdb]` to avoid duplicates
-Appends new fields using `ET.SubElement()` for bottom placement
-Maintains clean XML structure and formatting
### NFOGuard Managed Fields
-`uniqueid[type="imdb"]` - IMDb ID for identification
-`premiered` - Release date (moved to bottom)
-`year` - Extracted from premiered date
-`dateadded` - Import timestamp
-`lockdata` - Prevents metadata overwrites
### Complete Path Processing Pipeline
-**Path Mapping**: Fixed substring matching (movies/movies6, tv/tv6)
+1 -1
View File
@@ -1 +1 @@
1.3.8
1.4.0
+23 -11
View File
@@ -52,17 +52,20 @@ class NFOManager:
raise ValueError("Root element is not <movie>")
# Remove existing NFOGuard-managed elements to avoid duplicates
# These will be re-added at the bottom
for tag in ["dateadded", "lockdata"]:
# These will be re-added at the very bottom
nfoguard_fields = ["dateadded", "lockdata", "premiered", "year"]
for tag in nfoguard_fields:
existing = movie.find(tag)
if existing is not None:
# Store the value before removing (for premiered/year)
if tag == "premiered" and not released:
released = existing.text # Preserve existing premiered date
movie.remove(existing)
# Remove any existing uniqueid with type="imdb" added by NFOGuard
# (Keep other uniqueid elements like tmdb)
# Remove ALL existing uniqueid with type="imdb" regardless of attributes
# We'll add a clean one at the bottom
for uniqueid in movie.findall("uniqueid[@type='imdb']"):
if uniqueid.get('default') == 'true':
movie.remove(uniqueid)
movie.remove(uniqueid)
except (ET.ParseError, ValueError) as e:
print(f"Warning: Could not parse existing NFO {nfo_path}, creating new: {e}")
@@ -71,17 +74,26 @@ class NFOManager:
# Create new NFO structure
movie = ET.Element("movie")
# Now append NFOGuard fields at the END of the file
# This ensures they appear after all existing content
# Now append ALL NFOGuard and date fields at the VERY END of the file
# This ensures they appear after all existing content including actors
# Add/update IMDb uniqueid at the end
# Add IMDb uniqueid at the end (after all existing content)
uniqueid = ET.SubElement(movie, "uniqueid", type="imdb", default="true")
uniqueid.text = imdb_id
# Add premiered if we have release date (only if not already present)
if released and movie.find("premiered") is None:
# Add premiered date at the bottom if we have it
if released:
premiered_elem = ET.SubElement(movie, "premiered")
premiered_elem.text = released[:10] if len(released) >= 10 else released
# Extract year from premiered date for consistency
try:
year_value = released[:4] if len(released) >= 4 else None
if year_value and year_value.isdigit():
year_elem = ET.SubElement(movie, "year")
year_elem.text = year_value
except:
pass # Skip year if we can't extract it
# Add dateadded at the end
if dateadded: