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