Updated M3U stream URLs

Changed M3U urls to use proxy
This commit is contained in:
Dispatcharr 2025-03-17 15:06:47 -05:00
parent 7a7cd0711d
commit 505551f312
3 changed files with 8 additions and 4 deletions

View file

@ -12,5 +12,5 @@ urlpatterns = [
re_path(r'^epg/?$', generate_epg, name='generate_epg'),
# Allow both `/stream/<int:stream_id>` and `/stream/<int:stream_id>/`
re_path(r'^stream/(?P<stream_id>\d+)/?$', stream_view, name='stream'),
re_path(r'^stream/(?P<channel_uuid>[0-9a-fA-F\-]+)/?$', stream_view, name='stream'),
]

View file

@ -22,7 +22,11 @@ def generate_m3u(request):
f'#EXTINF:-1 tvg-id="{tvg_id}" tvg-name="{tvg_name}" tvg-logo="{tvg_logo}" '
f'tvg-chno="{channel_number}" group-title="{group_title}",{channel.name}\n'
)
stream_url = request.build_absolute_uri(reverse('output:stream', args=[channel.id]))
base_url = request.build_absolute_uri('/')[:-1]
stream_url = f"{base_url}/proxy/ts/stream/{channel.uuid}"
#stream_url = request.build_absolute_uri(reverse('output:stream', args=[channel.id]))
m3u_content += extinf_line + stream_url + "\n"
response = HttpResponse(m3u_content, content_type="application/x-mpegURL")

View file

@ -29,7 +29,7 @@ def settings_view(request):
return render(request, 'settings.html')
def stream_view(request, stream_id):
def stream_view(request, channel_uuid):
"""
Streams the first available stream for the given channel.
It uses the channels assigned StreamProfile.
@ -40,7 +40,7 @@ def stream_view(request, stream_id):
redis_client = redis.Redis(host=settings.REDIS_HOST, port=6379, db=int(getattr(settings, "REDIS_DB", "0")))
# Retrieve the channel by the provided stream_id.
channel = Channel.objects.get(channel_number=stream_id)
channel = Channel.objects.get(uuid=channel_uuid)
logger.debug("Channel retrieved: ID=%s, Name=%s", channel.id, channel.name)
# Ensure the channel has at least one stream.