From 331355e84672d4d79ee1517a3a181452e669988f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 3 Nov 2025 14:20:05 +0000 Subject: [PATCH] Fix KeyError: 'stream_count' in manage_channel_visibility Root cause: Lines 1414-1415 were trying to access non-existent fields 'stream_count' and 'attached' directly from channel objects. These values are actually stored in the channel_stream_counts dictionary and channels_attached_to_others set respectively. Changes: - Fixed field access to use correct data structures - Added error handling to check if channel exists in stream_counts - Added debug logging to show evaluation details for each channel - Added full traceback logging in exception handler for better debugging This fixes the error: "Error managing channel visibility: 'stream_count'" --- Stream-Mapparr/plugin.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Stream-Mapparr/plugin.py b/Stream-Mapparr/plugin.py index cf57663..c7806f2 100644 --- a/Stream-Mapparr/plugin.py +++ b/Stream-Mapparr/plugin.py @@ -1411,9 +1411,17 @@ class Plugin: for ch in group_channels: channel_id = ch['id'] channel_name = ch['name'] - stream_count = ch['stream_count'] - is_attached = ch['attached'] - + + # Get stream count from the dictionary we built earlier + if channel_id not in channel_stream_counts: + logger.warning(f"[Stream-Mapparr] Channel {channel_id} ({channel_name}) not found in stream counts, skipping") + continue + + stream_count = channel_stream_counts[channel_id]['stream_count'] + is_attached = channel_id in channels_attached_to_others + + logger.debug(f"[Stream-Mapparr] Evaluating {channel_name}: stream_count={stream_count}, is_attached={is_attached}, enabled_in_group={enabled_in_group}") + # Determine reason for enabling/disabling if is_attached: reason = 'Attached to another channel' @@ -1559,7 +1567,10 @@ class Plugin: } except Exception as e: + import traceback + error_details = traceback.format_exc() logger.error(f"[Stream-Mapparr] Error managing channel visibility: {str(e)}") + logger.error(f"[Stream-Mapparr] Full traceback:\n{error_details}") return {"status": "error", "message": f"Error managing channel visibility: {str(e)}"} def clear_csv_exports_action(self, settings, logger):