From 8494f615d0ef2efca57d3f2f65ce03096868df94 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Sat, 18 Oct 2025 17:29:44 -0500 Subject: [PATCH] Bug fix: Use correct name if stream name is supposed to be used to build dummy. --- apps/output/views.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/output/views.py b/apps/output/views.py index c7a827fc..d683801d 100644 --- a/apps/output/views.py +++ b/apps/output/views.py @@ -905,9 +905,27 @@ def generate_epg(request, profile_name=None, user=None): # Use EPG data name for display, but channel name for pattern matching display_name = channel.epg_data.name if channel.epg_data else channel.name - # For dummy EPG pattern matching, always use the actual channel name + # For dummy EPG pattern matching, determine which name to use pattern_match_name = channel.name + # Check if we should use stream name instead of channel name + if channel.epg_data and channel.epg_data.epg_source: + epg_source = channel.epg_data.epg_source + if epg_source.custom_properties: + custom_props = epg_source.custom_properties + name_source = custom_props.get('name_source') + + if name_source == 'stream': + stream_index = custom_props.get('stream_index', 1) - 1 + channel_streams = channel.streams.all().order_by('channelstream__order') + + if channel_streams.exists() and 0 <= stream_index < channel_streams.count(): + stream = list(channel_streams)[stream_index] + pattern_match_name = stream.name + logger.debug(f"Using stream name for parsing: {pattern_match_name} (stream index: {stream_index})") + else: + logger.warning(f"Stream index {stream_index} not found for channel {channel.name}, falling back to channel name") + if not channel.epg_data: # Use the enhanced dummy EPG generation function with defaults program_length_hours = 4 # Default to 4-hour program blocks