Add gracenote ID when creating channel if available. Fixes m3u output if gracenote ID doesn't exist.

This commit is contained in:
SergeantPanda 2025-05-04 09:23:02 -05:00
parent 2243e2470b
commit f3abbaeb27
2 changed files with 7 additions and 2 deletions

View file

@ -285,6 +285,10 @@ class ChannelViewSet(viewsets.ModelViewSet):
{"error": f"Channel number {channel_number} is already in use. Please choose a different number."},
status=status.HTTP_400_BAD_REQUEST
)
#Get the tvc_guide_stationid from custom properties if it exists
tvc_guide_stationid = None
if 'tvc-guide-stationid' in stream_custom_props:
tvc_guide_stationid = stream_custom_props['tvc-guide-stationid']
@ -292,6 +296,7 @@ class ChannelViewSet(viewsets.ModelViewSet):
'channel_number': channel_number,
'name': name,
'tvg_id': stream.tvg_id,
'tvc_guide_stationid': tvc_guide_stationid,
'channel_group_id': channel_group.id,
'streams': [stream_id],
}

View file

@ -30,10 +30,10 @@ def generate_m3u(request, profile_name=None):
tvg_logo = ""
if channel.logo:
tvg_logo = request.build_absolute_uri(reverse('api:channels:logo-cache', args=[channel.logo.id]))
# create possible gracenote id insertion
tvc_guide_stationid = ""
if len(channel.tvc_guide_stationid) > 0:
if channel.tvc_guide_stationid:
tvc_guide_stationid = f'tvc-guide-stationid="{channel.tvc_guide_stationid}" '
channel_number = channel.channel_number