Update for Jellyfin 10.9

This commit is contained in:
knackebrot
2024-06-22 20:16:55 +02:00
parent 309e7c4110
commit d38c1595d8
4 changed files with 75 additions and 43 deletions
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks> <TargetFrameworks>net8.0</TargetFrameworks>
<AssemblyVersion>5.0.1.0</AssemblyVersion> <AssemblyVersion>6.0.0.0</AssemblyVersion>
<FileVersion>5.0.1.0</FileVersion> <FileVersion>6.0.0.0</FileVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|AnyCPU'">
@@ -11,6 +11,10 @@
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="Configuration\configPage.html" /> <None Remove="Configuration\configPage.html" />
</ItemGroup> </ItemGroup>
@@ -20,12 +24,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Jellyfin.Common" Version="10.8.0" /> <PackageReference Include="Jellyfin.Common" Version="10.9.0" />
<PackageReference Include="Jellyfin.Naming" Version="10.8.0" /> <PackageReference Include="Jellyfin.Naming" Version="10.9.0" />
<PackageReference Include="Jellyfin.Controller" Version="10.8.0" /> <PackageReference Include="Jellyfin.Controller" Version="10.9.0" />
<PackageReference Include="Jellyfin.Model" Version="10.8.0" /> <PackageReference Include="Jellyfin.Model" Version="10.9.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+36 -29
View File
@@ -35,12 +35,15 @@ namespace Jellyfin.Plugin.Enigma2
public DateTime LastRecordingChange = DateTime.MinValue; public DateTime LastRecordingChange = DateTime.MinValue;
private readonly HttpClient _httpClient; private IHttpClientFactory _httpClientFactory;
public static LiveTvService Instance { get; private set; }
public LiveTvService(ILogger<LiveTvService> logger, IHttpClientFactory httpClientFactory) public LiveTvService(ILogger<LiveTvService> logger, IHttpClientFactory httpClientFactory)
{ {
_logger = logger; _logger = logger;
_httpClient = GetHttpClient(httpClientFactory); _httpClientFactory = httpClientFactory;
Instance = this;
} }
@@ -49,7 +52,7 @@ namespace Jellyfin.Plugin.Enigma2
/// </summary> /// </summary>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
private async Task EnsureConnectionAsync(CancellationToken cancellationToken) public async Task EnsureConnectionAsync(CancellationToken cancellationToken)
{ {
_logger.LogInformation("[Enigma2] Start EnsureConnectionAsync"); _logger.LogInformation("[Enigma2] Start EnsureConnectionAsync");
@@ -151,9 +154,9 @@ namespace Jellyfin.Plugin.Enigma2
/// </summary> /// </summary>
/// <param name="httpClientFactory"></param> /// <param name="httpClientFactory"></param>
/// <returns></returns> /// <returns></returns>
private HttpClient GetHttpClient(IHttpClientFactory httpClientFactory) private HttpClient GetHttpClient()
{ {
var httpClient = httpClientFactory.CreateClient(NamedClient.Default); var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
httpClient.DefaultRequestHeaders.UserAgent.Add( httpClient.DefaultRequestHeaders.UserAgent.Add(
new ProductInfoHeaderValue(Name, Plugin.Instance.Version.ToString())); new ProductInfoHeaderValue(Name, Plugin.Instance.Version.ToString()));
@@ -189,7 +192,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/getservices", baseUrl); var url = string.Format("{0}/web/getservices", baseUrl);
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] InitiateSession url: {0}", url)); UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] InitiateSession url: {0}", url));
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false)) using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@@ -290,7 +293,7 @@ namespace Jellyfin.Plugin.Enigma2
baseUrlPicon = protocol + "://" + Plugin.Instance.Configuration.WebInterfaceUsername + ":" + Plugin.Instance.Configuration.WebInterfacePassword + "@" + Plugin.Instance.Configuration.HostName + ":" + Plugin.Instance.Configuration.WebInterfacePort; baseUrlPicon = protocol + "://" + Plugin.Instance.Configuration.WebInterfaceUsername + ":" + Plugin.Instance.Configuration.WebInterfacePassword + "@" + Plugin.Instance.Configuration.HostName + ":" + Plugin.Instance.Configuration.WebInterfacePort;
} }
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false)) using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@@ -454,7 +457,7 @@ namespace Jellyfin.Plugin.Enigma2
baseUrlPicon = protocol + "://" + Plugin.Instance.Configuration.WebInterfaceUsername + ":" + Plugin.Instance.Configuration.WebInterfacePassword + "@" + Plugin.Instance.Configuration.HostName + ":" + Plugin.Instance.Configuration.WebInterfacePort; baseUrlPicon = protocol + "://" + Plugin.Instance.Configuration.WebInterfaceUsername + ":" + Plugin.Instance.Configuration.WebInterfacePassword + "@" + Plugin.Instance.Configuration.HostName + ":" + Plugin.Instance.Configuration.WebInterfacePort;
} }
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false)) using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@@ -555,11 +558,11 @@ namespace Jellyfin.Plugin.Enigma2
/// Gets the Recordings async /// Gets the Recordings async
/// </summary> /// </summary>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{IEnumerable{RecordingInfo}}</returns> /// <returns>Task{IEnumerable{MyRecordingInfo}}</returns>
public async Task<IEnumerable<RecordingInfo>> GetRecordingsAsync(CancellationToken cancellationToken) public async Task<IEnumerable<MyRecordingInfo>> GetRecordingsAsync(CancellationToken cancellationToken)
{ {
await Task.Delay(0); //to avoid await warnings await Task.Delay(0); //to avoid await warnings
return new List<RecordingInfo>(); return new List<MyRecordingInfo>();
} }
public async Task<IEnumerable<MyRecordingInfo>> GetAllRecordingsAsync(CancellationToken cancellationToken) public async Task<IEnumerable<MyRecordingInfo>> GetAllRecordingsAsync(CancellationToken cancellationToken)
@@ -578,7 +581,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/movielist", baseUrl); var url = string.Format("{0}/web/movielist", baseUrl);
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] GetRecordingsAsync url: {0}", url)); UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] GetRecordingsAsync url: {0}", url));
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false)) using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@@ -757,7 +760,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/moviedelete?sRef={1}", baseUrl, recordingId); var url = string.Format("{0}/web/moviedelete?sRef={1}", baseUrl, recordingId);
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] DeleteRecordingAsync url: {0}", url)); UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] DeleteRecordingAsync url: {0}", url));
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false)) using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@@ -772,7 +775,7 @@ namespace Jellyfin.Plugin.Enigma2
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult"); var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
foreach (XmlNode xmlNode in e2simplexmlresult) foreach (XmlNode xmlNode in e2simplexmlresult)
{ {
var recordingInfo = new RecordingInfo(); var recordingInfo = new MyRecordingInfo();
var e2state = "?"; var e2state = "?";
var e2statetext = "?"; var e2statetext = "?";
@@ -837,7 +840,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/timerdelete?sRef={1}&begin={2}&end={3}", baseUrl, sRef, begin, end); var url = string.Format("{0}/web/timerdelete?sRef={1}&begin={2}&end={3}", baseUrl, sRef, begin, end);
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] CancelTimerAsync url: {0}", url)); UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] CancelTimerAsync url: {0}", url));
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false)) using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@@ -852,7 +855,7 @@ namespace Jellyfin.Plugin.Enigma2
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult"); var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
foreach (XmlNode xmlNode in e2simplexmlresult) foreach (XmlNode xmlNode in e2simplexmlresult)
{ {
var recordingInfo = new RecordingInfo(); var recordingInfo = new MyRecordingInfo();
var e2state = "?"; var e2state = "?";
var e2statetext = "?"; var e2statetext = "?";
@@ -920,7 +923,7 @@ namespace Jellyfin.Plugin.Enigma2
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] CreateTimerAsync url: {0}", url)); UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] CreateTimerAsync url: {0}", url));
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false)) using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@@ -935,7 +938,7 @@ namespace Jellyfin.Plugin.Enigma2
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult"); var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
foreach (XmlNode xmlNode in e2simplexmlresult) foreach (XmlNode xmlNode in e2simplexmlresult)
{ {
var recordingInfo = new RecordingInfo(); var recordingInfo = new MyRecordingInfo();
var e2state = "?"; var e2state = "?";
var e2statetext = "?"; var e2statetext = "?";
@@ -992,7 +995,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/timerlist", baseUrl); var url = string.Format("{0}/web/timerlist", baseUrl);
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] GetTimersAsync url: {0}", url)); UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] GetTimersAsync url: {0}", url));
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false)) using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@@ -1215,7 +1218,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/zap?sRef={1}", baseUrl, channelOid); var url = string.Format("{0}/web/zap?sRef={1}", baseUrl, channelOid);
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] ZapToChannel url: {0}", url)); UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] ZapToChannel url: {0}", url));
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false)) using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@@ -1230,7 +1233,7 @@ namespace Jellyfin.Plugin.Enigma2
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult"); var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
foreach (XmlNode xmlNode in e2simplexmlresult) foreach (XmlNode xmlNode in e2simplexmlresult)
{ {
var recordingInfo = new RecordingInfo(); var recordingInfo = new MyRecordingInfo();
var e2state = "?"; var e2state = "?";
var e2statetext = "?"; var e2statetext = "?";
@@ -1314,7 +1317,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/epgservice?sRef={1}", baseUrl, channelId); var url = string.Format("{0}/web/epgservice?sRef={1}", baseUrl, channelId);
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] GetProgramsAsync url: {0}", url)); UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] GetProgramsAsync url: {0}", url));
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false)) using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@@ -1476,7 +1479,7 @@ namespace Jellyfin.Plugin.Enigma2
/// </summary> /// </summary>
/// <param name="cancellationToken">The CancellationToken</param> /// <param name="cancellationToken">The CancellationToken</param>
/// <returns>LiveTvServiceStatusInfo</returns> /// <returns>LiveTvServiceStatusInfo</returns>
public async Task<LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken cancellationToken) /*public async Task<LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken cancellationToken)
{ {
_logger.LogInformation("[Enigma2] Start GetStatusInfoAsync Async, retrieve status details"); _logger.LogInformation("[Enigma2] Start GetStatusInfoAsync Async, retrieve status details");
await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false); await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);
@@ -1555,7 +1558,7 @@ namespace Jellyfin.Plugin.Enigma2
} }
} }
} }*/
/// <summary> /// <summary>
@@ -1581,8 +1584,12 @@ namespace Jellyfin.Plugin.Enigma2
public async Task CloseLiveStream(string id, CancellationToken cancellationToken) public async Task CloseLiveStream(string id, CancellationToken cancellationToken)
{ {
await Task.Delay(0); //to avoid await warnings await Task.Factory.StartNew<string>(() =>
throw new NotImplementedException(); {
_logger.LogDebug("[Enigma2] LiveTvService.CloseLiveStream: closed stream for subscriptionId: {id}", id);
return id;
});
} }
@@ -1676,21 +1683,21 @@ namespace Jellyfin.Plugin.Enigma2
} }
public Task<ImageStream> GetChannelImageAsync(string channelId, CancellationToken cancellationToken) public Task<Stream> GetChannelImageAsync(string channelId, CancellationToken cancellationToken)
{ {
// Leave as is. This is handled by supplying image url to ChannelInfo // Leave as is. This is handled by supplying image url to ChannelInfo
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<ImageStream> GetProgramImageAsync(string programId, string channelId, CancellationToken cancellationToken) public Task<Stream> GetProgramImageAsync(string programId, string channelId, CancellationToken cancellationToken)
{ {
// Leave as is. This is handled by supplying image url to ProgramInfo // Leave as is. This is handled by supplying image url to ProgramInfo
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<ImageStream> GetRecordingImageAsync(string recordingId, CancellationToken cancellationToken) public Task<Stream> GetRecordingImageAsync(string recordingId, CancellationToken cancellationToken)
{ {
// Leave as is. This is handled by supplying image url to RecordingInfo // Leave as is. This is handled by supplying image url to RecordingInfo
throw new NotImplementedException(); throw new NotImplementedException();
+6 -5
View File
@@ -7,23 +7,24 @@ using System.Threading.Tasks;
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Channels; using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.MediaInfo;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Plugin.Enigma2 namespace Jellyfin.Plugin.Enigma2
{ {
public class RecordingsChannel : IChannel, IHasCacheKey, ISupportsDelete, ISupportsLatestMedia, ISupportsMediaProbe, IHasFolderAttributes public class RecordingsChannel : IChannel, IHasCacheKey, ISupportsDelete, ISupportsLatestMedia, ISupportsMediaProbe, IHasFolderAttributes
{ {
public ILiveTvManager _liveTvManager; private readonly ILogger<LiveTvService> _logger;
public RecordingsChannel(ILiveTvManager liveTvManager) public RecordingsChannel(ILoggerFactory loggerFactory)
{ {
_liveTvManager = liveTvManager; _logger = loggerFactory.CreateLogger<LiveTvService>();
_logger.LogDebug("[Enigma2] RecordingsChannel()");
} }
public string Name => "Enigma2 Recordings"; public string Name => "Enigma2 Recordings";
@@ -110,7 +111,7 @@ namespace Jellyfin.Plugin.Enigma2
private LiveTvService GetService() private LiveTvService GetService()
{ {
return _liveTvManager.Services.OfType<LiveTvService>().First(); return LiveTvService.Instance;
} }
public bool CanDelete(BaseItem item) public bool CanDelete(BaseItem item)
@@ -0,0 +1,20 @@
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller;
using Microsoft.Extensions.DependencyInjection;
using System.Net.Http;
using Jellyfin.Plugin.Enigma2.Helpers;
namespace Jellyfin.Plugin.Enigma2
{
public class ServiceRegistrator : IPluginServiceRegistrator
{
/// <inheritdoc />
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
{
serviceCollection.AddSingleton<ILiveTvService, LiveTvService>();
serviceCollection.AddSingleton<IChannel, RecordingsChannel>();
}
}
}