fix: Resolve isinstance() TypeError and undefined variable errors
Local Docker Build (Dev) / build-dev (push) Successful in 29s
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:
+6
-3
@@ -685,7 +685,7 @@ class NFOManager:
|
|||||||
if episode.tag != "episodedetails":
|
if episode.tag != "episodedetails":
|
||||||
raise ValueError("Root element is not <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
|
# Remove existing NFOGuard fields to re-add them at the bottom
|
||||||
nfoguard_fields = ["aired", "dateadded", "season", "episode"]
|
nfoguard_fields = ["aired", "dateadded", "season", "episode"]
|
||||||
@@ -970,8 +970,11 @@ class NFOManager:
|
|||||||
episode.remove(existing_field)
|
episode.remove(existing_field)
|
||||||
|
|
||||||
# Remove any existing NFOGuard comments
|
# Remove any existing NFOGuard comments
|
||||||
for child in episode:
|
for child in list(episode):
|
||||||
if isinstance(child, ET.Comment):
|
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):
|
if self.manager_brand in str(child):
|
||||||
episode.remove(child)
|
episode.remove(child)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user