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'"
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user