Browse Source

fix: use jwt in hls direct playlist (#2889)

* bump nvenc sharp

* fix: use jwt in hls direct playlist
pull/2891/head
Jason Dove 2 weeks ago committed by GitHub
parent
commit
0fc7ebb068
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 7
      ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumber.cs
  3. 9
      ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs
  4. 2
      ErsatzTV.FFmpeg/ErsatzTV.FFmpeg.csproj
  5. 3
      ErsatzTV/Controllers/IptvController.cs

2
CHANGELOG.md

@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. @@ -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

7
ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumber.cs

@ -2,5 +2,10 @@ @@ -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<Either<BaseError, string>>;

9
ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs

@ -33,11 +33,10 @@ public class GetHlsPlaylistByChannelNumberHandler : @@ -33,11 +33,10 @@ public class GetHlsPlaylistByChannelNumberHandler :
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
DateTimeOffset now = DateTimeOffset.Now;
Validation<BaseError, Parameters> 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<string> GetPlaylist(
TvContext dbContext,
GetHlsPlaylistByChannelNumber request,
Parameters parameters,
DateTimeOffset now)
@ -69,6 +68,10 @@ public class GetHlsPlaylistByChannelNumberHandler : @@ -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 : @@ -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}
";
}

2
ErsatzTV.FFmpeg/ErsatzTV.FFmpeg.csproj

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
<PackageReference Include="CliWrap" Version="3.10.1" />
<PackageReference Include="Hardware.Info" Version="101.1.1.1" />
<PackageReference Include="LanguageExt.Core" Version="4.4.9" />
<PackageReference Include="Lennox.NvEncSharp" Version="[2.0.0]" />
<PackageReference Include="Lennox.NvEncSharp" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="10.0.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.7" />
</ItemGroup>

3
ErsatzTV/Controllers/IptvController.cs

@ -275,7 +275,8 @@ public class IptvController : StreamingControllerBase @@ -275,7 +275,8 @@ public class IptvController : StreamingControllerBase
Request.Scheme,
Request.Host.ToString(),
channelNumber,
mode))
mode,
Request.Query["access_token"]))
.Map(r => r.Match<IActionResult>(
playlist => Content(playlist, "application/vnd.apple.mpegurl"),
error => BadRequest(error.Value)));

Loading…
Cancel
Save