From e502c3625bef95c64a0fd936e5d971bb5d7c7d21 Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Fri, 26 Sep 2025 08:52:26 -0400 Subject: [PATCH] fix: Resolve isinstance() TypeError and undefined variable errors Fixed two critical bugs in NFO processing: 1. isinstance() TypeError: Fixed XML comment detection in update_episode_nfo_preserving_name - ET.Comment is not a proper type for isinstance() - Added safer comment detection using type checking and string matching 2. Undefined variable: Fixed episode_filename reference in create_episode_nfo - Variable only defined in fallback case but referenced in all cases - Changed to use nfo_path.name which is always available These fixes resolve the errors preventing NFO file updates for existing long-named NFO files. --- VERSION | 2 +- core/nfo_manager.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index d615fd0..158c747 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.9.4 +1.9.5 diff --git a/core/nfo_manager.py b/core/nfo_manager.py index 33e222c..2c89215 100644 --- a/core/nfo_manager.py +++ b/core/nfo_manager.py @@ -685,7 +685,7 @@ class NFOManager: if episode.tag != "episodedetails": raise ValueError("Root element is not ") - print(f"📝 Updating standard NFO: {episode_filename}") + print(f"📝 Updating existing NFO: {nfo_path.name}") # Remove existing NFOGuard fields to re-add them at the bottom nfoguard_fields = ["aired", "dateadded", "season", "episode"] @@ -970,8 +970,11 @@ class NFOManager: episode.remove(existing_field) # Remove any existing NFOGuard comments - for child in episode: - if isinstance(child, ET.Comment): + for child in list(episode): + if hasattr(child, 'tag') and child.tag is ET.Comment: + if self.manager_brand in str(child): + episode.remove(child) + elif str(type(child)).find('Comment') != -1: if self.manager_brand in str(child): episode.remove(child)