use jwt for mpeg-ts streaming mode (#1661)

This commit is contained in:
Jason Dove
2024-03-29 21:36:49 -05:00
committed by GitHub
parent 7702999b9a
commit 4e56117e0e
6 changed files with 21 additions and 6 deletions
+1
View File
@@ -56,6 +56,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- This fix will require a one-time re-scan of each Plex library in full
- After the initial full scan, incremental scans will behave as normal
- Fix edge case where some local episodes, music videos, other videos, songs, images would not automatically be restored from trash
- Fix `MPEG-TS` playback when JWT tokens are enabled for streaming endpoints
### Changed
- Log search index updates under scanner category at debug level, to indicate a potential cause for the UI being out of date
@@ -2,7 +2,7 @@
public record GetWrappedProcessByChannelNumber : FFmpegProcessRequest
{
public GetWrappedProcessByChannelNumber(string scheme, string host, string channelNumber) : base(
public GetWrappedProcessByChannelNumber(string scheme, string host, string accessToken, string channelNumber) : base(
channelNumber,
"ts",
DateTimeOffset.Now,
@@ -12,8 +12,10 @@ public record GetWrappedProcessByChannelNumber : FFmpegProcessRequest
{
Scheme = scheme;
Host = host;
AccessToken = accessToken;
}
public string Scheme { get; }
public string Host { get; }
public string AccessToken { get; }
}
@@ -35,7 +35,8 @@ public class GetWrappedProcessByChannelNumberHandler : FFmpegProcessHandler<GetW
saveReports,
channel,
request.Scheme,
request.Host);
request.Host,
request.AccessToken);
return new PlayoutItemProcessModel(process, Option<TimeSpan>.None, DateTimeOffset.MaxValue, true);
}
@@ -724,12 +724,17 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
bool saveReports,
Channel channel,
string scheme,
string host)
string host,
string accessToken)
{
var resolution = new FrameSize(channel.FFmpegProfile.Resolution.Width, channel.FFmpegProfile.Resolution.Height);
string accessTokenQuery = string.IsNullOrWhiteSpace(accessToken)
? string.Empty
: $"&access_token={accessToken}";
var concatInputFile = new ConcatInputFile(
$"http://localhost:{Settings.ListenPort}/iptv/channel/{channel.Number}.m3u8?mode=segmenter",
$"http://localhost:{Settings.ListenPort}/iptv/channel/{channel.Number}.m3u8?mode=segmenter{accessTokenQuery}",
resolution);
IPipelineBuilder pipelineBuilder = await _pipelineBuilderFactory.GetBuilder(
@@ -60,7 +60,13 @@ public interface IFFmpegProcessService
string scheme,
string host);
Task<Command> WrapSegmenter(string ffmpegPath, bool saveReports, Channel channel, string scheme, string host);
Task<Command> WrapSegmenter(
string ffmpegPath,
bool saveReports,
Channel channel,
string scheme,
string host,
string accessToken);
Task<Command> ResizeImage(string ffmpegPath, string inputFile, string outputFile, int height);
+1 -1
View File
@@ -100,7 +100,7 @@ public class IptvController : ControllerBase
FFmpegProcessRequest request = mode switch
{
"ts-legacy" => new GetConcatProcessByChannelNumber(Request.Scheme, Request.Host.ToString(), channelNumber),
_ => new GetWrappedProcessByChannelNumber(Request.Scheme, Request.Host.ToString(), channelNumber)
_ => new GetWrappedProcessByChannelNumber(Request.Scheme, Request.Host.ToString(), Request.Query["access_token"], channelNumber)
};
return await _mediator.Send(request)