fix: Resolve isinstance() TypeError and undefined variable errors
Local Docker Build (Dev) / build-dev (push) Successful in 29s

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.
This commit is contained in:
2025-09-26 08:52:26 -04:00
parent 5810877489
commit e502c3625b
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
1.9.4
1.9.5
+6 -3
View File
@@ -685,7 +685,7 @@ class NFOManager:
if episode.tag != "episodedetails":
raise ValueError("Root element is not <episodedetails>")
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)