diff --git a/Jellyfin.Plugin.Enigma2/Jellyfin.Plugin.Enigma2.csproj b/Jellyfin.Plugin.Enigma2/Jellyfin.Plugin.Enigma2.csproj
index 6ab3b71..2383243 100644
--- a/Jellyfin.Plugin.Enigma2/Jellyfin.Plugin.Enigma2.csproj
+++ b/Jellyfin.Plugin.Enigma2/Jellyfin.Plugin.Enigma2.csproj
@@ -1,9 +1,9 @@
- net6.0
- 5.0.1.0
- 5.0.1.0
+ net8.0
+ 6.0.0.0
+ 6.0.0.0
@@ -11,6 +11,10 @@
false
+
+ none
+
+
@@ -20,12 +24,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/Jellyfin.Plugin.Enigma2/LiveTvService.cs b/Jellyfin.Plugin.Enigma2/LiveTvService.cs
index 654af5a..8e3ec14 100644
--- a/Jellyfin.Plugin.Enigma2/LiveTvService.cs
+++ b/Jellyfin.Plugin.Enigma2/LiveTvService.cs
@@ -35,12 +35,15 @@ namespace Jellyfin.Plugin.Enigma2
public DateTime LastRecordingChange = DateTime.MinValue;
- private readonly HttpClient _httpClient;
+ private IHttpClientFactory _httpClientFactory;
+
+ public static LiveTvService Instance { get; private set; }
public LiveTvService(ILogger logger, IHttpClientFactory httpClientFactory)
{
_logger = logger;
- _httpClient = GetHttpClient(httpClientFactory);
+ _httpClientFactory = httpClientFactory;
+ Instance = this;
}
@@ -49,7 +52,7 @@ namespace Jellyfin.Plugin.Enigma2
///
///
///
- private async Task EnsureConnectionAsync(CancellationToken cancellationToken)
+ public async Task EnsureConnectionAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("[Enigma2] Start EnsureConnectionAsync");
@@ -151,9 +154,9 @@ namespace Jellyfin.Plugin.Enigma2
///
///
///
- private HttpClient GetHttpClient(IHttpClientFactory httpClientFactory)
+ private HttpClient GetHttpClient()
{
- var httpClient = httpClientFactory.CreateClient(NamedClient.Default);
+ var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
httpClient.DefaultRequestHeaders.UserAgent.Add(
new ProductInfoHeaderValue(Name, Plugin.Instance.Version.ToString()));
@@ -189,7 +192,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/getservices", baseUrl);
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))
{
@@ -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;
}
- 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))
{
@@ -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;
}
- 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))
{
@@ -555,11 +558,11 @@ namespace Jellyfin.Plugin.Enigma2
/// Gets the Recordings async
///
/// The cancellation token.
- /// Task{IEnumerable{RecordingInfo}}
- public async Task> GetRecordingsAsync(CancellationToken cancellationToken)
+ /// Task{IEnumerable{MyRecordingInfo}}
+ public async Task> GetRecordingsAsync(CancellationToken cancellationToken)
{
await Task.Delay(0); //to avoid await warnings
- return new List();
+ return new List();
}
public async Task> GetAllRecordingsAsync(CancellationToken cancellationToken)
@@ -578,7 +581,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/movielist", baseUrl);
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))
{
@@ -757,7 +760,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/moviedelete?sRef={1}", baseUrl, recordingId);
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))
{
@@ -772,7 +775,7 @@ namespace Jellyfin.Plugin.Enigma2
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
foreach (XmlNode xmlNode in e2simplexmlresult)
{
- var recordingInfo = new RecordingInfo();
+ var recordingInfo = new MyRecordingInfo();
var e2state = "?";
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);
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))
{
@@ -852,7 +855,7 @@ namespace Jellyfin.Plugin.Enigma2
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
foreach (XmlNode xmlNode in e2simplexmlresult)
{
- var recordingInfo = new RecordingInfo();
+ var recordingInfo = new MyRecordingInfo();
var e2state = "?";
var e2statetext = "?";
@@ -920,7 +923,7 @@ namespace Jellyfin.Plugin.Enigma2
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))
{
@@ -935,7 +938,7 @@ namespace Jellyfin.Plugin.Enigma2
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
foreach (XmlNode xmlNode in e2simplexmlresult)
{
- var recordingInfo = new RecordingInfo();
+ var recordingInfo = new MyRecordingInfo();
var e2state = "?";
var e2statetext = "?";
@@ -992,7 +995,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/timerlist", baseUrl);
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))
{
@@ -1215,7 +1218,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/zap?sRef={1}", baseUrl, channelOid);
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))
{
@@ -1230,7 +1233,7 @@ namespace Jellyfin.Plugin.Enigma2
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
foreach (XmlNode xmlNode in e2simplexmlresult)
{
- var recordingInfo = new RecordingInfo();
+ var recordingInfo = new MyRecordingInfo();
var e2state = "?";
var e2statetext = "?";
@@ -1314,7 +1317,7 @@ namespace Jellyfin.Plugin.Enigma2
var url = string.Format("{0}/web/epgservice?sRef={1}", baseUrl, channelId);
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))
{
@@ -1476,7 +1479,7 @@ namespace Jellyfin.Plugin.Enigma2
///
/// The CancellationToken
/// LiveTvServiceStatusInfo
- public async Task GetStatusInfoAsync(CancellationToken cancellationToken)
+ /*public async Task GetStatusInfoAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("[Enigma2] Start GetStatusInfoAsync Async, retrieve status details");
await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);
@@ -1555,7 +1558,7 @@ namespace Jellyfin.Plugin.Enigma2
}
}
- }
+ }*/
///
@@ -1581,8 +1584,12 @@ namespace Jellyfin.Plugin.Enigma2
public async Task CloseLiveStream(string id, CancellationToken cancellationToken)
{
- await Task.Delay(0); //to avoid await warnings
- throw new NotImplementedException();
+ await Task.Factory.StartNew(() =>
+ {
+ _logger.LogDebug("[Enigma2] LiveTvService.CloseLiveStream: closed stream for subscriptionId: {id}", id);
+ return id;
+ });
+
}
@@ -1676,21 +1683,21 @@ namespace Jellyfin.Plugin.Enigma2
}
- public Task GetChannelImageAsync(string channelId, CancellationToken cancellationToken)
+ public Task GetChannelImageAsync(string channelId, CancellationToken cancellationToken)
{
// Leave as is. This is handled by supplying image url to ChannelInfo
throw new NotImplementedException();
}
- public Task GetProgramImageAsync(string programId, string channelId, CancellationToken cancellationToken)
+ public Task GetProgramImageAsync(string programId, string channelId, CancellationToken cancellationToken)
{
// Leave as is. This is handled by supplying image url to ProgramInfo
throw new NotImplementedException();
}
- public Task GetRecordingImageAsync(string recordingId, CancellationToken cancellationToken)
+ public Task GetRecordingImageAsync(string recordingId, CancellationToken cancellationToken)
{
// Leave as is. This is handled by supplying image url to RecordingInfo
throw new NotImplementedException();
diff --git a/Jellyfin.Plugin.Enigma2/RecordingsChannel.cs b/Jellyfin.Plugin.Enigma2/RecordingsChannel.cs
index 56a5b66..8934031 100644
--- a/Jellyfin.Plugin.Enigma2/RecordingsChannel.cs
+++ b/Jellyfin.Plugin.Enigma2/RecordingsChannel.cs
@@ -7,23 +7,24 @@ using System.Threading.Tasks;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.MediaInfo;
+using Microsoft.Extensions.Logging;
namespace Jellyfin.Plugin.Enigma2
{
public class RecordingsChannel : IChannel, IHasCacheKey, ISupportsDelete, ISupportsLatestMedia, ISupportsMediaProbe, IHasFolderAttributes
{
- public ILiveTvManager _liveTvManager;
+ private readonly ILogger _logger;
- public RecordingsChannel(ILiveTvManager liveTvManager)
+ public RecordingsChannel(ILoggerFactory loggerFactory)
{
- _liveTvManager = liveTvManager;
+ _logger = loggerFactory.CreateLogger();
+ _logger.LogDebug("[Enigma2] RecordingsChannel()");
}
public string Name => "Enigma2 Recordings";
@@ -110,7 +111,7 @@ namespace Jellyfin.Plugin.Enigma2
private LiveTvService GetService()
{
- return _liveTvManager.Services.OfType().First();
+ return LiveTvService.Instance;
}
public bool CanDelete(BaseItem item)
diff --git a/Jellyfin.Plugin.Enigma2/ServiceRegistrator.cs b/Jellyfin.Plugin.Enigma2/ServiceRegistrator.cs
new file mode 100644
index 0000000..592aaf5
--- /dev/null
+++ b/Jellyfin.Plugin.Enigma2/ServiceRegistrator.cs
@@ -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
+ {
+ ///
+ public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
+ {
+ serviceCollection.AddSingleton();
+ serviceCollection.AddSingleton();
+ }
+ }
+}