Resolve saved native channel references after receiver migrations
This commit is contained in:
@@ -14,6 +14,9 @@ using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
@@ -32,6 +35,7 @@ namespace Jellyfin.Plugin.Enigma2
|
||||
private int _liveStreams;
|
||||
private readonly LiveStreamProbe _streamProbe;
|
||||
private readonly LiveStreamRelay _streamRelay;
|
||||
private readonly ILibraryManager _library;
|
||||
|
||||
private string tvBouquetSRef;
|
||||
private List<ChannelInfo> tvChannelInfos = new List<ChannelInfo>();
|
||||
@@ -42,12 +46,13 @@ namespace Jellyfin.Plugin.Enigma2
|
||||
|
||||
public static LiveTvService Instance { get; private set; }
|
||||
|
||||
public LiveTvService(ILogger<LiveTvService> logger, IHttpClientFactory httpClientFactory, InternetEpg internetEpg, LiveStreamProbe streamProbe, LiveStreamRelay streamRelay)
|
||||
public LiveTvService(ILogger<LiveTvService> logger, IHttpClientFactory httpClientFactory, InternetEpg internetEpg, LiveStreamProbe streamProbe, LiveStreamRelay streamRelay, ILibraryManager library)
|
||||
{
|
||||
_logger = logger;
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_streamProbe = streamProbe;
|
||||
_streamRelay = streamRelay;
|
||||
_library = library;
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
@@ -1139,6 +1144,26 @@ namespace Jellyfin.Plugin.Enigma2
|
||||
{
|
||||
_logger.LogInformation("[Enigma2] Start GetChannelStream");
|
||||
|
||||
var requestedReference = channelOid;
|
||||
var currentChannels = await GetChannelsAsync(cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
channelOid = ChannelReferenceResolver.Resolve(channelOid, currentChannels, () =>
|
||||
{
|
||||
// Native playback has already checked the user's channel access.
|
||||
// This internal lookup reads only Enigma2 channel metadata and
|
||||
// does not expose items or alter the user's native channel ID.
|
||||
var names = _library.GetItemList(new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { BaseItemKind.LiveTvChannel }
|
||||
}).OfType<LiveTvChannel>()
|
||||
.Where(c => string.Equals(c.ServiceName, "Enigma2", StringComparison.OrdinalIgnoreCase)
|
||||
&& string.Equals(c.ExternalId, requestedReference, StringComparison.OrdinalIgnoreCase))
|
||||
.Select(c => c.Name).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
return names.Length == 1 ? names[0] : null;
|
||||
});
|
||||
if (!string.Equals(channelOid, requestedReference, StringComparison.OrdinalIgnoreCase))
|
||||
_logger.LogInformation("[Enigma2] Resolved saved channel reference {PreviousReference} to current bouquet reference {CurrentReference}", requestedReference, channelOid);
|
||||
|
||||
var protocol = "http";
|
||||
if (Plugin.Instance.Configuration.UseSecureHTTPSForStreams)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user