diff --git a/CHANGELOG.md b/CHANGELOG.md index 52511f5f2..ded67e853 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Fixed +- Fix HLS Direct playback when JWT auth is also used ## [26.5.1] - 2026-05-08 ### Fixed diff --git a/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumber.cs b/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumber.cs index 9e100ac27..9d8348515 100644 --- a/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumber.cs +++ b/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumber.cs @@ -2,5 +2,10 @@ namespace ErsatzTV.Application.Streaming; -public record GetHlsPlaylistByChannelNumber(string Scheme, string Host, string ChannelNumber, string Mode) +public record GetHlsPlaylistByChannelNumber( + string Scheme, + string Host, + string ChannelNumber, + string Mode, + string AccessToken) : IRequest>; diff --git a/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs b/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs index 3bc675cb9..1c1b68536 100644 --- a/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs +++ b/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs @@ -33,11 +33,10 @@ public class GetHlsPlaylistByChannelNumberHandler : await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken); DateTimeOffset now = DateTimeOffset.Now; Validation validation = await Validate(dbContext, request, now, cancellationToken); - return await validation.Apply(parameters => GetPlaylist(dbContext, request, parameters, now)); + return await validation.Apply(parameters => GetPlaylist(request, parameters, now)); } private async Task GetPlaylist( - TvContext dbContext, GetHlsPlaylistByChannelNumber request, Parameters parameters, DateTimeOffset now) @@ -69,6 +68,10 @@ public class GetHlsPlaylistByChannelNumberHandler : }; } + string accessToken = string.IsNullOrWhiteSpace(request.AccessToken) + ? string.Empty + : $"&access_token={request.AccessToken}"; + long index = GetIndexForChannel(parameters.Channel, parameters.PlayoutItem); double timeRemaining = Math.Abs((parameters.PlayoutItem.FinishOffset - now).TotalSeconds); return $@"#EXTM3U @@ -77,7 +80,7 @@ public class GetHlsPlaylistByChannelNumberHandler : #EXT-X-MEDIA-SEQUENCE:{index} #EXT-X-DISCONTINUITY #EXTINF:{timeRemaining:F2}, -{request.Scheme}://{request.Host}/{endpoint}/{request.ChannelNumber}{extension}?index={index}{mode} +{request.Scheme}://{request.Host}/{endpoint}/{request.ChannelNumber}{extension}?index={index}{mode}{accessToken} "; } diff --git a/ErsatzTV.FFmpeg/ErsatzTV.FFmpeg.csproj b/ErsatzTV.FFmpeg/ErsatzTV.FFmpeg.csproj index 2eef97ebc..114ebb215 100644 --- a/ErsatzTV.FFmpeg/ErsatzTV.FFmpeg.csproj +++ b/ErsatzTV.FFmpeg/ErsatzTV.FFmpeg.csproj @@ -14,7 +14,7 @@ - + diff --git a/ErsatzTV/Controllers/IptvController.cs b/ErsatzTV/Controllers/IptvController.cs index 87247139d..bafd14ec4 100644 --- a/ErsatzTV/Controllers/IptvController.cs +++ b/ErsatzTV/Controllers/IptvController.cs @@ -275,7 +275,8 @@ public class IptvController : StreamingControllerBase Request.Scheme, Request.Host.ToString(), channelNumber, - mode)) + mode, + Request.Query["access_token"])) .Map(r => r.Match( playlist => Content(playlist, "application/vnd.apple.mpegurl"), error => BadRequest(error.Value)));