From 724ca5168f387d62683fb6881788dd6c753951f3 Mon Sep 17 00:00:00 2001 From: Timothy Date: Tue, 14 Jul 2026 21:36:05 +0200 Subject: [PATCH 1/4] feat(jellyfin): add player-owned playback probe Add a Jellyfin 12 rc2 ILiveTvService probe that reads ErsatzTV guide/source data and returns native Jellyfin media sources while preserving the LiveTvChannel session item. Refs #357 Co-Authored-By: OpenAI Codex --- .../Configuration/PluginConfiguration.cs | 20 ++ .../Configuration/configPage.html | 62 ++++++ .../ErsatzTvClient.cs | 93 ++++++++ .../ErsatzTvContracts.cs | 99 +++++++++ .../ErsatzTvLiveTvService.cs | 207 ++++++++++++++++++ .../Jellyfin.Plugin.ChicoryTV.csproj | 27 +++ .../Jellyfin.Plugin.ChicoryTV/Plugin.cs | 44 ++++ .../Jellyfin.Plugin.ChicoryTV/README.md | 28 +++ .../ServiceRegistrator.cs | 17 ++ 9 files changed, 597 insertions(+) create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/PluginConfiguration.cs create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/configPage.html create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvClient.cs create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvContracts.cs create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvLiveTvService.cs create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Jellyfin.Plugin.ChicoryTV.csproj create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Plugin.cs create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/README.md create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ServiceRegistrator.cs diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/PluginConfiguration.cs b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/PluginConfiguration.cs new file mode 100644 index 000000000..d91e586d3 --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/PluginConfiguration.cs @@ -0,0 +1,20 @@ +using MediaBrowser.Model.Plugins; + +namespace Jellyfin.Plugin.ChicoryTV.Configuration; + +/// Configuration for the ErsatzTV connection. +public sealed class PluginConfiguration : BasePluginConfiguration +{ + /// Initializes a new instance of the class. + public PluginConfiguration() + { + BaseUrl = "http://localhost:8409"; + ApiKey = string.Empty; + } + + /// Gets or sets the ErsatzTV server base URL. + public string BaseUrl { get; set; } + + /// Gets or sets the ErsatzTV API key. + public string ApiKey { get; set; } +} diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/configPage.html b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/configPage.html new file mode 100644 index 000000000..00e0c12c3 --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/configPage.html @@ -0,0 +1,62 @@ + + + + + ChicoryTV + + +
+
+
+
+
+ + +
For example, http://localhost:8409
+
+
+ + +
Sent to ErsatzTV as X-Api-Key.
+
+
+ +
+
+
+
+ +
+ + diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvClient.cs b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvClient.cs new file mode 100644 index 000000000..13d137fc9 --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvClient.cs @@ -0,0 +1,93 @@ +using System.Globalization; +using System.Net.Http.Headers; +using System.Text.Json; + +namespace Jellyfin.Plugin.ChicoryTV; + +internal sealed class ErsatzTvClient : IDisposable +{ + private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web) + { + PropertyNameCaseInsensitive = true + }; + + private readonly HttpClient _httpClient = new(); + + public ErsatzTvClient() + { + } + + public Task GetGuideAsync( + DateTimeOffset? start, + DateTimeOffset? end, + CancellationToken cancellationToken) + { + var relativePath = "api/v1/guide"; + if (start.HasValue && end.HasValue) + { + relativePath += string.Create( + CultureInfo.InvariantCulture, + $"?start={Uri.EscapeDataString(start.Value.ToUniversalTime().ToString("O", CultureInfo.InvariantCulture))}" + + $"&end={Uri.EscapeDataString(end.Value.ToUniversalTime().ToString("O", CultureInfo.InvariantCulture))}"); + } + + return GetAsync(relativePath, cancellationToken); + } + + public Task GetPlaybackSourceAsync( + int channelId, + DateTimeOffset at, + CancellationToken cancellationToken) + { + string timestamp = Uri.EscapeDataString(at.ToUniversalTime().ToString("O", CultureInfo.InvariantCulture)); + return GetAsync( + string.Create( + CultureInfo.InvariantCulture, + $"api/v1/channels/{channelId}/playback-source?at={timestamp}"), + cancellationToken); + } + + public void Dispose() => _httpClient.Dispose(); + + private async Task GetAsync(string relativePath, CancellationToken cancellationToken) + { + var configuration = Plugin.Instance?.Configuration + ?? throw new InvalidOperationException("The ChicoryTV plugin has not been initialized."); + string configuredBaseUrl = configuration.BaseUrl?.Trim() ?? string.Empty; + if (!Uri.TryCreate(configuredBaseUrl.TrimEnd('/') + "/", UriKind.Absolute, out Uri? baseUri) + || (baseUri.Scheme != Uri.UriSchemeHttp && baseUri.Scheme != Uri.UriSchemeHttps)) + { + throw new InvalidOperationException("Configure an absolute HTTP or HTTPS ErsatzTV base URL."); + } + + using var request = new HttpRequestMessage(HttpMethod.Get, new Uri(baseUri, relativePath)); + request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + if (!string.IsNullOrWhiteSpace(configuration.ApiKey)) + { + request.Headers.TryAddWithoutValidation("X-Api-Key", configuration.ApiKey); + } + + using HttpResponseMessage response = await _httpClient.SendAsync( + request, + HttpCompletionOption.ResponseHeadersRead, + cancellationToken).ConfigureAwait(false); + if (!response.IsSuccessStatusCode) + { + string detail = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + if (detail.Length > 512) + { + detail = detail[..512]; + } + + throw new HttpRequestException( + $"ErsatzTV GET {request.RequestUri?.AbsolutePath} failed with {(int)response.StatusCode} " + + $"({response.ReasonPhrase}): {detail}", + null, + response.StatusCode); + } + + await using Stream body = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); + return await JsonSerializer.DeserializeAsync(body, JsonOptions, cancellationToken).ConfigureAwait(false) + ?? throw new JsonException($"ErsatzTV returned an empty {typeof(T).Name} response."); + } +} diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvContracts.cs b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvContracts.cs new file mode 100644 index 000000000..00cddfefc --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvContracts.cs @@ -0,0 +1,99 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Jellyfin.Plugin.ChicoryTV; + +[JsonConverter(typeof(JsonStringEnumConverter))] +public enum PlaybackSourceKind +{ + LocalFile, + JellyfinItem, + PlexItem, + EmbyItem, + RemoteUrl, + Unsupported +} + +public sealed class GuideResponse +{ + public DateTimeOffset Start { get; set; } + + public DateTimeOffset End { get; set; } + + public List Channels { get; set; } = []; +} + +public sealed class GuideChannel +{ + public int Id { get; set; } + + public string Number { get; set; } = string.Empty; + + public string Name { get; set; } = string.Empty; + + public List Programmes { get; set; } = []; +} + +public sealed class GuideProgramme +{ + public DateTimeOffset Start { get; set; } + + public DateTimeOffset Stop { get; set; } + + public string Title { get; set; } = string.Empty; + + public string? SubTitle { get; set; } + + public string? Category { get; set; } + + public JsonElement FillerKind { get; set; } +} + +public sealed class PlaybackSourceResponse +{ + public int ChannelId { get; set; } + + public int SourceChannelId { get; set; } + + public DateTimeOffset ResolvedAt { get; set; } + + public DateTimeOffset SourceAt { get; set; } + + public DateTimeOffset? NextTransitionAt { get; set; } + + public PlaybackItem? Active { get; set; } +} + +public sealed class PlaybackItem +{ + public int PlayoutItemId { get; set; } + + public int MediaItemId { get; set; } + + public DateTimeOffset Start { get; set; } + + public DateTimeOffset Finish { get; set; } + + public long InPointTicks { get; set; } + + public long CurrentOffsetTicks { get; set; } + + public long OutPointTicks { get; set; } + + public JsonElement FillerKind { get; set; } + + public PlaybackSourceReference Source { get; set; } = new(); +} + +public sealed class PlaybackSourceReference +{ + public PlaybackSourceKind Kind { get; set; } + + public string? ItemId { get; set; } + + public string? Path { get; set; } + + public string? Url { get; set; } + + public bool IsLive { get; set; } +} diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvLiveTvService.cs b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvLiveTvService.cs new file mode 100644 index 000000000..87c39e904 --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvLiveTvService.cs @@ -0,0 +1,207 @@ +using System.Globalization; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.LiveTv; +using Microsoft.Extensions.Logging; + +namespace Jellyfin.Plugin.ChicoryTV; + +internal sealed class ErsatzTvLiveTvService : ILiveTvService +{ + private const string ReadOnlyMessage = "ChicoryTV is a read-only Live TV probe and does not support timers."; + + private readonly ErsatzTvClient _client; + private readonly ILibraryManager _libraryManager; + private readonly IMediaSourceManager _mediaSourceManager; + private readonly ILogger _logger; + + public ErsatzTvLiveTvService( + ErsatzTvClient client, + ILibraryManager libraryManager, + IMediaSourceManager mediaSourceManager, + ILogger logger) + { + _client = client; + _libraryManager = libraryManager; + _mediaSourceManager = mediaSourceManager; + _logger = logger; + } + + public string Name => "ChicoryTV"; + + public string HomePageUrl => "https://github.com/ErsatzTV/ErsatzTV"; + + public async Task> GetChannelsAsync(CancellationToken cancellationToken) + { + GuideResponse guide = await _client.GetGuideAsync(null, null, cancellationToken).ConfigureAwait(false); + return guide.Channels.Select(channel => new ChannelInfo + { + Id = channel.Id.ToString(CultureInfo.InvariantCulture), + Number = channel.Number, + Name = channel.Name, + ChannelType = ChannelType.TV + }).ToList(); + } + + public async Task> GetProgramsAsync( + string channelId, + DateTime startDateUtc, + DateTime endDateUtc, + CancellationToken cancellationToken) + { + if (!int.TryParse(channelId, NumberStyles.None, CultureInfo.InvariantCulture, out int parsedChannelId)) + { + return Array.Empty(); + } + + DateTimeOffset start = new(DateTime.SpecifyKind(startDateUtc, DateTimeKind.Utc)); + DateTimeOffset end = new(DateTime.SpecifyKind(endDateUtc, DateTimeKind.Utc)); + GuideResponse guide = await _client.GetGuideAsync(start, end, cancellationToken).ConfigureAwait(false); + GuideChannel? channel = guide.Channels.FirstOrDefault(candidate => candidate.Id == parsedChannelId); + if (channel is null) + { + return Array.Empty(); + } + + return channel.Programmes + .Where(programme => programme.Stop > start && programme.Start < end) + .Select(programme => new ProgramInfo + { + Id = string.Create( + CultureInfo.InvariantCulture, + $"{channel.Id}:{programme.Start.UtcDateTime.Ticks}"), + ChannelId = channelId, + Name = programme.Title, + EpisodeTitle = programme.SubTitle, + StartDate = programme.Start.UtcDateTime, + EndDate = programme.Stop.UtcDateTime, + Genres = string.IsNullOrWhiteSpace(programme.Category) ? [] : [programme.Category] + }) + .ToList(); + } + + public async Task> GetChannelStreamMediaSources( + string channelId, + CancellationToken cancellationToken) + { + ResolvedMediaSources resolved = await ResolveMediaSourcesAsync( + channelId, + "resolving", + cancellationToken).ConfigureAwait(false); + return resolved.Sources; + } + + public async Task GetChannelStream( + string channelId, + string streamId, + CancellationToken cancellationToken) + { + ResolvedMediaSources resolved = await ResolveMediaSourcesAsync( + channelId, + "opening", + cancellationToken).ConfigureAwait(false); + MediaSourceInfo? source = string.IsNullOrWhiteSpace(streamId) + ? resolved.Sources.FirstOrDefault() + : resolved.Sources.FirstOrDefault( + candidate => string.Equals(candidate.Id, streamId, StringComparison.OrdinalIgnoreCase)); + return source + ?? throw new InvalidOperationException( + $"Jellyfin media source '{streamId}' is no longer available for ErsatzTV channel {channelId}."); + } + + public Task CloseLiveStream(string id, CancellationToken cancellationToken) => Task.CompletedTask; + + public Task ResetTuner(string id, CancellationToken cancellationToken) => Task.CompletedTask; + + public Task> GetTimersAsync(CancellationToken cancellationToken) => + Task.FromResult>(Array.Empty()); + + public Task> GetSeriesTimersAsync(CancellationToken cancellationToken) => + Task.FromResult>(Array.Empty()); + + public Task GetNewTimerDefaultsAsync( + CancellationToken cancellationToken, + ProgramInfo? program = null) => NotSupported(); + + public Task CancelTimerAsync(string timerId, CancellationToken cancellationToken) => NotSupported(); + + public Task CancelSeriesTimerAsync(string timerId, CancellationToken cancellationToken) => NotSupported(); + + public Task CreateTimerAsync(TimerInfo info, CancellationToken cancellationToken) => NotSupported(); + + public Task CreateSeriesTimerAsync(SeriesTimerInfo info, CancellationToken cancellationToken) => NotSupported(); + + public Task UpdateTimerAsync(TimerInfo updatedTimer, CancellationToken cancellationToken) => NotSupported(); + + public Task UpdateSeriesTimerAsync(SeriesTimerInfo info, CancellationToken cancellationToken) => NotSupported(); + + private static Task NotSupported() => Task.FromException(new NotSupportedException(ReadOnlyMessage)); + + private static Task NotSupported() => Task.FromException(new NotSupportedException(ReadOnlyMessage)); + + private async Task ResolveMediaSourcesAsync( + string channelId, + string operation, + CancellationToken cancellationToken) + { + if (!int.TryParse(channelId, NumberStyles.None, CultureInfo.InvariantCulture, out int parsedChannelId)) + { + throw new InvalidOperationException($"ErsatzTV channel id '{channelId}' is not an integer."); + } + + PlaybackSourceResponse response = await _client.GetPlaybackSourceAsync( + parsedChannelId, + DateTimeOffset.UtcNow, + cancellationToken).ConfigureAwait(false); + PlaybackItem active = response.Active + ?? throw new InvalidOperationException( + $"ErsatzTV channel {channelId} has no active playout item at {response.ResolvedAt:O}."); + if (active.Source.Kind != PlaybackSourceKind.JellyfinItem) + { + throw new NotSupportedException( + $"ErsatzTV source kind '{active.Source.Kind}' is not supported by this probe; only JellyfinItem is supported."); + } + + if (!Guid.TryParse(active.Source.ItemId, out Guid jellyfinItemId)) + { + throw new InvalidOperationException( + $"ErsatzTV returned invalid Jellyfin item id '{active.Source.ItemId}' for channel {channelId}."); + } + + var item = _libraryManager.GetItemById(jellyfinItemId) + ?? throw new InvalidOperationException( + $"Jellyfin library item {active.Source.ItemId} referenced by ErsatzTV channel {channelId} was not found."); + IReadOnlyList nativeSources = await _mediaSourceManager.GetPlaybackMediaSources( + item, + null, + true, + true, + cancellationToken).ConfigureAwait(false); + List sources = nativeSources.Where(source => !source.RequiresOpening).ToList(); + if (sources.Count != nativeSources.Count) + { + _logger.LogWarning( + "ChicoryTV omitted {Count} native media source(s) that require nested dynamic opening; this first probe supports directly usable Jellyfin media sources only.", + nativeSources.Count - sources.Count); + } + + if (sources.Count == 0) + { + throw new NotSupportedException( + $"Jellyfin item {active.Source.ItemId} has no native media source usable without dynamic opening."); + } + + _logger.LogInformation( + "ChicoryTV {Operation} ErsatzTV channel {ChannelId} as Jellyfin item {JellyfinItemId}; " + + "schedule-derived CurrentOffsetTicks={CurrentOffsetTicks}. ILiveTvService has no playback-offset parameter.", + operation, + response.ChannelId, + active.Source.ItemId, + active.CurrentOffsetTicks); + + return new ResolvedMediaSources(sources); + } + + private sealed record ResolvedMediaSources(List Sources); +} diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Jellyfin.Plugin.ChicoryTV.csproj b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Jellyfin.Plugin.ChicoryTV.csproj new file mode 100644 index 000000000..3b35c7154 --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Jellyfin.Plugin.ChicoryTV.csproj @@ -0,0 +1,27 @@ + + + + net10.0 + Jellyfin.Plugin.ChicoryTV + Jellyfin.Plugin.ChicoryTV + 0.1.0.0 + enable + enable + false + + + + + runtime + + + runtime + + + + + + + + + diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Plugin.cs b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Plugin.cs new file mode 100644 index 000000000..3b79cd3e7 --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Plugin.cs @@ -0,0 +1,44 @@ +using System.Globalization; +using Jellyfin.Plugin.ChicoryTV.Configuration; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Plugins; +using MediaBrowser.Model.Plugins; +using MediaBrowser.Model.Serialization; + +namespace Jellyfin.Plugin.ChicoryTV; + +/// The ChicoryTV Jellyfin plugin. +public sealed class Plugin : BasePlugin, IHasWebPages +{ + /// Initializes a new instance of the class. + public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) + : base(applicationPaths, xmlSerializer) + { + Instance = this; + } + + /// + public override string Name => "ChicoryTV"; + + /// + public override string Description => "Read-only ErsatzTV guide and Jellyfin-owned Live TV playback probe."; + + /// + public override Guid Id => Guid.Parse("3e2c64db-7f24-4bf4-b388-d4aa27f93aa8"); + + /// Gets the active plugin instance. + public static Plugin? Instance { get; private set; } + + /// + public IEnumerable GetPages() => + [ + new PluginPageInfo + { + Name = Name, + EmbeddedResourcePath = string.Format( + CultureInfo.InvariantCulture, + "{0}.Configuration.configPage.html", + GetType().Namespace) + } + ]; +} diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/README.md b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/README.md new file mode 100644 index 000000000..dec0b2d78 --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/README.md @@ -0,0 +1,28 @@ +# ChicoryTV Jellyfin 12 rc2 probe + +This standalone, read-only plugin proves the narrow Jellyfin-owned playback path for ErsatzTV issue #357. It imports ErsatzTV's JSON guide as an `ILiveTvService`. When a channel is opened, it resolves the scheduled `JellyfinItem` and returns that library item's native `MediaSourceInfo` objects so Jellyfin remains responsible for direct-play/transcode negotiation. The requested item and session remain the Jellyfin `LiveTvChannel`; the underlying library item is never returned as the client-facing item. + +## Build and install + +The project deliberately is not part of `ErsatzTV.sln`. It targets `net10.0` and pins both `Jellyfin.Controller` and `Jellyfin.Model` to exactly `12.0.0-rc2`, excluding their runtime assets as the official plugin template does. + +```shell +dotnet build integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Jellyfin.Plugin.ChicoryTV.csproj +``` + +Copy `bin/Debug/net10.0/Jellyfin.Plugin.ChicoryTV.dll` (and the PDB when debugging) into its own directory below Jellyfin's plugins directory, then restart Jellyfin. In Dashboard > Plugins > ChicoryTV, configure the ErsatzTV base URL and API key. Refresh Jellyfin's Live TV guide after changing the connection. + +The ErsatzTV side must provide: + +- `GET /api/v1/guide`, with `Start`, `End`, and `Channels`; each channel has `Id`, `Number`, `Name`, and `Programmes`. +- `GET /api/v1/channels/{id}/playback-source?at=...`, with the schedule-derived source contract described by issue #357. The plugin sends the configured key in `X-Api-Key`. + +## Probe limitations + +- Only `Source.Kind == JellyfinItem` is accepted. Local files, URLs, Plex, Emby, and unknown kinds fail explicitly; there is no proxy or ErsatzTV transcode fallback. +- Native sources that require a nested dynamic-open operation are omitted. This first probe is for directly usable native Jellyfin library media sources. +- `ILiveTvService` source resolution has no user parameter. This probe performs a non-user-aware library lookup, so administrators must not treat Live TV channel access as authorization for otherwise restricted backing items. +- Jellyfin normalizes non-default Live TV sources as infinite/interlaced-capable and enables transcoding. Those stock-server mutations can affect negotiation even though the source metadata originates from the native library item. +- The schedule-derived `CurrentOffsetTicks` is logged when resolving/opening, but it is not applied. The exact stock Jellyfin client sends `StartTimeTicks=0`, and `ILiveTvService` has no offset parameter. This probe makes no claim that Jellyfin consumes the logged offset. +- A finite library file reaching EOF does not retune the channel. There is no continuous stream or transition engine. +- Timer reads are empty and all timer mutations are unsupported. There is no recording, Kodi work, ErsatzTV FFmpeg process, or deployment automation. The plugin does not mutate the underlying item's watch history; Jellyfin may still record its normal session/user data against the `LiveTvChannel`. diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ServiceRegistrator.cs b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ServiceRegistrator.cs new file mode 100644 index 000000000..bb32a58a5 --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ServiceRegistrator.cs @@ -0,0 +1,17 @@ +using MediaBrowser.Controller; +using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Controller.Plugins; +using Microsoft.Extensions.DependencyInjection; + +namespace Jellyfin.Plugin.ChicoryTV; + +/// Registers the plugin's Live TV service. +public sealed class ServiceRegistrator : IPluginServiceRegistrator +{ + /// + public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost) + { + serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); + } +} -- 2.47.3 From dd4ce6f378ac7903c9ac0a79282753b0736786e3 Mon Sep 17 00:00:00 2001 From: Timothy Date: Tue, 14 Jul 2026 21:44:07 +0200 Subject: [PATCH 2/4] feat(api): resolve scheduled playback sources Add an authenticated playback-source endpoint for player-owned playback and document the Jellyfin Live TV proof-of-concept boundary. Cache guide snapshots for the probe plugin while leaving native Jellyfin source handling in control. Refs #357 Co-Authored-By: OpenAI Codex --- .../Queries/GetChannelGuideDataHandler.cs | 1 + .../Queries/GetChannelPlaybackSource.cs | 6 + .../GetChannelPlaybackSourceHandler.cs | 168 +++++++++++ .../Api/Channels/ChannelGuideResponseModel.cs | 1 + .../ChannelPlaybackSourceResponseModel.cs | 47 ++++ .../GetChannelGuideDataHandlerTests.cs | 1 + .../GetChannelPlaybackSourceHandlerTests.cs | 264 ++++++++++++++++++ .../Controllers/ChannelControllerTests.cs | 23 ++ ErsatzTV/Controllers/Api/ChannelController.cs | 23 ++ ErsatzTV/wwwroot/openapi/v1.json | 242 ++++++++++++++++ docs/README.md | 2 + docs/endpoint-index.md | 3 +- docs/player-owned-playback-poc.md | 142 ++++++++++ .../ErsatzTvClient.cs | 66 ++++- .../Jellyfin.Plugin.ChicoryTV/README.md | 1 + web/src/api/generated/v1.d.ts | 28 ++ 16 files changed, 1007 insertions(+), 11 deletions(-) create mode 100644 ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSource.cs create mode 100644 ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSourceHandler.cs create mode 100644 ErsatzTV.Core/Api/Channels/ChannelPlaybackSourceResponseModel.cs create mode 100644 ErsatzTV.Tests/Application/Channels/GetChannelPlaybackSourceHandlerTests.cs create mode 100644 docs/player-owned-playback-poc.md diff --git a/ErsatzTV.Application/Channels/Queries/GetChannelGuideDataHandler.cs b/ErsatzTV.Application/Channels/Queries/GetChannelGuideDataHandler.cs index b4294b068..5388724af 100644 --- a/ErsatzTV.Application/Channels/Queries/GetChannelGuideDataHandler.cs +++ b/ErsatzTV.Application/Channels/Queries/GetChannelGuideDataHandler.cs @@ -119,6 +119,7 @@ public class GetChannelGuideDataHandler( responseChannels.Add( new ChannelGuideChannelResponseModel( + channel.Id, channel.Number, channel.Name, programmes.OrderBy(p => p.Start).ToList())); diff --git a/ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSource.cs b/ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSource.cs new file mode 100644 index 000000000..a457d9f2d --- /dev/null +++ b/ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSource.cs @@ -0,0 +1,6 @@ +using ErsatzTV.Core.Api.Channels; + +namespace ErsatzTV.Application.Channels; + +public record GetChannelPlaybackSource(int ChannelId, DateTimeOffset At) + : IRequest>; diff --git a/ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSourceHandler.cs b/ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSourceHandler.cs new file mode 100644 index 000000000..6d559a7a6 --- /dev/null +++ b/ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSourceHandler.cs @@ -0,0 +1,168 @@ +#nullable enable +using ErsatzTV.Core.Api.Channels; +using ErsatzTV.Core.Domain; +using ErsatzTV.Infrastructure.Data; +using Microsoft.EntityFrameworkCore; + +namespace ErsatzTV.Application.Channels; + +/// +/// Resolves the physical playout item at a point in time without invoking the streaming or FFmpeg pipeline. +/// Guide projection is deliberately not used here: guide entries may merge filler or split a block differently +/// from the actual media-item boundaries a player must follow. +/// +public class GetChannelPlaybackSourceHandler(IDbContextFactory dbContextFactory) + : IRequestHandler> +{ + public async Task> Handle( + GetChannelPlaybackSource request, + CancellationToken cancellationToken) + { + await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); + + Channel? channel = await dbContext.Channels + .AsNoTracking() + .SingleOrDefaultAsync(c => c.Id == request.ChannelId, cancellationToken); + + if (channel is null) + { + return None; + } + + int sourceChannelId = channel.PlayoutSource == ChannelPlayoutSource.Mirror + ? channel.MirrorSourceChannelId ?? channel.Id + : channel.Id; + TimeSpan playoutOffset = channel.PlayoutSource == ChannelPlayoutSource.Mirror + ? channel.PlayoutOffset ?? TimeSpan.Zero + : TimeSpan.Zero; + DateTime sourceAtUtc = request.At.UtcDateTime - playoutOffset; + + PlayoutItem? active = await ActiveItems(dbContext, sourceChannelId, sourceAtUtc) + .OrderBy(pi => pi.Start) + .FirstOrDefaultAsync(cancellationToken); + + DateTime? nextSourceTransition = active?.Finish; + if (nextSourceTransition is null) + { + nextSourceTransition = await dbContext.PlayoutItems + .AsNoTracking() + .Where(pi => pi.Playout.ChannelId == sourceChannelId && pi.Start > sourceAtUtc) + .OrderBy(pi => pi.Start) + .Select(pi => (DateTime?)pi.Start) + .FirstOrDefaultAsync(cancellationToken); + } + + DateTimeOffset resolvedAt = request.At.ToUniversalTime(); + DateTimeOffset sourceAt = new(sourceAtUtc, TimeSpan.Zero); + DateTimeOffset? nextTransitionAt = nextSourceTransition.HasValue + ? new DateTimeOffset(nextSourceTransition.Value + playoutOffset, TimeSpan.Zero) + : null; + + ChannelPlaybackItemResponseModel? playbackItem = active is null + ? null + : ToPlaybackItem(active, sourceAtUtc, playoutOffset); + + return new ChannelPlaybackSourceResponseModel( + channel.Id, + sourceChannelId, + resolvedAt, + sourceAt, + nextTransitionAt, + playbackItem); + } + + private static IQueryable ActiveItems(TvContext dbContext, int sourceChannelId, DateTime sourceAtUtc) => + dbContext.PlayoutItems + .AsNoTracking() + .Where(pi => pi.Playout.ChannelId == sourceChannelId) + .Where(pi => pi.Start <= sourceAtUtc && pi.Finish > sourceAtUtc) + .Include(pi => pi.MediaItem) + .ThenInclude(mi => (mi as Movie)!.MediaVersions) + .ThenInclude(mv => mv.MediaFiles) + .Include(pi => pi.MediaItem) + .ThenInclude(mi => (mi as Episode)!.MediaVersions) + .ThenInclude(mv => mv.MediaFiles) + .Include(pi => pi.MediaItem) + .ThenInclude(mi => (mi as MusicVideo)!.MediaVersions) + .ThenInclude(mv => mv.MediaFiles) + .Include(pi => pi.MediaItem) + .ThenInclude(mi => (mi as OtherVideo)!.MediaVersions) + .ThenInclude(mv => mv.MediaFiles) + .Include(pi => pi.MediaItem) + .ThenInclude(mi => (mi as Song)!.MediaVersions) + .ThenInclude(mv => mv.MediaFiles) + .Include(pi => pi.MediaItem) + .ThenInclude(mi => (mi as Image)!.MediaVersions) + .ThenInclude(mv => mv.MediaFiles) + .Include(pi => pi.MediaItem) + .ThenInclude(mi => (mi as RemoteStream)!.MediaVersions) + .ThenInclude(mv => mv.MediaFiles) + .AsSplitQuery(); + + private static ChannelPlaybackItemResponseModel ToPlaybackItem( + PlayoutItem item, + DateTime sourceAtUtc, + TimeSpan playoutOffset) + { + TimeSpan currentOffset = item.InPoint + (sourceAtUtc - item.Start); + if (currentOffset < item.InPoint) + { + currentOffset = item.InPoint; + } + + if (item.OutPoint > item.InPoint && currentOffset > item.OutPoint) + { + currentOffset = item.OutPoint; + } + + return new ChannelPlaybackItemResponseModel( + item.Id, + item.MediaItemId, + new DateTimeOffset(item.Start + playoutOffset, TimeSpan.Zero), + new DateTimeOffset(item.Finish + playoutOffset, TimeSpan.Zero), + item.InPoint.Ticks, + currentOffset.Ticks, + item.OutPoint.Ticks, + item.FillerKind, + GetSourceReference(item.MediaItem)); + } + + private static ChannelPlaybackSourceReferenceResponseModel GetSourceReference(MediaItem mediaItem) => + mediaItem switch + { + JellyfinMovie movie => Reference(ChannelPlaybackSourceKind.JellyfinItem, itemId: movie.ItemId), + JellyfinEpisode episode => Reference(ChannelPlaybackSourceKind.JellyfinItem, itemId: episode.ItemId), + PlexMovie movie => Reference(ChannelPlaybackSourceKind.PlexItem, itemId: movie.Key), + PlexEpisode episode => Reference(ChannelPlaybackSourceKind.PlexItem, itemId: episode.Key), + PlexOtherVideo video => Reference(ChannelPlaybackSourceKind.PlexItem, itemId: video.Key), + EmbyMovie movie => Reference(ChannelPlaybackSourceKind.EmbyItem, itemId: movie.ItemId), + EmbyEpisode episode => Reference(ChannelPlaybackSourceKind.EmbyItem, itemId: episode.ItemId), + RemoteStream stream => Reference( + ChannelPlaybackSourceKind.RemoteUrl, + url: stream.Url, + isLive: stream.IsLive), + Movie movie => LocalFile(movie.MediaVersions), + Episode episode => LocalFile(episode.MediaVersions), + MusicVideo video => LocalFile(video.MediaVersions), + OtherVideo video => LocalFile(video.MediaVersions), + Song song => LocalFile(song.MediaVersions), + Image image => LocalFile(image.MediaVersions), + _ => Reference(ChannelPlaybackSourceKind.Unsupported) + }; + + private static ChannelPlaybackSourceReferenceResponseModel LocalFile(IEnumerable versions) + { + string? path = versions.FirstOrDefault()?.MediaFiles.FirstOrDefault()?.Path; + return string.IsNullOrWhiteSpace(path) + ? Reference(ChannelPlaybackSourceKind.Unsupported) + : Reference(ChannelPlaybackSourceKind.LocalFile, path: path); + } + + private static ChannelPlaybackSourceReferenceResponseModel Reference( + ChannelPlaybackSourceKind kind, + string? itemId = null, + string? path = null, + string? url = null, + bool isLive = false) => + new(kind, itemId, path, url, isLive); +} diff --git a/ErsatzTV.Core/Api/Channels/ChannelGuideResponseModel.cs b/ErsatzTV.Core/Api/Channels/ChannelGuideResponseModel.cs index cc968cff0..31cfb857b 100644 --- a/ErsatzTV.Core/Api/Channels/ChannelGuideResponseModel.cs +++ b/ErsatzTV.Core/Api/Channels/ChannelGuideResponseModel.cs @@ -14,6 +14,7 @@ public record ChannelGuideProgrammeResponseModel( /// One channel's guide programmes for the requested window. public record ChannelGuideChannelResponseModel( + int Id, string Number, string Name, List Programmes); diff --git a/ErsatzTV.Core/Api/Channels/ChannelPlaybackSourceResponseModel.cs b/ErsatzTV.Core/Api/Channels/ChannelPlaybackSourceResponseModel.cs new file mode 100644 index 000000000..29b289450 --- /dev/null +++ b/ErsatzTV.Core/Api/Channels/ChannelPlaybackSourceResponseModel.cs @@ -0,0 +1,47 @@ +#nullable enable +using ErsatzTV.Core.Domain.Filler; + +namespace ErsatzTV.Core.Api.Channels; + +/// The kind of source selected by the channel schedule. +public enum ChannelPlaybackSourceKind +{ + LocalFile, + JellyfinItem, + PlexItem, + EmbyItem, + RemoteUrl, + Unsupported +} + +/// A token-free reference to the scheduled media source. +public record ChannelPlaybackSourceReferenceResponseModel( + ChannelPlaybackSourceKind Kind, + string? ItemId, + string? Path, + string? Url, + bool IsLive); + +/// The physical playout item covering the requested channel time. +public record ChannelPlaybackItemResponseModel( + int PlayoutItemId, + int MediaItemId, + DateTimeOffset Start, + DateTimeOffset Finish, + long InPointTicks, + long CurrentOffsetTicks, + long OutPointTicks, + FillerKind FillerKind, + ChannelPlaybackSourceReferenceResponseModel Source); + +/// +/// Resolves a viewer-facing channel time to the physical media item selected by the schedule. +/// This is intentionally playback-engine neutral and never starts an ErsatzTV transcoder. +/// +public record ChannelPlaybackSourceResponseModel( + int ChannelId, + int SourceChannelId, + DateTimeOffset ResolvedAt, + DateTimeOffset SourceAt, + DateTimeOffset? NextTransitionAt, + ChannelPlaybackItemResponseModel? Active); diff --git a/ErsatzTV.Tests/Application/Channels/GetChannelGuideDataHandlerTests.cs b/ErsatzTV.Tests/Application/Channels/GetChannelGuideDataHandlerTests.cs index 806c7a64d..8bc3c7603 100644 --- a/ErsatzTV.Tests/Application/Channels/GetChannelGuideDataHandlerTests.cs +++ b/ErsatzTV.Tests/Application/Channels/GetChannelGuideDataHandlerTests.cs @@ -61,6 +61,7 @@ public class GetChannelGuideDataHandlerTests CancellationToken.None); result.Channels.Select(c => c.Number).ShouldBe(["2"]); + result.Channels.Single().Id.ShouldBeGreaterThan(0); } [Test] diff --git a/ErsatzTV.Tests/Application/Channels/GetChannelPlaybackSourceHandlerTests.cs b/ErsatzTV.Tests/Application/Channels/GetChannelPlaybackSourceHandlerTests.cs new file mode 100644 index 000000000..7e5588114 --- /dev/null +++ b/ErsatzTV.Tests/Application/Channels/GetChannelPlaybackSourceHandlerTests.cs @@ -0,0 +1,264 @@ +using ErsatzTV.Application.Channels; +using ErsatzTV.Core.Api.Channels; +using ErsatzTV.Core.Domain; +using ErsatzTV.Core.Domain.Filler; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Tests.Support; +using LanguageExt; +using NUnit.Framework; +using Shouldly; + +namespace ErsatzTV.Tests.Application.Channels; + +[TestFixture] +public class GetChannelPlaybackSourceHandlerTests +{ + private static readonly DateTimeOffset Now = new(2026, 7, 14, 20, 0, 0, TimeSpan.Zero); + + private InMemoryTvContext _db = null!; + + [SetUp] + public async Task SetUp() => _db = await InMemoryTvContext.CreateAsync(); + + [TearDown] + public async Task TearDown() => await _db.DisposeAsync(); + + [Test] + public async Task Handle_Should_Resolve_Jellyfin_Item_And_Schedule_Offset() + { + string jellyfinItemId = Guid.NewGuid().ToString("N"); + DateTime start = Now.UtcDateTime.AddMinutes(-10); + DateTime finish = Now.UtcDateTime.AddMinutes(20); + + await using (TvContext context = _db.CreateContext()) + { + Channel channel = MakeChannel(7, "7.1"); + var movie = new JellyfinMovie + { + Id = 70, + ItemId = jellyfinItemId, + Etag = string.Empty, + MovieMetadata = [], + MediaVersions = [] + }; + var playout = new Playout { Id = 71, Channel = channel, ChannelId = channel.Id, Items = [] }; + var item = new PlayoutItem + { + Id = 72, + MediaItem = movie, + MediaItemId = movie.Id, + Playout = playout, + PlayoutId = playout.Id, + Start = start, + Finish = finish, + InPoint = TimeSpan.FromMinutes(5), + OutPoint = TimeSpan.FromMinutes(35), + FillerKind = FillerKind.None + }; + + context.Channels.Add(channel); + context.JellyfinMovies.Add(movie); + context.Playouts.Add(playout); + context.PlayoutItems.Add(item); + await context.SaveChangesAsync(); + } + + ChannelPlaybackSourceResponseModel result = await GetResult(7, Now); + + result.ChannelId.ShouldBe(7); + result.SourceChannelId.ShouldBe(7); + result.SourceAt.ShouldBe(Now); + result.NextTransitionAt.ShouldBe(new DateTimeOffset(finish, TimeSpan.Zero)); + result.Active.ShouldNotBeNull(); + result.Active.Start.ShouldBe(new DateTimeOffset(start, TimeSpan.Zero)); + result.Active.CurrentOffsetTicks.ShouldBe(TimeSpan.FromMinutes(15).Ticks); + result.Active.Source.Kind.ShouldBe(ChannelPlaybackSourceKind.JellyfinItem); + result.Active.Source.ItemId.ShouldBe(jellyfinItemId); + result.Active.Source.Path.ShouldBeNull(); + } + + [Test] + public async Task Handle_Should_Use_Actual_Filler_Item_Not_Guide_Display_Item() + { + await using (TvContext context = _db.CreateContext()) + { + Channel channel = MakeChannel(8, "8"); + var filler = new OtherVideo + { + Id = 80, + OtherVideoMetadata = [], + MediaVersions = + [ + new MediaVersion + { + MediaFiles = [new MediaFile { Path = "/media/bumper.mkv", PathHash = "bumper" }] + } + ] + }; + var playout = new Playout { Id = 81, Channel = channel, ChannelId = channel.Id, Items = [] }; + var item = new PlayoutItem + { + Id = 82, + MediaItem = filler, + MediaItemId = filler.Id, + Playout = playout, + PlayoutId = playout.Id, + Start = Now.UtcDateTime.AddMinutes(-1), + Finish = Now.UtcDateTime.AddMinutes(1), + OutPoint = TimeSpan.FromMinutes(2), + FillerKind = FillerKind.MidRoll, + GuideGroup = 4 + }; + + context.Channels.Add(channel); + context.OtherVideos.Add(filler); + context.Playouts.Add(playout); + context.PlayoutItems.Add(item); + await context.SaveChangesAsync(); + } + + ChannelPlaybackSourceResponseModel result = await GetResult(8, Now); + + result.Active.ShouldNotBeNull(); + result.Active.PlayoutItemId.ShouldBe(82); + result.Active.FillerKind.ShouldBe(FillerKind.MidRoll); + result.Active.Source.Kind.ShouldBe(ChannelPlaybackSourceKind.LocalFile); + result.Active.Source.Path.ShouldBe("/media/bumper.mkv"); + } + + [Test] + public async Task Handle_Should_Apply_Mirror_Clock_And_Viewer_Facing_Timestamps() + { + TimeSpan offset = TimeSpan.FromHours(1); + DateTime sourceStart = Now.UtcDateTime.Subtract(offset).AddMinutes(-5); + DateTime sourceFinish = Now.UtcDateTime.Subtract(offset).AddMinutes(25); + + await using (TvContext context = _db.CreateContext()) + { + Channel source = MakeChannel(9, "9"); + Channel mirror = MakeChannel(10, "10"); + mirror.PlayoutSource = ChannelPlayoutSource.Mirror; + mirror.MirrorSourceChannelId = source.Id; + mirror.PlayoutOffset = offset; + + var remote = new RemoteStream + { + Id = 90, + Url = "https://example.invalid/live.m3u8", + IsLive = true, + RemoteStreamMetadata = [], + MediaVersions = [] + }; + var playout = new Playout { Id = 91, Channel = source, ChannelId = source.Id, Items = [] }; + var item = new PlayoutItem + { + Id = 92, + MediaItem = remote, + MediaItemId = remote.Id, + Playout = playout, + PlayoutId = playout.Id, + Start = sourceStart, + Finish = sourceFinish, + OutPoint = TimeSpan.FromMinutes(30) + }; + + context.Channels.AddRange(source, mirror); + context.RemoteStreams.Add(remote); + context.Playouts.Add(playout); + context.PlayoutItems.Add(item); + await context.SaveChangesAsync(); + } + + ChannelPlaybackSourceResponseModel result = await GetResult(10, Now); + + result.SourceChannelId.ShouldBe(9); + result.SourceAt.ShouldBe(Now.Subtract(offset)); + result.Active.ShouldNotBeNull(); + result.Active.Start.ShouldBe(new DateTimeOffset(sourceStart + offset, TimeSpan.Zero)); + result.Active.Finish.ShouldBe(new DateTimeOffset(sourceFinish + offset, TimeSpan.Zero)); + result.Active.CurrentOffsetTicks.ShouldBe(TimeSpan.FromMinutes(5).Ticks); + result.Active.Source.Kind.ShouldBe(ChannelPlaybackSourceKind.RemoteUrl); + result.Active.Source.IsLive.ShouldBeTrue(); + } + + [Test] + public async Task Handle_Should_Use_Half_Open_Boundary_And_Return_Next_Start_During_Gap() + { + await using (TvContext context = _db.CreateContext()) + { + Channel channel = MakeChannel(11, "11"); + var movie = new Movie { Id = 110, MovieMetadata = [], MediaVersions = [] }; + var playout = new Playout { Id = 111, Channel = channel, ChannelId = channel.Id, Items = [] }; + context.Channels.Add(channel); + context.Movies.Add(movie); + context.Playouts.Add(playout); + context.PlayoutItems.AddRange( + new PlayoutItem + { + Id = 112, + MediaItem = movie, + MediaItemId = movie.Id, + Playout = playout, + PlayoutId = playout.Id, + Start = Now.UtcDateTime.AddMinutes(-30), + Finish = Now.UtcDateTime + }, + new PlayoutItem + { + Id = 113, + MediaItem = movie, + MediaItemId = movie.Id, + Playout = playout, + PlayoutId = playout.Id, + Start = Now.UtcDateTime.AddMinutes(10), + Finish = Now.UtcDateTime.AddMinutes(40) + }); + await context.SaveChangesAsync(); + } + + ChannelPlaybackSourceResponseModel result = await GetResult(11, Now); + + result.Active.ShouldBeNull(); + result.NextTransitionAt.ShouldBe(Now.AddMinutes(10)); + } + + [Test] + public async Task Handle_Should_Return_None_For_Missing_Channel() + { + var handler = new GetChannelPlaybackSourceHandler(_db.Factory); + + Option result = await handler.Handle( + new GetChannelPlaybackSource(404, Now), + CancellationToken.None); + + result.IsNone.ShouldBeTrue(); + } + + private async Task GetResult(int channelId, DateTimeOffset at) + { + var handler = new GetChannelPlaybackSourceHandler(_db.Factory); + Option result = await handler.Handle( + new GetChannelPlaybackSource(channelId, at), + CancellationToken.None); + return result.Match( + Some: value => value, + None: () => throw new AssertionException("Expected a playback-source response")); + } + + private static Channel MakeChannel(int id, string number) => + new(Guid.NewGuid()) + { + Id = id, + Number = number, + SortNumber = id, + Name = $"Channel {number}", + Group = "Test", + Categories = string.Empty, + StreamSelector = string.Empty, + PreferredAudioLanguageCode = string.Empty, + PreferredAudioTitle = string.Empty, + PreferredSubtitleLanguageCode = string.Empty, + MusicVideoCreditsTemplate = string.Empty, + PlayoutSource = ChannelPlayoutSource.Generated + }; +} diff --git a/ErsatzTV.Tests/Controllers/ChannelControllerTests.cs b/ErsatzTV.Tests/Controllers/ChannelControllerTests.cs index 59ee2f9a1..bb5d87379 100644 --- a/ErsatzTV.Tests/Controllers/ChannelControllerTests.cs +++ b/ErsatzTV.Tests/Controllers/ChannelControllerTests.cs @@ -15,6 +15,7 @@ using ErsatzTV.Core.Domain; using ErsatzTV.Core.Errors; using ErsatzTV.Core.Interfaces.Locking; using ErsatzTV.Core.Scheduling; +using ErsatzTV.Filters; using LanguageExt; using static LanguageExt.Prelude; using MediatR; @@ -273,6 +274,28 @@ public class ChannelControllerTests Arg.Any()); } + [Test] + public async Task GetPlaybackSource_Should_Require_Authentication_And_Map_Query() + { + DateTimeOffset at = new(2026, 7, 14, 20, 0, 0, TimeSpan.Zero); + var model = new ChannelPlaybackSourceResponseModel(7, 7, at, at, null, null); + _mediator.Send(Arg.Any(), Arg.Any()) + .Returns(Option.Some(model)); + + IActionResult result = await _controller.GetPlaybackSource(7, at, CancellationToken.None); + + result.ShouldBeOfType().Value.ShouldBe(model); + await _mediator.Received(1).Send( + Arg.Is(q => q.ChannelId == 7 && q.At == at), + Arg.Any()); + + MethodInfo method = typeof(ChannelController).GetMethod(nameof(ChannelController.GetPlaybackSource))!; + method.GetCustomAttribute().ShouldNotBeNull(); + ResponseCacheAttribute cache = method.GetCustomAttribute()!; + cache.NoStore.ShouldBeTrue(); + cache.Location.ShouldBe(ResponseCacheLocation.None); + } + [Test] public async Task BulkRenumber_Should_Return_422_On_Validation_Error() { diff --git a/ErsatzTV/Controllers/Api/ChannelController.cs b/ErsatzTV/Controllers/Api/ChannelController.cs index c29ff6278..1c99a7339 100644 --- a/ErsatzTV/Controllers/Api/ChannelController.cs +++ b/ErsatzTV/Controllers/Api/ChannelController.cs @@ -11,6 +11,7 @@ using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Locking; using ErsatzTV.Core.Scheduling; using ErsatzTV.Extensions; +using ErsatzTV.Filters; using MediatR; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -48,6 +49,28 @@ public class ChannelController( CancellationToken cancellationToken) => await mediator.Send(new GetChannelGuideData(start, end), cancellationToken); + [HttpGet("/api/v1/channels/{id:int}/playback-source")] + [Tags("Channels")] + [EndpointSummary("Resolve the scheduled playback source for a channel")] + [EndpointDescription( + "Returns the physical media item and in-file offset selected by the channel schedule at the requested " + + "time. This read-only endpoint never starts an ErsatzTV transcoder. at defaults to now.")] + [EndpointGroupName("general")] + [RequiresAuthentication] + [ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)] + [ProducesResponseType(typeof(ChannelPlaybackSourceResponseModel), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] + public async Task GetPlaybackSource( + int id, + [FromQuery] DateTimeOffset? at, + CancellationToken cancellationToken) + { + Option result = await mediator.Send( + new GetChannelPlaybackSource(id, at ?? DateTimeOffset.UtcNow), + cancellationToken); + return result.ToGetResult(); + } + [HttpGet("/api/v1/channels/music-video-credits-templates", Name = "GetMusicVideoCreditsTemplates")] [Tags("Channels")] [EndpointSummary("Get available music video credits template names")] diff --git a/ErsatzTV/wwwroot/openapi/v1.json b/ErsatzTV/wwwroot/openapi/v1.json index 77ed5c7e7..261207c5b 100644 --- a/ErsatzTV/wwwroot/openapi/v1.json +++ b/ErsatzTV/wwwroot/openapi/v1.json @@ -1533,6 +1533,100 @@ ] } }, + "/api/v1/channels/{id}/playback-source": { + "get": { + "tags": [ + "Channels" + ], + "summary": "Resolve the scheduled playback source for a channel", + "description": "Returns the physical media item and in-file offset selected by the channel schedule at the requested time. This read-only endpoint never starts an ErsatzTV transcoder. at defaults to now.", + "operationId": "ChannelGetPlaybackSource", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "at", + "in": "query", + "schema": { + "type": "string", + "format": "date-time" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ChannelPlaybackSourceResponseModel" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChannelPlaybackSourceResponseModel" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ChannelPlaybackSourceResponseModel" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ProblemDetails" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemDetails" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/ProblemDetails" + } + } + } + }, + "401": { + "description": "API key missing or invalid.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemDetails" + } + } + } + }, + "400": { + "description": "Request validation failed (model binding or FluentValidation).", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ValidationProblemDetails" + } + } + } + } + }, + "security": [ + { } + ] + } + }, "/api/v1/channels/music-video-credits-templates": { "get": { "tags": [ @@ -22927,12 +23021,17 @@ }, "ChannelGuideChannelResponseModel": { "required": [ + "id", "number", "name", "programmes" ], "type": "object", "properties": { + "id": { + "type": "integer", + "format": "int32" + }, "number": { "type": "string" }, @@ -23072,6 +23171,149 @@ } } }, + "ChannelPlaybackItemResponseModel": { + "required": [ + "playoutItemId", + "mediaItemId", + "start", + "finish", + "inPointTicks", + "currentOffsetTicks", + "outPointTicks", + "fillerKind", + "source" + ], + "type": "object", + "properties": { + "playoutItemId": { + "type": "integer", + "format": "int32" + }, + "mediaItemId": { + "type": "integer", + "format": "int32" + }, + "start": { + "type": "string", + "format": "date-time" + }, + "finish": { + "type": "string", + "format": "date-time" + }, + "inPointTicks": { + "type": "integer", + "format": "int64" + }, + "currentOffsetTicks": { + "type": "integer", + "format": "int64" + }, + "outPointTicks": { + "type": "integer", + "format": "int64" + }, + "fillerKind": { + "$ref": "#/components/schemas/FillerKind" + }, + "source": { + "$ref": "#/components/schemas/ChannelPlaybackSourceReferenceResponseModel" + } + } + }, + "ChannelPlaybackSourceKind": { + "enum": [ + "LocalFile", + "JellyfinItem", + "PlexItem", + "EmbyItem", + "RemoteUrl", + "Unsupported" + ], + "type": "string" + }, + "ChannelPlaybackSourceReferenceResponseModel": { + "required": [ + "kind", + "itemId", + "path", + "url", + "isLive" + ], + "type": "object", + "properties": { + "kind": { + "$ref": "#/components/schemas/ChannelPlaybackSourceKind" + }, + "itemId": { + "type": [ + "null", + "string" + ] + }, + "path": { + "type": [ + "null", + "string" + ] + }, + "url": { + "type": [ + "null", + "string" + ] + }, + "isLive": { + "type": "boolean" + } + } + }, + "ChannelPlaybackSourceResponseModel": { + "required": [ + "channelId", + "sourceChannelId", + "resolvedAt", + "sourceAt", + "nextTransitionAt", + "active" + ], + "type": "object", + "properties": { + "channelId": { + "type": "integer", + "format": "int32" + }, + "sourceChannelId": { + "type": "integer", + "format": "int32" + }, + "resolvedAt": { + "type": "string", + "format": "date-time" + }, + "sourceAt": { + "type": "string", + "format": "date-time" + }, + "nextTransitionAt": { + "type": [ + "null", + "string" + ], + "format": "date-time" + }, + "active": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/ChannelPlaybackItemResponseModel" + } + ] + } + } + }, "ChannelPlayoutMode": { "enum": [ "Continuous", diff --git a/docs/README.md b/docs/README.md index 737531ddf..5e226ac1a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -32,6 +32,8 @@ Also present in `docs/`: Largely superseded day-to-day by `docs/api-conventions.md`; read this for the original rationale. - **`docs/channels.md`** — Channel entity field reference. - **`docs/m3u-xmltv.md`** — M3U/XMLTV generation overview (`ChannelPlaylist`, `GetChannelGuideHandler`). +- **`docs/player-owned-playback-poc.md`** — issue #357 feasibility record for a thin Jellyfin Live TV + plugin, native player/transcode ownership, and the deliberately deferred Kodi decision. - **`docs/fork-strategy.md`** — divergence policy vs upstream ErsatzTV. - **`docs/design-sync.md`** — Claude Design ↔ repo screen workflow (#92). - **`docs/endpoint-index.md`** — generated REST endpoint index (method/path/operationId/summary per diff --git a/docs/endpoint-index.md b/docs/endpoint-index.md index a72acd4c9..0f5623e5a 100644 --- a/docs/endpoint-index.md +++ b/docs/endpoint-index.md @@ -2,7 +2,7 @@ *Generated by `scripts/generate-endpoint-index.py` from `ErsatzTV/wwwroot/openapi/v1.json`. Do not edit by hand -- regenerated by `scripts/update-openapi.sh`.* -160 endpoints, 242 operations. +161 endpoints, 243 operations. ## Artists @@ -65,6 +65,7 @@ | DELETE | `/api/v1/channels/{id}` | ChannelDelete | Delete a channel | | GET | `/api/v1/channels/{id}` | GetChannelById | Get a channel by id | | PUT | `/api/v1/channels/{id}` | ChannelUpdate | Update a channel | +| GET | `/api/v1/channels/{id}/playback-source` | ChannelGetPlaybackSource | Resolve the scheduled playback source for a channel | | POST | `/api/v1/channels/{id}/playout/reset` | ChannelResetPlayout | Reset channel playout | | GET | `/api/v1/guide` | ChannelGetGuide | Get the JSON channel guide (EPG) | diff --git a/docs/player-owned-playback-poc.md b/docs/player-owned-playback-poc.md new file mode 100644 index 000000000..121ce1340 --- /dev/null +++ b/docs/player-owned-playback-poc.md @@ -0,0 +1,142 @@ +# Player-owned channel playback PoC (#357) + +Status: phase-one Jellyfin probe. The live measurements and Kodi gate remain open. + +## Current verdict + +A thin Jellyfin Live TV plugin can reuse ChicoryTV channels and guide data, select a backing Jellyfin +library item, and leave direct-play/direct-stream/transcode negotiation to Jellyfin. That part fits the +desired ownership model. + +Stock Jellyfin 12.0-rc2 does **not**, however, give an `ILiveTvService` provider a way to supply the +schedule-derived position in that file. Jellyfin seeks from the client's `StartTimeTicks`; its web client +tunes a Live TV channel with zero, and the provider's stream methods receive no start-time argument. +Jellyfin also normalizes provider sources as infinite Live TV, while opening the selected source only once. +It does not reopen the channel when a finite file reaches the next scheduled boundary. + +The provisional result is therefore: + +- **Go** for a small installed plugin probe and for Jellyfin-owned codec negotiation on one selected item. +- **No-go** for replacing the existing continuous channel path with a server-plugin-only implementation + until both provider-supplied initial offset and boundary transition semantics have a proven solution. +- **Administrator-only for the probe.** The Live TV provider contract has no user context when it resolves + the backing item, so per-library user restrictions are not yet enforced for that item. +- **Do not start Kodi-specific implementation yet.** Preserve the existing M3U/XMLTV path and use the + Jellyfin result to decide whether Kodi can reuse an official Jellyfin integration or needs a thin companion. + +## Intended ecosystem and ownership + +| Concern | Owner in the proposed split | +|---|---| +| Channels, schedules, playout items, filler decisions | ChicoryTV | +| Advanced configuration, wizards, API and MCP automation | ChicoryTV | +| Jellyfin-side configuration | Only ChicoryTV URL and machine API key | +| Channel and EPG presentation in Jellyfin | Native Jellyfin Live TV through a thin plugin | +| File lookup inside Jellyfin | Jellyfin library item ID and native media-source lookup | +| Direct play, direct stream, fallback transcode | Jellyfin and the requesting client | +| Kodi during this phase | Existing IPTV/PVR M3U + XMLTV path, unchanged | + +ChicoryTV remains the only authoritative state. The plugin is an adapter, not a second channel editor or +schedule store. + +## Phase-one seam + +The adapter reuses the existing JSON guide and adds one authenticated read: + +```text +GET /api/v1/guide?start=...&end=... +GET /api/v1/channels/{id}/playback-source?at=... +``` + +Guide channels now include their stable ChicoryTV channel ID. `playback-source` resolves that viewer-facing +channel time to the actual physical `PlayoutItem`, including filler, rather than to the guide display item. +It returns: + +- source channel and mirror-adjusted lookup time; +- physical playout item, start/finish, in/out points, and current in-file offset; +- the next physical transition; +- a token-free typed source reference (`JellyfinItem`, `LocalFile`, `PlexItem`, `EmbyItem`, or `RemoteUrl`). + +The handler depends only on the database context. It never asks the FFmpeg process or segmenter services to +start work. The endpoint is explicitly machine-key authenticated and non-cacheable because local paths may be +present for local-library items. The first plugin probe accepts only `JellyfinItem`, so it cannot silently fall +back to an ErsatzTV proxy or transcoder. + +Jellyfin asks a provider for programme data per channel. The probe holds one 30-second guide snapshot that +covers the requested window so a refresh does not rebuild the full ChicoryTV guide once for every channel. + +Mirrors use the source clock (`requested time - PlayoutOffset`) and return viewer-facing transition times. +Selection is start-inclusive and finish-exclusive. Continuous generated channels are the phase-one target; +on-demand clock shifting and `ExternalJson` guide channels are not yet supported by this seam. + +## Exact Jellyfin limitation + +The checked runtime is Jellyfin Server and Web `v12.0-rc2` on .NET 10. + +1. `ILiveTvService.GetChannelStreamMediaSources` and `GetChannelStream` can return a native file-backed + `MediaSourceInfo`, but neither method receives the requested schedule offset. +2. Jellyfin's playback-info and open-live-stream routes take `StartTimeTicks` from the client request. +3. The stock web client maps a currently airing programme to its channel and starts it with position zero. +4. Jellyfin uses nonzero `StartTimeTicks` for its native FFmpeg `-ss` path, but the plugin cannot populate that + request field through the Live TV provider contract. +5. Jellyfin forces Live TV media sources to `IsInfiniteStream = true` and clears finite runtime metadata. + Guide refresh persists EPG metadata; it is not a transition scheduler for an already-open stream. + +Returning the file alone therefore proves native playback ownership but starts at the beginning. Returning a +custom continuous HTTP/HLS stream could solve position and transitions, but it would make the plugin or +ChicoryTV a stream orchestrator again—the complexity this direction is meant to remove. + +The smallest architecture-compatible paths to investigate after the live probe are either an upstream +Jellyfin provider contract that carries an initial offset and transition/reopen semantics, or a deliberately +thin client companion that supplies `StartTimeTicks` and retunes at a boundary. Both must be evaluated before +custom streaming code. + +## Continue Watching and history + +No first-phase history toggle is required. Native Live TV playback keeps the session `ItemId` as the virtual +`LiveTvChannel`; the backing episode/movie is only media-source data. Jellyfin writes progress against the +session item, and `LiveTvChannel` explicitly does not support position resume. Consequently, briefly surfing +past a scheduled episode should not add that episode to Continue Watching or change its played state. + +The live probe must still assert start/progress/stop event IDs. If a client reports the backing item ID instead +of the channel ID, the assumption is false and suppression becomes a separate design problem. The plugin must +never substitute the backing library item as the playback session item. + +## Reuse matrix + +| Existing component | Reuse | Notes | +|---|---:|---| +| Channel model and editing | Unchanged | Plugin reads projected channel IDs/names/numbers. | +| Playout schedules and physical item timing | Unchanged | New read projects existing `PlayoutItem` state. | +| JSON guide / shared guide projector | Unchanged + additive ID | Same guide grouping/filler metadata as XMLTV. | +| M3U/XMLTV and Kodi IPTV Simple behavior | Unchanged | Remains the rollback and current Kodi path. | +| REST API/auth | Reused | One additive, explicitly authenticated read endpoint. | +| MCP and automation | Unchanged | ChicoryTV remains authoritative; no plugin-side writes. | +| Channel wizards / simple programming flow | Unchanged | They continue producing the same channel/schedule state. | +| ChicoryTV advanced web UI | Unchanged | No duplicate editor in Jellyfin. | +| ErsatzTV FFmpeg/segmenter | Not used by the probe | Still available per-client/per-channel as fallback. | +| Watermarks, graphics and subtitle burn-in | Not reproduced | Native-file playback cannot preserve rendered overlays. | +| On-demand playout clock | Deferred | Needs an explicit player-owned clock contract. | +| External JSON playout guide | Deferred | Existing JSON guide intentionally omits it. | +| Per-user backing-library authorization | Blocking gap | `ILiveTvService` source resolution has no user argument. | + +## Live probe and evidence still required + +The installed probe must record, without assuming success: + +1. two ChicoryTV channels and their EPG rows in Jellyfin; +2. the adapter's computed offset and the actual `StartTimeTicks` sent by a stock client; +3. direct-play/direct-stream and forced native Jellyfin-transcode process/network paths; +4. behavior at finite-file EOF and at two scheduled boundaries; +5. playback event item IDs and the user's Continue Watching state before/after channel surfing; +6. startup/channel-change latency, A/V stability, visible quality, and Jellyfin/ErsatzTV CPU and memory; +7. confirmation that no ErsatzTV FFmpeg process starts. + +Only after that evidence should the issue choose between an upstream Jellyfin seam, a thin client companion, +or a no-go with the existing IPTV stream retained. + +## Rollback + +The experiment is isolated and makes no schema change. Disable/remove the Jellyfin plugin and clients continue +using the existing M3U/XMLTV stream URLs. The additive API read has no producer side effects and can remain for +future adapters or be removed before release if the direction is rejected. diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvClient.cs b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvClient.cs index 13d137fc9..0dada970d 100644 --- a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvClient.cs +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/ErsatzTvClient.cs @@ -12,26 +12,37 @@ internal sealed class ErsatzTvClient : IDisposable }; private readonly HttpClient _httpClient = new(); + private readonly SemaphoreSlim _guideLock = new(1, 1); + private GuideResponse? _cachedGuide; + private DateTimeOffset _cachedGuideExpiresAt; public ErsatzTvClient() { } - public Task GetGuideAsync( + public async Task GetGuideAsync( DateTimeOffset? start, DateTimeOffset? end, CancellationToken cancellationToken) { - var relativePath = "api/v1/guide"; - if (start.HasValue && end.HasValue) + await _guideLock.WaitAsync(cancellationToken).ConfigureAwait(false); + try { - relativePath += string.Create( - CultureInfo.InvariantCulture, - $"?start={Uri.EscapeDataString(start.Value.ToUniversalTime().ToString("O", CultureInfo.InvariantCulture))}" + - $"&end={Uri.EscapeDataString(end.Value.ToUniversalTime().ToString("O", CultureInfo.InvariantCulture))}"); - } + GuideResponse? cached = GetCachedGuide(start, end); + if (cached is not null) + { + return cached; + } - return GetAsync(relativePath, cancellationToken); + GuideResponse guide = await GetGuideCoreAsync(start, end, cancellationToken).ConfigureAwait(false); + _cachedGuide = guide; + _cachedGuideExpiresAt = DateTimeOffset.UtcNow.AddSeconds(30); + return guide; + } + finally + { + _guideLock.Release(); + } } public Task GetPlaybackSourceAsync( @@ -47,7 +58,42 @@ internal sealed class ErsatzTvClient : IDisposable cancellationToken); } - public void Dispose() => _httpClient.Dispose(); + public void Dispose() + { + _guideLock.Dispose(); + _httpClient.Dispose(); + } + + private GuideResponse? GetCachedGuide(DateTimeOffset? start, DateTimeOffset? end) + { + GuideResponse? cached = _cachedGuide; + if (cached is null || DateTimeOffset.UtcNow >= _cachedGuideExpiresAt) + { + return null; + } + + return (!start.HasValue || cached.Start <= start.Value) + && (!end.HasValue || cached.End >= end.Value) + ? cached + : null; + } + + private Task GetGuideCoreAsync( + DateTimeOffset? start, + DateTimeOffset? end, + CancellationToken cancellationToken) + { + var relativePath = "api/v1/guide"; + if (start.HasValue && end.HasValue) + { + relativePath += string.Create( + CultureInfo.InvariantCulture, + $"?start={Uri.EscapeDataString(start.Value.ToUniversalTime().ToString("O", CultureInfo.InvariantCulture))}" + + $"&end={Uri.EscapeDataString(end.Value.ToUniversalTime().ToString("O", CultureInfo.InvariantCulture))}"); + } + + return GetAsync(relativePath, cancellationToken); + } private async Task GetAsync(string relativePath, CancellationToken cancellationToken) { diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/README.md b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/README.md index dec0b2d78..84be179c3 100644 --- a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/README.md +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/README.md @@ -22,6 +22,7 @@ The ErsatzTV side must provide: - Only `Source.Kind == JellyfinItem` is accepted. Local files, URLs, Plex, Emby, and unknown kinds fail explicitly; there is no proxy or ErsatzTV transcode fallback. - Native sources that require a nested dynamic-open operation are omitted. This first probe is for directly usable native Jellyfin library media sources. - `ILiveTvService` source resolution has no user parameter. This probe performs a non-user-aware library lookup, so administrators must not treat Live TV channel access as authorization for otherwise restricted backing items. +- Jellyfin requests guide programmes per channel; the plugin reuses a matching guide response for 30 seconds to avoid rebuilding the complete ErsatzTV guide for every channel in one refresh. - Jellyfin normalizes non-default Live TV sources as infinite/interlaced-capable and enables transcoding. Those stock-server mutations can affect negotiation even though the source metadata originates from the native library item. - The schedule-derived `CurrentOffsetTicks` is logged when resolving/opening, but it is not applied. The exact stock Jellyfin client sends `StartTimeTicks=0`, and `ILiveTvService` has no offset parameter. This probe makes no claim that Jellyfin consumes the logged offset. - A finite library file reaching EOF does not retune the channel. There is no continuous stream or transition engine. diff --git a/web/src/api/generated/v1.d.ts b/web/src/api/generated/v1.d.ts index ad9f715d3..a6bbcaa49 100644 --- a/web/src/api/generated/v1.d.ts +++ b/web/src/api/generated/v1.d.ts @@ -167,6 +167,7 @@ export interface components { "showInEpg": boolean; }; "ChannelGuideChannelResponseModel": { + "id": number; "number": string; "name": string; "programmes": Array; @@ -197,6 +198,33 @@ export interface components { "title": string; "startUtc": string; "finishUtc": string; + }; + "ChannelPlaybackItemResponseModel": { + "playoutItemId": number; + "mediaItemId": number; + "start": string; + "finish": string; + "inPointTicks": number; + "currentOffsetTicks": number; + "outPointTicks": number; + "fillerKind": components["schemas"]["FillerKind"]; + "source": components["schemas"]["ChannelPlaybackSourceReferenceResponseModel"]; + }; + "ChannelPlaybackSourceKind": "LocalFile" | "JellyfinItem" | "PlexItem" | "EmbyItem" | "RemoteUrl" | "Unsupported"; + "ChannelPlaybackSourceReferenceResponseModel": { + "kind": components["schemas"]["ChannelPlaybackSourceKind"]; + "itemId": null | string; + "path": null | string; + "url": null | string; + "isLive": boolean; + }; + "ChannelPlaybackSourceResponseModel": { + "channelId": number; + "sourceChannelId": number; + "resolvedAt": string; + "sourceAt": string; + "nextTransitionAt": null | string; + "active": null | components["schemas"]["ChannelPlaybackItemResponseModel"]; }; "ChannelPlayoutMode": "Continuous" | "OnDemand"; "ChannelPlayoutSource": "Generated" | "Mirror"; -- 2.47.3 From 63f72c7c5089c42f0c64d99a4e01a9226d7f2aa1 Mon Sep 17 00:00:00 2001 From: Timothy Date: Wed, 15 Jul 2026 19:07:55 +0200 Subject: [PATCH 3/4] fix(jellyfin): harden player-owned playback probe Pin discovery/open to a short schedule-identity snapshot without sharing mutable Jellyfin media sources, gate the authorization-incomplete lab probe behind an explicit opt-in, and add focused plugin tests to the main solution. Redact remote URLs and serialize OpenAPI ApiKey requirements correctly. Refs #357 Co-Authored-By: OpenAI Codex --- .../GetChannelPlaybackSourceHandler.cs | 8 +- .../ChannelPlaybackSourceResponseModel.cs | 1 - .../GetChannelPlaybackSourceHandlerTests.cs | 175 +++- .../OpenApiContractHonestyTests.cs | 27 + ErsatzTV.sln | 47 + .../ApiSecurityOperationTransformer.cs | 6 +- ErsatzTV/wwwroot/openapi/v1.json | 979 +++++++++++++----- docs/player-owned-playback-poc.md | 19 +- .../ErsatzTvLiveTvServiceTests.cs | 312 ++++++ .../Jellyfin.Plugin.ChicoryTV.Tests.csproj | 27 + .../Configuration/PluginConfiguration.cs | 6 + .../Configuration/configPage.html | 14 +- .../ErsatzTvClient.cs | 16 +- .../ErsatzTvContracts.cs | 2 - .../ErsatzTvLiveTvService.cs | 208 +++- .../IErsatzTvClient.cs | 17 + .../Jellyfin.Plugin.ChicoryTV.csproj | 6 + .../PluginConfigurationAccessor.cs | 15 + .../Jellyfin.Plugin.ChicoryTV/README.md | 7 +- .../ServiceRegistrator.cs | 4 +- web/src/api/generated/v1.d.ts | 1 - 21 files changed, 1584 insertions(+), 313 deletions(-) create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV.Tests/ErsatzTvLiveTvServiceTests.cs create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV.Tests/Jellyfin.Plugin.ChicoryTV.Tests.csproj create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/IErsatzTvClient.cs create mode 100644 integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/PluginConfigurationAccessor.cs diff --git a/ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSourceHandler.cs b/ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSourceHandler.cs index 6d559a7a6..0cde70396 100644 --- a/ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSourceHandler.cs +++ b/ErsatzTV.Application/Channels/Queries/GetChannelPlaybackSourceHandler.cs @@ -137,10 +137,7 @@ public class GetChannelPlaybackSourceHandler(IDbContextFactory dbCont PlexOtherVideo video => Reference(ChannelPlaybackSourceKind.PlexItem, itemId: video.Key), EmbyMovie movie => Reference(ChannelPlaybackSourceKind.EmbyItem, itemId: movie.ItemId), EmbyEpisode episode => Reference(ChannelPlaybackSourceKind.EmbyItem, itemId: episode.ItemId), - RemoteStream stream => Reference( - ChannelPlaybackSourceKind.RemoteUrl, - url: stream.Url, - isLive: stream.IsLive), + RemoteStream stream => Reference(ChannelPlaybackSourceKind.RemoteUrl, isLive: stream.IsLive), Movie movie => LocalFile(movie.MediaVersions), Episode episode => LocalFile(episode.MediaVersions), MusicVideo video => LocalFile(video.MediaVersions), @@ -162,7 +159,6 @@ public class GetChannelPlaybackSourceHandler(IDbContextFactory dbCont ChannelPlaybackSourceKind kind, string? itemId = null, string? path = null, - string? url = null, bool isLive = false) => - new(kind, itemId, path, url, isLive); + new(kind, itemId, path, isLive); } diff --git a/ErsatzTV.Core/Api/Channels/ChannelPlaybackSourceResponseModel.cs b/ErsatzTV.Core/Api/Channels/ChannelPlaybackSourceResponseModel.cs index 29b289450..39772e1b4 100644 --- a/ErsatzTV.Core/Api/Channels/ChannelPlaybackSourceResponseModel.cs +++ b/ErsatzTV.Core/Api/Channels/ChannelPlaybackSourceResponseModel.cs @@ -19,7 +19,6 @@ public record ChannelPlaybackSourceReferenceResponseModel( ChannelPlaybackSourceKind Kind, string? ItemId, string? Path, - string? Url, bool IsLive); /// The physical playout item covering the requested channel time. diff --git a/ErsatzTV.Tests/Application/Channels/GetChannelPlaybackSourceHandlerTests.cs b/ErsatzTV.Tests/Application/Channels/GetChannelPlaybackSourceHandlerTests.cs index 7e5588114..420c69043 100644 --- a/ErsatzTV.Tests/Application/Channels/GetChannelPlaybackSourceHandlerTests.cs +++ b/ErsatzTV.Tests/Application/Channels/GetChannelPlaybackSourceHandlerTests.cs @@ -176,26 +176,73 @@ public class GetChannelPlaybackSourceHandlerTests result.Active.ShouldNotBeNull(); result.Active.Start.ShouldBe(new DateTimeOffset(sourceStart + offset, TimeSpan.Zero)); result.Active.Finish.ShouldBe(new DateTimeOffset(sourceFinish + offset, TimeSpan.Zero)); + result.NextTransitionAt.ShouldBe(new DateTimeOffset(sourceFinish + offset, TimeSpan.Zero)); result.Active.CurrentOffsetTicks.ShouldBe(TimeSpan.FromMinutes(5).Ticks); result.Active.Source.Kind.ShouldBe(ChannelPlaybackSourceKind.RemoteUrl); result.Active.Source.IsLive.ShouldBeTrue(); } [Test] - public async Task Handle_Should_Use_Half_Open_Boundary_And_Return_Next_Start_During_Gap() + public async Task Handle_Should_Select_Item_At_Start_And_Exclude_Item_At_Finish() { await using (TvContext context = _db.CreateContext()) { Channel channel = MakeChannel(11, "11"); - var movie = new Movie { Id = 110, MovieMetadata = [], MediaVersions = [] }; - var playout = new Playout { Id = 111, Channel = channel, ChannelId = channel.Id, Items = [] }; + var first = new Movie { Id = 110, MovieMetadata = [], MediaVersions = [] }; + var second = new Movie { Id = 111, MovieMetadata = [], MediaVersions = [] }; + var playout = new Playout { Id = 112, Channel = channel, ChannelId = channel.Id, Items = [] }; + context.Channels.Add(channel); + context.Movies.AddRange(first, second); + context.Playouts.Add(playout); + context.PlayoutItems.AddRange( + new PlayoutItem + { + Id = 113, + MediaItem = first, + MediaItemId = first.Id, + Playout = playout, + PlayoutId = playout.Id, + Start = Now.UtcDateTime.AddMinutes(-30), + Finish = Now.UtcDateTime + }, + new PlayoutItem + { + Id = 114, + MediaItem = second, + MediaItemId = second.Id, + Playout = playout, + PlayoutId = playout.Id, + Start = Now.UtcDateTime, + Finish = Now.UtcDateTime.AddMinutes(30) + }); + await context.SaveChangesAsync(); + } + + ChannelPlaybackSourceResponseModel result = await GetResult(11, Now); + + result.Active.ShouldNotBeNull(); + result.Active.PlayoutItemId.ShouldBe(114); + result.Active.MediaItemId.ShouldBe(111); + result.Active.Start.ShouldBe(Now); + result.Active.CurrentOffsetTicks.ShouldBe(TimeSpan.Zero.Ticks); + result.NextTransitionAt.ShouldBe(Now.AddMinutes(30)); + } + + [Test] + public async Task Handle_Should_Return_Next_Start_During_Gap() + { + await using (TvContext context = _db.CreateContext()) + { + Channel channel = MakeChannel(12, "12"); + var movie = new Movie { Id = 120, MovieMetadata = [], MediaVersions = [] }; + var playout = new Playout { Id = 121, Channel = channel, ChannelId = channel.Id, Items = [] }; context.Channels.Add(channel); context.Movies.Add(movie); context.Playouts.Add(playout); context.PlayoutItems.AddRange( new PlayoutItem { - Id = 112, + Id = 122, MediaItem = movie, MediaItemId = movie.Id, Playout = playout, @@ -205,7 +252,7 @@ public class GetChannelPlaybackSourceHandlerTests }, new PlayoutItem { - Id = 113, + Id = 123, MediaItem = movie, MediaItemId = movie.Id, Playout = playout, @@ -216,12 +263,103 @@ public class GetChannelPlaybackSourceHandlerTests await context.SaveChangesAsync(); } - ChannelPlaybackSourceResponseModel result = await GetResult(11, Now); + ChannelPlaybackSourceResponseModel result = await GetResult(12, Now); result.Active.ShouldBeNull(); result.NextTransitionAt.ShouldBe(Now.AddMinutes(10)); } + [Test] + public async Task Handle_Should_Return_No_Next_Transition_During_Terminal_Gap() + { + await using (TvContext context = _db.CreateContext()) + { + Channel channel = MakeChannel(13, "13"); + var movie = new Movie { Id = 130, MovieMetadata = [], MediaVersions = [] }; + var playout = new Playout { Id = 131, Channel = channel, ChannelId = channel.Id, Items = [] }; + var finishedItem = new PlayoutItem + { + Id = 132, + MediaItem = movie, + MediaItemId = movie.Id, + Playout = playout, + PlayoutId = playout.Id, + Start = Now.UtcDateTime.AddHours(-1), + Finish = Now.UtcDateTime.AddMinutes(-30) + }; + + context.Channels.Add(channel); + context.Movies.Add(movie); + context.Playouts.Add(playout); + context.PlayoutItems.Add(finishedItem); + await context.SaveChangesAsync(); + } + + ChannelPlaybackSourceResponseModel result = await GetResult(13, Now); + + result.Active.ShouldBeNull(); + result.NextTransitionAt.ShouldBeNull(); + } + + [Test] + public async Task Handle_Should_Map_Server_Items_And_Unsupported_Empty_Local_Media() + { + const string jellyfinItemId = "jellyfin-episode"; + const string plexKey = "/library/metadata/123"; + const string embyItemId = "emby-movie"; + + await using (TvContext context = _db.CreateContext()) + { + var jellyfinEpisode = new JellyfinEpisode + { + Id = 140, + ItemId = jellyfinItemId, + Etag = string.Empty, + EpisodeMetadata = [], + MediaVersions = [] + }; + var plexMovie = new PlexMovie + { + Id = 150, + Key = plexKey, + Etag = string.Empty, + MovieMetadata = [], + MediaVersions = [] + }; + var embyMovie = new EmbyMovie + { + Id = 160, + ItemId = embyItemId, + Etag = string.Empty, + MovieMetadata = [], + MediaVersions = [] + }; + var emptyLocalMovie = new Movie { Id = 170, MovieMetadata = [], MediaVersions = [] }; + + AddActiveItem(context, MakeChannel(14, "14"), jellyfinEpisode, 141, 142); + AddActiveItem(context, MakeChannel(15, "15"), plexMovie, 151, 152); + AddActiveItem(context, MakeChannel(16, "16"), embyMovie, 161, 162); + AddActiveItem(context, MakeChannel(17, "17"), emptyLocalMovie, 171, 172); + await context.SaveChangesAsync(); + } + + ChannelPlaybackSourceReferenceResponseModel jellyfin = (await GetResult(14, Now)).Active!.Source; + ChannelPlaybackSourceReferenceResponseModel plex = (await GetResult(15, Now)).Active!.Source; + ChannelPlaybackSourceReferenceResponseModel emby = (await GetResult(16, Now)).Active!.Source; + ChannelPlaybackSourceReferenceResponseModel unsupported = (await GetResult(17, Now)).Active!.Source; + + jellyfin.Kind.ShouldBe(ChannelPlaybackSourceKind.JellyfinItem); + jellyfin.ItemId.ShouldBe(jellyfinItemId); + plex.Kind.ShouldBe(ChannelPlaybackSourceKind.PlexItem); + plex.ItemId.ShouldBe(plexKey); + emby.Kind.ShouldBe(ChannelPlaybackSourceKind.EmbyItem); + emby.ItemId.ShouldBe(embyItemId); + unsupported.Kind.ShouldBe(ChannelPlaybackSourceKind.Unsupported); + unsupported.ItemId.ShouldBeNull(); + unsupported.Path.ShouldBeNull(); + unsupported.IsLive.ShouldBeFalse(); + } + [Test] public async Task Handle_Should_Return_None_For_Missing_Channel() { @@ -245,6 +383,31 @@ public class GetChannelPlaybackSourceHandlerTests None: () => throw new AssertionException("Expected a playback-source response")); } + private static void AddActiveItem( + TvContext context, + Channel channel, + MediaItem mediaItem, + int playoutId, + int playoutItemId) + { + var playout = new Playout { Id = playoutId, Channel = channel, ChannelId = channel.Id, Items = [] }; + var item = new PlayoutItem + { + Id = playoutItemId, + MediaItem = mediaItem, + MediaItemId = mediaItem.Id, + Playout = playout, + PlayoutId = playout.Id, + Start = Now.UtcDateTime.AddMinutes(-1), + Finish = Now.UtcDateTime.AddMinutes(1) + }; + + context.Channels.Add(channel); + context.MediaItems.Add(mediaItem); + context.Playouts.Add(playout); + context.PlayoutItems.Add(item); + } + private static Channel MakeChannel(int id, string number) => new(Guid.NewGuid()) { diff --git a/ErsatzTV.Tests/Controllers/OpenApiContractHonestyTests.cs b/ErsatzTV.Tests/Controllers/OpenApiContractHonestyTests.cs index 124e5ecea..3a0426598 100644 --- a/ErsatzTV.Tests/Controllers/OpenApiContractHonestyTests.cs +++ b/ErsatzTV.Tests/Controllers/OpenApiContractHonestyTests.cs @@ -1,3 +1,4 @@ +using System.Text.Json; using ErsatzTV.Serialization; using ErsatzTV.Tests.Support; using Microsoft.OpenApi; @@ -71,6 +72,32 @@ public class OpenApiContractHonestyTests } } + [Test] + public async Task Serialized_Gated_Operations_Should_Name_The_ApiKey_Scheme() + { + string json = await _document.SerializeAsJsonAsync( + OpenApiSpecVersion.OpenApi3_1, + CancellationToken.None); + using JsonDocument serialized = JsonDocument.Parse(json); + + foreach (JsonProperty path in serialized.RootElement.GetProperty("paths").EnumerateObject()) + { + foreach (JsonProperty operation in path.Value.EnumerateObject()) + { + if (operation.NameEquals("parameters")) + { + continue; + } + + JsonElement security = operation.Value.GetProperty("security"); + security.GetArrayLength().ShouldBeGreaterThan(0, $"{operation.Name} {path.Name} should declare security"); + security[0].TryGetProperty(ApiSecurityOperationTransformer.SchemeName, out JsonElement scopes) + .ShouldBeTrue($"{operation.Name} {path.Name} should name the ApiKey scheme after serialization"); + scopes.ValueKind.ShouldBe(JsonValueKind.Array); + } + } + } + [Test] public void Troubleshoot_Playback_Actions_Should_Carry_Stable_Explicit_OperationIds() { diff --git a/ErsatzTV.sln b/ErsatzTV.sln index 589b7d4a6..edd2f8c56 100644 --- a/ErsatzTV.sln +++ b/ErsatzTV.sln @@ -32,6 +32,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ErsatzTV.Tests", "ErsatzTV. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ErsatzTV.Architecture.Tests", "ErsatzTV.Architecture.Tests\ErsatzTV.Architecture.Tests.csproj", "{49123AF1-38FE-4546-9DBD-8B7F1B4CFC7F}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integrations", "integrations", "{4958D7D8-4791-2CCE-6FFA-082B65933577}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "jellyfin", "jellyfin", "{65793B68-0114-8A23-3D53-9EDEAEBFFD0F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Plugin.ChicoryTV", "integrations\jellyfin\Jellyfin.Plugin.ChicoryTV\Jellyfin.Plugin.ChicoryTV.csproj", "{5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Plugin.ChicoryTV.Tests", "integrations\jellyfin\Jellyfin.Plugin.ChicoryTV.Tests\Jellyfin.Plugin.ChicoryTV.Tests.csproj", "{10235034-68F6-44AC-8C54-4C6F12DAD534}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -315,6 +323,42 @@ Global {49123AF1-38FE-4546-9DBD-8B7F1B4CFC7F}.Debug No Sync|x64.Build.0 = Debug|Any CPU {49123AF1-38FE-4546-9DBD-8B7F1B4CFC7F}.Debug No Sync|x86.ActiveCfg = Debug|Any CPU {49123AF1-38FE-4546-9DBD-8B7F1B4CFC7F}.Debug No Sync|x86.Build.0 = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug|x64.ActiveCfg = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug|x64.Build.0 = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug|x86.ActiveCfg = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug|x86.Build.0 = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Release|Any CPU.Build.0 = Release|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Release|x64.ActiveCfg = Release|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Release|x64.Build.0 = Release|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Release|x86.ActiveCfg = Release|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Release|x86.Build.0 = Release|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug No Sync|Any CPU.ActiveCfg = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug No Sync|Any CPU.Build.0 = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug No Sync|x64.ActiveCfg = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug No Sync|x64.Build.0 = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug No Sync|x86.ActiveCfg = Debug|Any CPU + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8}.Debug No Sync|x86.Build.0 = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug|Any CPU.Build.0 = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug|x64.ActiveCfg = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug|x64.Build.0 = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug|x86.ActiveCfg = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug|x86.Build.0 = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Release|Any CPU.ActiveCfg = Release|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Release|Any CPU.Build.0 = Release|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Release|x64.ActiveCfg = Release|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Release|x64.Build.0 = Release|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Release|x86.ActiveCfg = Release|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Release|x86.Build.0 = Release|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug No Sync|Any CPU.ActiveCfg = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug No Sync|Any CPU.Build.0 = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug No Sync|x64.ActiveCfg = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug No Sync|x64.Build.0 = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug No Sync|x86.ActiveCfg = Debug|Any CPU + {10235034-68F6-44AC-8C54-4C6F12DAD534}.Debug No Sync|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -325,5 +369,8 @@ Global {591FB3F4-4DD8-441B-B7C8-F2A42BF69992} = {325E6DA0-52B3-4431-98A2-72C36F403704} {2EF80455-953D-4696-831D-E8CBCA82B0EF} = {325E6DA0-52B3-4431-98A2-72C36F403704} {56F56E76-CEF4-4639-B7BB-03FD201BB019} = {325E6DA0-52B3-4431-98A2-72C36F403704} + {65793B68-0114-8A23-3D53-9EDEAEBFFD0F} = {4958D7D8-4791-2CCE-6FFA-082B65933577} + {5E6B1E48-F229-4FE1-8BA6-66994ADBE5A8} = {65793B68-0114-8A23-3D53-9EDEAEBFFD0F} + {10235034-68F6-44AC-8C54-4C6F12DAD534} = {65793B68-0114-8A23-3D53-9EDEAEBFFD0F} EndGlobalSection EndGlobal diff --git a/ErsatzTV/Serialization/ApiSecurityOperationTransformer.cs b/ErsatzTV/Serialization/ApiSecurityOperationTransformer.cs index 4fef0c4d5..e44940eba 100644 --- a/ErsatzTV/Serialization/ApiSecurityOperationTransformer.cs +++ b/ErsatzTV/Serialization/ApiSecurityOperationTransformer.cs @@ -36,7 +36,11 @@ public sealed class ApiSecurityOperationTransformer(IApiKeyProvider apiKeyProvid operation.Security ??= new List(); operation.Security.Add(new OpenApiSecurityRequirement { - [new OpenApiSecuritySchemeReference(SchemeName)] = new List() + // Microsoft.OpenApi 2.x needs the host document to serialize this as the + // component name. Without it the in-memory requirement looks populated, + // but the generated JSON contains `security: [ {} ]`, which means anonymous + // access in OpenAPI rather than the X-Api-Key requirement enforced at runtime. + [new OpenApiSecuritySchemeReference(SchemeName, context.Document, null)] = new List() }); operation.Responses ??= new OpenApiResponses(); diff --git a/ErsatzTV/wwwroot/openapi/v1.json b/ErsatzTV/wwwroot/openapi/v1.json index 261207c5b..307ef747a 100644 --- a/ErsatzTV/wwwroot/openapi/v1.json +++ b/ErsatzTV/wwwroot/openapi/v1.json @@ -86,7 +86,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -188,7 +190,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -241,7 +245,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -338,7 +344,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -407,7 +415,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -460,7 +470,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -578,7 +590,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -663,7 +677,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -729,7 +745,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -888,7 +906,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -983,7 +1003,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -1103,7 +1125,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -1234,7 +1258,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -1286,7 +1312,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -1403,7 +1431,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -1456,7 +1486,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -1529,7 +1561,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -1623,7 +1657,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -1676,7 +1712,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -1729,7 +1767,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -1814,7 +1854,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -1942,7 +1984,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -2028,7 +2072,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -2148,7 +2194,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -2250,7 +2298,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -2352,7 +2402,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -2454,7 +2506,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -2550,7 +2604,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -2603,7 +2659,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -2720,7 +2778,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -2784,7 +2844,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -2889,7 +2951,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -2974,7 +3038,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -3102,7 +3168,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -3188,7 +3256,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -3241,7 +3311,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -3358,7 +3430,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -3443,7 +3517,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -3571,7 +3647,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -3657,7 +3735,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -3761,7 +3841,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -3872,7 +3954,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -4016,7 +4100,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -4113,7 +4199,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -4166,7 +4254,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -4263,7 +4353,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -4332,7 +4424,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -4386,7 +4480,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -4504,7 +4600,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -4589,7 +4687,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -4656,7 +4756,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -4785,7 +4887,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -4838,7 +4942,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -4935,7 +5041,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -5004,7 +5112,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -5058,7 +5168,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -5176,7 +5288,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -5261,7 +5375,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -5327,7 +5443,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -5486,7 +5604,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -5581,7 +5701,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -5625,7 +5747,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -5670,7 +5794,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -5788,7 +5914,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -5836,7 +5964,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -5930,7 +6060,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -6068,7 +6200,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -6162,7 +6296,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -6299,7 +6435,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -6387,7 +6525,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -6484,7 +6624,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -6537,7 +6679,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -6664,7 +6808,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -6718,7 +6864,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -6803,7 +6951,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -6941,7 +7091,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -7037,7 +7189,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -7110,7 +7264,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -7237,7 +7393,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -7322,7 +7480,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -7460,7 +7620,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -7556,7 +7718,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -7610,7 +7774,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -7638,7 +7804,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -7691,7 +7859,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -7766,7 +7936,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -7887,7 +8059,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -7931,7 +8105,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -7976,7 +8152,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -8094,7 +8272,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -8142,7 +8322,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -8236,7 +8418,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -8374,7 +8558,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -8468,7 +8654,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -8605,7 +8793,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -8693,7 +8883,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -8790,7 +8982,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -8843,7 +9037,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -8896,7 +9092,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -9013,7 +9211,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -9146,7 +9346,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -9252,7 +9454,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -9305,7 +9509,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -9402,7 +9608,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -9487,7 +9695,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -9636,7 +9846,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -9722,7 +9934,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -9856,7 +10070,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -9936,7 +10152,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10035,7 +10253,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10082,7 +10302,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10129,7 +10351,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10156,7 +10380,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10238,7 +10464,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10343,7 +10571,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10396,7 +10626,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10450,7 +10682,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10535,7 +10769,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10617,7 +10853,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -10734,7 +10972,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -10819,7 +11059,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -10977,7 +11219,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -11063,7 +11307,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -11116,7 +11362,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -11213,7 +11461,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -11343,7 +11593,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -11429,7 +11681,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -11503,7 +11757,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -11600,7 +11856,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -11685,7 +11943,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -11853,7 +12113,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -11939,7 +12201,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -12034,7 +12298,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -12145,7 +12411,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -12254,7 +12522,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -12336,7 +12606,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -12454,7 +12726,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -12501,7 +12775,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -12586,7 +12862,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -12735,7 +13013,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -12841,7 +13121,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -12952,7 +13234,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -13103,7 +13387,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -13218,7 +13504,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -13406,7 +13694,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -13521,7 +13811,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -13709,7 +14001,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -13804,7 +14098,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -13917,7 +14213,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -14023,7 +14321,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -14067,7 +14367,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -14176,7 +14478,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -14285,7 +14589,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -14371,7 +14677,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -14416,7 +14724,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -14501,7 +14811,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -14549,7 +14861,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -14643,7 +14957,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -14781,7 +15097,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -14875,7 +15193,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -15013,7 +15333,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -15102,7 +15424,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -15199,7 +15523,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -15281,7 +15607,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -15398,7 +15726,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -15483,7 +15813,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -15641,7 +15973,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -15727,7 +16061,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -15811,7 +16147,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -15864,7 +16202,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -15971,7 +16311,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -16069,7 +16411,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -16122,7 +16466,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -16239,7 +16585,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -16324,7 +16672,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -16452,7 +16802,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -16538,7 +16890,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -16624,7 +16978,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -16752,7 +17108,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -16920,7 +17278,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17017,7 +17377,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17119,7 +17481,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17204,7 +17568,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17278,7 +17644,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17352,7 +17720,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17426,7 +17796,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17500,7 +17872,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17574,7 +17948,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17648,7 +18024,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17733,7 +18111,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17786,7 +18166,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17833,7 +18215,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -17877,7 +18261,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -17984,7 +18370,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -18028,7 +18416,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -18135,7 +18525,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -18179,7 +18571,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -18286,7 +18680,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -18330,7 +18726,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -18437,7 +18835,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -18481,7 +18881,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -18588,7 +18990,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -18632,7 +19036,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -18739,7 +19145,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -18783,7 +19191,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -18890,7 +19300,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -18975,7 +19387,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -19028,7 +19442,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -19145,7 +19561,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -19230,7 +19648,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -19358,7 +19778,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -19444,7 +19866,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -19497,7 +19921,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -19594,7 +20020,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -19663,7 +20091,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -19737,7 +20167,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -19855,7 +20287,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -19940,7 +20374,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -20006,7 +20442,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -20165,7 +20603,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -20260,7 +20700,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -20391,7 +20833,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -20465,7 +20909,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -20566,7 +21012,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -20651,7 +21099,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -20737,7 +21187,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -20865,7 +21317,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -20953,7 +21407,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -20998,7 +21454,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21042,7 +21500,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21132,7 +21592,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21271,7 +21733,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21298,7 +21762,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21346,7 +21812,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21399,7 +21867,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21494,7 +21964,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21539,7 +22011,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21583,7 +22057,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21636,7 +22112,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "post": { @@ -21763,7 +22241,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } }, @@ -21848,7 +22328,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "put": { @@ -21986,7 +22468,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] }, "delete": { @@ -22082,7 +22566,9 @@ } }, "security": [ - { } + { + "ApiKey": [ ] + } ] } } @@ -23237,7 +23723,6 @@ "kind", "itemId", "path", - "url", "isLive" ], "type": "object", @@ -23257,12 +23742,6 @@ "string" ] }, - "url": { - "type": [ - "null", - "string" - ] - }, "isLive": { "type": "boolean" } diff --git a/docs/player-owned-playback-poc.md b/docs/player-owned-playback-poc.md index 121ce1340..f0208130c 100644 --- a/docs/player-owned-playback-poc.md +++ b/docs/player-owned-playback-poc.md @@ -11,16 +11,18 @@ desired ownership model. Stock Jellyfin 12.0-rc2 does **not**, however, give an `ILiveTvService` provider a way to supply the schedule-derived position in that file. Jellyfin seeks from the client's `StartTimeTicks`; its web client tunes a Live TV channel with zero, and the provider's stream methods receive no start-time argument. -Jellyfin also normalizes provider sources as infinite Live TV, while opening the selected source only once. -It does not reopen the channel when a finite file reaches the next scheduled boundary. +Jellyfin also marks provider sources as infinite Live TV. The directly usable native-file path retains the +backing source's finite runtime metadata, but Jellyfin still does not treat that runtime or the EPG boundary as +a request to reopen the channel on the next scheduled item. The provisional result is therefore: - **Go** for a small installed plugin probe and for Jellyfin-owned codec negotiation on one selected item. - **No-go** for replacing the existing continuous channel path with a server-plugin-only implementation until both provider-supplied initial offset and boundary transition semantics have a proven solution. -- **Administrator-only for the probe.** The Live TV provider contract has no user context when it resolves - the backing item, so per-library user restrictions are not yet enforced for that item. +- **Isolated-lab-only for the probe.** The Live TV provider contract has no user context when it resolves the + backing item, so the plugin cannot enforce per-library user restrictions. An "administrator-only" warning is + not an authorization control; the live probe must use a loopback-only cloned Jellyfin with no non-admin users. - **Do not start Kodi-specific implementation yet.** Preserve the existing M3U/XMLTV path and use the Jellyfin result to decide whether Kodi can reuse an official Jellyfin integration or needs a thin companion. @@ -55,7 +57,8 @@ It returns: - source channel and mirror-adjusted lookup time; - physical playout item, start/finish, in/out points, and current in-file offset; - the next physical transition; -- a token-free typed source reference (`JellyfinItem`, `LocalFile`, `PlexItem`, `EmbyItem`, or `RemoteUrl`). +- a typed source reference (`JellyfinItem`, `LocalFile`, `PlexItem`, `EmbyItem`, or `RemoteUrl`). Credential-bearing + remote URLs are deliberately not returned by this phase-one endpoint. The handler depends only on the database context. It never asks the FFmpeg process or segmenter services to start work. The endpoint is explicitly machine-key authenticated and non-cacheable because local paths may be @@ -79,8 +82,9 @@ The checked runtime is Jellyfin Server and Web `v12.0-rc2` on .NET 10. 3. The stock web client maps a currently airing programme to its channel and starts it with position zero. 4. Jellyfin uses nonzero `StartTimeTicks` for its native FFmpeg `-ss` path, but the plugin cannot populate that request field through the Live TV provider contract. -5. Jellyfin forces Live TV media sources to `IsInfiniteStream = true` and clears finite runtime metadata. - Guide refresh persists EPG metadata; it is not a transition scheduler for an already-open stream. +5. Jellyfin forces Live TV media sources to `IsInfiniteStream = true`. For the probe's supported non-opening + native sources, `RunTimeTicks` remains present, but neither it nor guide refresh becomes a transition scheduler + for an already-open stream. Returning the file alone therefore proves native playback ownership but starts at the beginning. Returning a custom continuous HTTP/HLS stream could solve position and transitions, but it would make the plugin or @@ -119,6 +123,7 @@ never substitute the backing library item as the playback session item. | On-demand playout clock | Deferred | Needs an explicit player-owned clock contract. | | External JSON playout guide | Deferred | Existing JSON guide intentionally omits it. | | Per-user backing-library authorization | Blocking gap | `ILiveTvService` source resolution has no user argument. | +| Multiple Jellyfin servers | Probe constraint | Item IDs are resolved on the Jellyfin server hosting the plugin; the phase-one contract does not yet encode server identity. | ## Live probe and evidence still required diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV.Tests/ErsatzTvLiveTvServiceTests.cs b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV.Tests/ErsatzTvLiveTvServiceTests.cs new file mode 100644 index 000000000..0c36e8076 --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV.Tests/ErsatzTvLiveTvServiceTests.cs @@ -0,0 +1,312 @@ +using Jellyfin.Plugin.ChicoryTV.Configuration; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Movies; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Model.Dto; +using Microsoft.Extensions.Logging.Abstractions; +using NSubstitute; +using NUnit.Framework; +using Shouldly; + +namespace Jellyfin.Plugin.ChicoryTV.Tests; + +[TestFixture] +public sealed class ErsatzTvLiveTvServiceTests +{ + [Test] + public async Task OpenUsesDiscoverySnapshotWhenScheduleClockCrossesBoundary() + { + DateTimeOffset now = new(2026, 7, 14, 12, 0, 0, TimeSpan.Zero); + var fixture = new ServiceFixture(now); + Guid itemAId = Guid.NewGuid(); + Guid itemBId = Guid.NewGuid(); + var sourceA = new MediaSourceInfo { Id = "source-a" }; + var sourceAForOpen = new MediaSourceInfo { Id = "source-a" }; + var sourceB = new MediaSourceInfo { Id = "source-b" }; + Movie itemA = fixture.AddItem(itemAId, sourceA); + fixture.AddItem(itemBId, sourceB); + fixture.MediaSourceManager.GetPlaybackMediaSources( + itemA, + null!, + true, + true, + Arg.Any()) + .Returns( + Task.FromResult>([sourceA]), + Task.FromResult>([sourceAForOpen])); + fixture.Client.GetPlaybackSourceAsync(1, Arg.Any(), Arg.Any()) + .Returns( + Task.FromResult(PlaybackResponse(now, itemAId)), + Task.FromResult(PlaybackResponse(now.AddSeconds(1), itemBId))); + + List discovered = await fixture.Service.GetChannelStreamMediaSources("1", default); + fixture.Time.Advance(TimeSpan.FromSeconds(2)); + MediaSourceInfo opened = await fixture.Service.GetChannelStream("1", "source-a", default); + + discovered.ShouldBe([sourceA]); + opened.ShouldBeSameAs(sourceAForOpen); + await fixture.Client.Received(1).GetPlaybackSourceAsync( + 1, + Arg.Any(), + Arg.Any()); + } + + [Test] + public async Task OpenRefreshesCurrentSourceAfterDiscoverySnapshotExpires() + { + DateTimeOffset now = new(2026, 7, 14, 12, 0, 0, TimeSpan.Zero); + var fixture = new ServiceFixture(now); + Guid itemAId = Guid.NewGuid(); + Guid itemBId = Guid.NewGuid(); + var sourceA = new MediaSourceInfo { Id = "source-a" }; + var sourceB = new MediaSourceInfo { Id = "source-b" }; + fixture.AddItem(itemAId, sourceA); + fixture.AddItem(itemBId, sourceB); + fixture.Client.GetPlaybackSourceAsync(1, Arg.Any(), Arg.Any()) + .Returns( + Task.FromResult(PlaybackResponse(now, itemAId)), + Task.FromResult(PlaybackResponse(now.AddSeconds(16), itemBId))); + + await fixture.Service.GetChannelStreamMediaSources("1", default); + fixture.Time.Advance(TimeSpan.FromSeconds(16)); + MediaSourceInfo opened = await fixture.Service.GetChannelStream("1", "source-b", default); + + opened.ShouldBeSameAs(sourceB); + await fixture.Client.Received(1).GetPlaybackSourceAsync( + 1, + now.AddSeconds(16), + Arg.Any()); + await fixture.Client.Received(2).GetPlaybackSourceAsync( + 1, + Arg.Any(), + Arg.Any()); + } + + [Test] + public async Task DiscoveryFiltersRequiresOpeningAndOpenSelectsRequestedStreamId() + { + DateTimeOffset now = new(2026, 7, 14, 12, 0, 0, TimeSpan.Zero); + var fixture = new ServiceFixture(now); + Guid itemId = Guid.NewGuid(); + var nested = new MediaSourceInfo { Id = "nested", RequiresOpening = true }; + var first = new MediaSourceInfo { Id = "first" }; + var requested = new MediaSourceInfo { Id = "requested" }; + fixture.AddItem(itemId, nested, first, requested); + fixture.Client.GetPlaybackSourceAsync(1, Arg.Any(), Arg.Any()) + .Returns(PlaybackResponse(now, itemId)); + + List discovered = await fixture.Service.GetChannelStreamMediaSources("1", default); + MediaSourceInfo opened = await fixture.Service.GetChannelStream("1", "REQUESTED", default); + + discovered.ShouldBe([first, requested]); + opened.ShouldBeSameAs(requested); + await fixture.Client.Received(1).GetPlaybackSourceAsync( + 1, + Arg.Any(), + Arg.Any()); + } + + [Test] + public async Task OpenWithBlankStreamIdUsesFirstDiscoveredSource() + { + var fixture = new ServiceFixture(); + Guid itemId = Guid.NewGuid(); + var first = new MediaSourceInfo { Id = "first" }; + var second = new MediaSourceInfo { Id = "second" }; + fixture.AddItem(itemId, first, second); + fixture.Client.GetPlaybackSourceAsync(1, Arg.Any(), Arg.Any()) + .Returns(PlaybackResponse(fixture.Time.GetUtcNow(), itemId)); + + await fixture.Service.GetChannelStreamMediaSources("1", default); + MediaSourceInfo opened = await fixture.Service.GetChannelStream("1", string.Empty, default); + + opened.ShouldBeSameAs(first); + } + + [Test] + public void DiscoveryRejectsWhenEveryNativeSourceRequiresOpening() + { + var fixture = new ServiceFixture(); + Guid itemId = Guid.NewGuid(); + fixture.AddItem(itemId, new MediaSourceInfo { Id = "nested", RequiresOpening = true }); + fixture.Client.GetPlaybackSourceAsync(1, Arg.Any(), Arg.Any()) + .Returns(PlaybackResponse(fixture.Time.GetUtcNow(), itemId)); + + NotSupportedException exception = Assert.ThrowsAsync( + () => fixture.Service.GetChannelStreamMediaSources("1", default))!; + + exception.Message.ShouldContain("no native media source usable"); + } + + [Test] + public void DiscoveryRejectsMalformedChannelIdWithoutCallingErsatzTv() + { + var fixture = new ServiceFixture(); + + InvalidOperationException exception = Assert.ThrowsAsync( + () => fixture.Service.GetChannelStreamMediaSources("not-an-integer", default))!; + + exception.Message.ShouldContain("is not an integer"); + fixture.Client.DidNotReceiveWithAnyArgs().GetPlaybackSourceAsync(default, default, default); + } + + [Test] + public void DiscoveryRejectsChannelWithNoActiveItem() + { + var fixture = new ServiceFixture(); + fixture.Client.GetPlaybackSourceAsync(1, Arg.Any(), Arg.Any()) + .Returns(new PlaybackSourceResponse + { + ChannelId = 1, + ResolvedAt = fixture.Time.GetUtcNow() + }); + + InvalidOperationException exception = Assert.ThrowsAsync( + () => fixture.Service.GetChannelStreamMediaSources("1", default))!; + + exception.Message.ShouldContain("has no active playout item"); + } + + [Test] + public void DiscoveryRejectsNonJellyfinSource() + { + var fixture = new ServiceFixture(); + fixture.Client.GetPlaybackSourceAsync(1, Arg.Any(), Arg.Any()) + .Returns(PlaybackResponse(fixture.Time.GetUtcNow(), (string?)null, PlaybackSourceKind.LocalFile)); + + NotSupportedException exception = Assert.ThrowsAsync( + () => fixture.Service.GetChannelStreamMediaSources("1", default))!; + + exception.Message.ShouldContain("only JellyfinItem is supported"); + } + + [Test] + public void DiscoveryRejectsMalformedJellyfinItemId() + { + var fixture = new ServiceFixture(); + fixture.Client.GetPlaybackSourceAsync(1, Arg.Any(), Arg.Any()) + .Returns(PlaybackResponse(fixture.Time.GetUtcNow(), "not-a-guid")); + + InvalidOperationException exception = Assert.ThrowsAsync( + () => fixture.Service.GetChannelStreamMediaSources("1", default))!; + + exception.Message.ShouldContain("invalid Jellyfin item id"); + } + + [Test] + public void DiscoveryRejectsMissingJellyfinItem() + { + var fixture = new ServiceFixture(); + Guid missingItemId = Guid.NewGuid(); + fixture.Client.GetPlaybackSourceAsync(1, Arg.Any(), Arg.Any()) + .Returns(PlaybackResponse(fixture.Time.GetUtcNow(), missingItemId)); + + InvalidOperationException exception = Assert.ThrowsAsync( + () => fixture.Service.GetChannelStreamMediaSources("1", default))!; + + exception.Message.ShouldContain("was not found"); + } + + [Test] + public async Task UnsafeLabAcknowledgementIsOffByDefaultAndBlocksExposure() + { + var fixture = new ServiceFixture(unsafeLabAccessEnabled: false); + + IEnumerable channels = await fixture.Service.GetChannelsAsync(default); + InvalidOperationException exception = Assert.ThrowsAsync( + () => fixture.Service.GetChannelStreamMediaSources("1", default))!; + + channels.ShouldBeEmpty(); + exception.Message.ShouldContain("Explicitly acknowledge the unsafe lab setting"); + await fixture.Client.DidNotReceiveWithAnyArgs().GetGuideAsync(default, default, default); + await fixture.Client.DidNotReceiveWithAnyArgs().GetPlaybackSourceAsync(default, default, default); + new PluginConfiguration().EnableUnsafeLabAccess.ShouldBeFalse(); + } + + private static PlaybackSourceResponse PlaybackResponse( + DateTimeOffset resolvedAt, + Guid? itemId, + PlaybackSourceKind kind = PlaybackSourceKind.JellyfinItem) => + PlaybackResponse(resolvedAt, itemId?.ToString(), kind); + + private static PlaybackSourceResponse PlaybackResponse( + DateTimeOffset resolvedAt, + string? itemId, + PlaybackSourceKind kind = PlaybackSourceKind.JellyfinItem) => + new() + { + ChannelId = 1, + ResolvedAt = resolvedAt, + Active = new PlaybackItem + { + CurrentOffsetTicks = TimeSpan.FromMinutes(3).Ticks, + Source = new PlaybackSourceReference + { + Kind = kind, + ItemId = itemId + } + } + }; + + private sealed class ServiceFixture + { + public ServiceFixture( + DateTimeOffset? now = null, + bool unsafeLabAccessEnabled = true) + { + Time = new ManualTimeProvider( + now ?? new DateTimeOffset(2026, 7, 14, 12, 0, 0, TimeSpan.Zero)); + Client = Substitute.For(); + ConfigurationAccessor = Substitute.For(); + LibraryManager = Substitute.For(); + MediaSourceManager = Substitute.For(); + ConfigurationAccessor.Configuration.Returns(new PluginConfiguration + { + EnableUnsafeLabAccess = unsafeLabAccessEnabled + }); + Service = new ErsatzTvLiveTvService( + Client, + ConfigurationAccessor, + LibraryManager, + MediaSourceManager, + NullLogger.Instance, + Time); + } + + public IErsatzTvClient Client { get; } + + public IPluginConfigurationAccessor ConfigurationAccessor { get; } + + public ILibraryManager LibraryManager { get; } + + public IMediaSourceManager MediaSourceManager { get; } + + public ManualTimeProvider Time { get; } + + public ErsatzTvLiveTvService Service { get; } + + public Movie AddItem(Guid itemId, params MediaSourceInfo[] sources) + { + var item = new Movie { Id = itemId }; + LibraryManager.GetItemById(itemId).Returns(item); + MediaSourceManager.GetPlaybackMediaSources( + item, + null!, + true, + true, + Arg.Any()) + .Returns(Task.FromResult>(sources)); + return item; + } + } + + private sealed class ManualTimeProvider(DateTimeOffset utcNow) : TimeProvider + { + private DateTimeOffset _utcNow = utcNow; + + public override DateTimeOffset GetUtcNow() => _utcNow; + + public void Advance(TimeSpan amount) => _utcNow = _utcNow.Add(amount); + } +} diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV.Tests/Jellyfin.Plugin.ChicoryTV.Tests.csproj b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV.Tests/Jellyfin.Plugin.ChicoryTV.Tests.csproj new file mode 100644 index 000000000..2dea0b241 --- /dev/null +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV.Tests/Jellyfin.Plugin.ChicoryTV.Tests.csproj @@ -0,0 +1,27 @@ + + + + net10.0 + enable + enable + false + true + + + + + + + + + + + + + + + + + + diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/PluginConfiguration.cs b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/PluginConfiguration.cs index d91e586d3..fdbd45563 100644 --- a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/PluginConfiguration.cs +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/PluginConfiguration.cs @@ -10,6 +10,7 @@ public sealed class PluginConfiguration : BasePluginConfiguration { BaseUrl = "http://localhost:8409"; ApiKey = string.Empty; + EnableUnsafeLabAccess = false; } /// Gets or sets the ErsatzTV server base URL. @@ -17,4 +18,9 @@ public sealed class PluginConfiguration : BasePluginConfiguration /// Gets or sets the ErsatzTV API key. public string ApiKey { get; set; } + + /// + /// Gets or sets a value indicating whether the authorization-incomplete lab probe is enabled. + /// + public bool EnableUnsafeLabAccess { get; set; } } diff --git a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/configPage.html b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/configPage.html index 00e0c12c3..6fed48280 100644 --- a/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/configPage.html +++ b/integrations/jellyfin/Jellyfin.Plugin.ChicoryTV/Configuration/configPage.html @@ -5,7 +5,7 @@ ChicoryTV -
+
@@ -19,6 +19,16 @@
Sent to ErsatzTV as X-Api-Key.
+
+ +
+ Required to expose any ChicoryTV channels or sources. This is not administrator-role + enforcement. Do not enable it on a shared or untrusted Jellyfin deployment. +
+