dates at bottom
This commit is contained in:
+23
-11
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user