From f3abbaeb27a2b2d80f34d7dac85f5d1e034de98f Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Sun, 4 May 2025 09:23:02 -0500 Subject: [PATCH] Add gracenote ID when creating channel if available. Fixes m3u output if gracenote ID doesn't exist. --- apps/channels/api_views.py | 5 +++++ apps/output/views.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/channels/api_views.py b/apps/channels/api_views.py index ab206afb..23d706ba 100644 --- a/apps/channels/api_views.py +++ b/apps/channels/api_views.py @@ -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], } diff --git a/apps/output/views.py b/apps/output/views.py index 5a5335d3..38b69bde 100644 --- a/apps/output/views.py +++ b/apps/output/views.py @@ -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