Skip to content

Commit d38c159

Browse files
committed
Update for Jellyfin 10.9
1 parent 309e7c4 commit d38c159

File tree

4 files changed

+75
-43
lines changed

4 files changed

+75
-43
lines changed
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0</TargetFrameworks>
5-
<AssemblyVersion>5.0.1.0</AssemblyVersion>
6-
<FileVersion>5.0.1.0</FileVersion>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
5+
<AssemblyVersion>6.0.0.0</AssemblyVersion>
6+
<FileVersion>6.0.0.0</FileVersion>
77
</PropertyGroup>
88

99
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|AnyCPU'">
1010
<DebugType>none</DebugType>
1111
<DebugSymbols>false</DebugSymbols>
1212
</PropertyGroup>
1313

14+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0|AnyCPU'">
15+
<DebugType>none</DebugType>
16+
</PropertyGroup>
17+
1418
<ItemGroup>
1519
<None Remove="Configuration\configPage.html" />
1620
</ItemGroup>
@@ -20,12 +24,12 @@
2024
</ItemGroup>
2125

2226
<ItemGroup>
23-
<PackageReference Include="Jellyfin.Common" Version="10.8.0" />
24-
<PackageReference Include="Jellyfin.Naming" Version="10.8.0" />
25-
<PackageReference Include="Jellyfin.Controller" Version="10.8.0" />
26-
<PackageReference Include="Jellyfin.Model" Version="10.8.0" />
27-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
28-
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
27+
<PackageReference Include="Jellyfin.Common" Version="10.9.0" />
28+
<PackageReference Include="Jellyfin.Naming" Version="10.9.0" />
29+
<PackageReference Include="Jellyfin.Controller" Version="10.9.0" />
30+
<PackageReference Include="Jellyfin.Model" Version="10.9.0" />
31+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
32+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
2933
</ItemGroup>
3034

3135
</Project>

Jellyfin.Plugin.Enigma2/LiveTvService.cs

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ public class LiveTvService : ILiveTvService
3535

3636
public DateTime LastRecordingChange = DateTime.MinValue;
3737

38-
private readonly HttpClient _httpClient;
38+
private IHttpClientFactory _httpClientFactory;
39+
40+
public static LiveTvService Instance { get; private set; }
3941

4042
public LiveTvService(ILogger<LiveTvService> logger, IHttpClientFactory httpClientFactory)
4143
{
4244
_logger = logger;
43-
_httpClient = GetHttpClient(httpClientFactory);
45+
_httpClientFactory = httpClientFactory;
46+
Instance = this;
4447
}
4548

4649

@@ -49,7 +52,7 @@ public LiveTvService(ILogger<LiveTvService> logger, IHttpClientFactory httpClien
4952
/// </summary>
5053
/// <param name="cancellationToken"></param>
5154
/// <returns></returns>
52-
private async Task EnsureConnectionAsync(CancellationToken cancellationToken)
55+
public async Task EnsureConnectionAsync(CancellationToken cancellationToken)
5356
{
5457
_logger.LogInformation("[Enigma2] Start EnsureConnectionAsync");
5558

@@ -151,9 +154,9 @@ private async Task EnsureConnectionAsync(CancellationToken cancellationToken)
151154
/// </summary>
152155
/// <param name="httpClientFactory"></param>
153156
/// <returns></returns>
154-
private HttpClient GetHttpClient(IHttpClientFactory httpClientFactory)
157+
private HttpClient GetHttpClient()
155158
{
156-
var httpClient = httpClientFactory.CreateClient(NamedClient.Default);
159+
var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
157160
httpClient.DefaultRequestHeaders.UserAgent.Add(
158161
new ProductInfoHeaderValue(Name, Plugin.Instance.Version.ToString()));
159162

@@ -189,7 +192,7 @@ public async Task<string> InitiateSession(CancellationToken cancellationToken, s
189192
var url = string.Format("{0}/web/getservices", baseUrl);
190193
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] InitiateSession url: {0}", url));
191194

192-
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
195+
using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
193196
{
194197
using (var reader = new StreamReader(stream))
195198
{
@@ -290,7 +293,7 @@ public async Task<IEnumerable<ChannelInfo>> GetChannelsAsync(CancellationToken c
290293
baseUrlPicon = protocol + "://" + Plugin.Instance.Configuration.WebInterfaceUsername + ":" + Plugin.Instance.Configuration.WebInterfacePassword + "@" + Plugin.Instance.Configuration.HostName + ":" + Plugin.Instance.Configuration.WebInterfacePort;
291294
}
292295

293-
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
296+
using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
294297
{
295298
using (var reader = new StreamReader(stream))
296299
{
@@ -454,7 +457,7 @@ public async Task<List<ChannelInfo>> GetChannelsForTVBouquetAsync(CancellationTo
454457
baseUrlPicon = protocol + "://" + Plugin.Instance.Configuration.WebInterfaceUsername + ":" + Plugin.Instance.Configuration.WebInterfacePassword + "@" + Plugin.Instance.Configuration.HostName + ":" + Plugin.Instance.Configuration.WebInterfacePort;
455458
}
456459

457-
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
460+
using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
458461
{
459462
using (var reader = new StreamReader(stream))
460463
{
@@ -555,11 +558,11 @@ public async Task<List<ChannelInfo>> GetChannelsForTVBouquetAsync(CancellationTo
555558
/// Gets the Recordings async
556559
/// </summary>
557560
/// <param name="cancellationToken">The cancellation token.</param>
558-
/// <returns>Task{IEnumerable{RecordingInfo}}</returns>
559-
public async Task<IEnumerable<RecordingInfo>> GetRecordingsAsync(CancellationToken cancellationToken)
561+
/// <returns>Task{IEnumerable{MyRecordingInfo}}</returns>
562+
public async Task<IEnumerable<MyRecordingInfo>> GetRecordingsAsync(CancellationToken cancellationToken)
560563
{
561564
await Task.Delay(0); //to avoid await warnings
562-
return new List<RecordingInfo>();
565+
return new List<MyRecordingInfo>();
563566
}
564567

565568
public async Task<IEnumerable<MyRecordingInfo>> GetAllRecordingsAsync(CancellationToken cancellationToken)
@@ -578,7 +581,7 @@ public async Task<IEnumerable<MyRecordingInfo>> GetAllRecordingsAsync(Cancellati
578581
var url = string.Format("{0}/web/movielist", baseUrl);
579582
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] GetRecordingsAsync url: {0}", url));
580583

581-
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
584+
using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
582585
{
583586
using (var reader = new StreamReader(stream))
584587
{
@@ -757,7 +760,7 @@ public async Task DeleteRecordingAsync(string recordingId, CancellationToken can
757760
var url = string.Format("{0}/web/moviedelete?sRef={1}", baseUrl, recordingId);
758761
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] DeleteRecordingAsync url: {0}", url));
759762

760-
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
763+
using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
761764
{
762765
using (var reader = new StreamReader(stream))
763766
{
@@ -772,7 +775,7 @@ public async Task DeleteRecordingAsync(string recordingId, CancellationToken can
772775
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
773776
foreach (XmlNode xmlNode in e2simplexmlresult)
774777
{
775-
var recordingInfo = new RecordingInfo();
778+
var recordingInfo = new MyRecordingInfo();
776779

777780
var e2state = "?";
778781
var e2statetext = "?";
@@ -837,7 +840,7 @@ public async Task CancelTimerAsync(string timerId, CancellationToken cancellatio
837840
var url = string.Format("{0}/web/timerdelete?sRef={1}&begin={2}&end={3}", baseUrl, sRef, begin, end);
838841
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] CancelTimerAsync url: {0}", url));
839842

840-
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
843+
using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
841844
{
842845
using (var reader = new StreamReader(stream))
843846
{
@@ -852,7 +855,7 @@ public async Task CancelTimerAsync(string timerId, CancellationToken cancellatio
852855
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
853856
foreach (XmlNode xmlNode in e2simplexmlresult)
854857
{
855-
var recordingInfo = new RecordingInfo();
858+
var recordingInfo = new MyRecordingInfo();
856859

857860
var e2state = "?";
858861
var e2statetext = "?";
@@ -920,7 +923,7 @@ public async Task CreateTimerAsync(TimerInfo info, CancellationToken cancellatio
920923

921924
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] CreateTimerAsync url: {0}", url));
922925

923-
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
926+
using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
924927
{
925928
using (var reader = new StreamReader(stream))
926929
{
@@ -935,7 +938,7 @@ public async Task CreateTimerAsync(TimerInfo info, CancellationToken cancellatio
935938
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
936939
foreach (XmlNode xmlNode in e2simplexmlresult)
937940
{
938-
var recordingInfo = new RecordingInfo();
941+
var recordingInfo = new MyRecordingInfo();
939942

940943
var e2state = "?";
941944
var e2statetext = "?";
@@ -992,7 +995,7 @@ public async Task<IEnumerable<TimerInfo>> GetTimersAsync(CancellationToken cance
992995
var url = string.Format("{0}/web/timerlist", baseUrl);
993996
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] GetTimersAsync url: {0}", url));
994997

995-
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
998+
using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
996999
{
9971000
using (var reader = new StreamReader(stream))
9981001
{
@@ -1215,7 +1218,7 @@ public async Task ZapToChannel(CancellationToken cancellationToken, string chann
12151218
var url = string.Format("{0}/web/zap?sRef={1}", baseUrl, channelOid);
12161219
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] ZapToChannel url: {0}", url));
12171220

1218-
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
1221+
using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
12191222
{
12201223
using (var reader = new StreamReader(stream))
12211224
{
@@ -1230,7 +1233,7 @@ public async Task ZapToChannel(CancellationToken cancellationToken, string chann
12301233
var e2simplexmlresult = xml.GetElementsByTagName("e2simplexmlresult");
12311234
foreach (XmlNode xmlNode in e2simplexmlresult)
12321235
{
1233-
var recordingInfo = new RecordingInfo();
1236+
var recordingInfo = new MyRecordingInfo();
12341237

12351238
var e2state = "?";
12361239
var e2statetext = "?";
@@ -1314,7 +1317,7 @@ public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(string channelId, D
13141317
var url = string.Format("{0}/web/epgservice?sRef={1}", baseUrl, channelId);
13151318
UtilsHelper.DebugInformation(_logger, string.Format("[Enigma2] GetProgramsAsync url: {0}", url));
13161319

1317-
using (var stream = await _httpClient.GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
1320+
using (var stream = await GetHttpClient().GetStreamAsync(url, cancellationToken).ConfigureAwait(false))
13181321
{
13191322
using (var reader = new StreamReader(stream))
13201323
{
@@ -1476,7 +1479,7 @@ public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(string channelId, D
14761479
/// </summary>
14771480
/// <param name="cancellationToken">The CancellationToken</param>
14781481
/// <returns>LiveTvServiceStatusInfo</returns>
1479-
public async Task<LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken cancellationToken)
1482+
/*public async Task<LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken cancellationToken)
14801483
{
14811484
_logger.LogInformation("[Enigma2] Start GetStatusInfoAsync Async, retrieve status details");
14821485
await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);
@@ -1555,7 +1558,7 @@ public async Task<LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken
15551558
15561559
}
15571560
}
1558-
}
1561+
}*/
15591562

15601563

15611564
/// <summary>
@@ -1581,8 +1584,12 @@ public async Task<MediaSourceInfo> GetRecordingStream(string recordingId, string
15811584

15821585
public async Task CloseLiveStream(string id, CancellationToken cancellationToken)
15831586
{
1584-
await Task.Delay(0); //to avoid await warnings
1585-
throw new NotImplementedException();
1587+
await Task.Factory.StartNew<string>(() =>
1588+
{
1589+
_logger.LogDebug("[Enigma2] LiveTvService.CloseLiveStream: closed stream for subscriptionId: {id}", id);
1590+
return id;
1591+
});
1592+
15861593
}
15871594

15881595

@@ -1676,21 +1683,21 @@ public Task ResetTuner(string id, CancellationToken cancellationToken)
16761683
}
16771684

16781685

1679-
public Task<ImageStream> GetChannelImageAsync(string channelId, CancellationToken cancellationToken)
1686+
public Task<Stream> GetChannelImageAsync(string channelId, CancellationToken cancellationToken)
16801687
{
16811688
// Leave as is. This is handled by supplying image url to ChannelInfo
16821689
throw new NotImplementedException();
16831690
}
16841691

16851692

1686-
public Task<ImageStream> GetProgramImageAsync(string programId, string channelId, CancellationToken cancellationToken)
1693+
public Task<Stream> GetProgramImageAsync(string programId, string channelId, CancellationToken cancellationToken)
16871694
{
16881695
// Leave as is. This is handled by supplying image url to ProgramInfo
16891696
throw new NotImplementedException();
16901697
}
16911698

16921699

1693-
public Task<ImageStream> GetRecordingImageAsync(string recordingId, CancellationToken cancellationToken)
1700+
public Task<Stream> GetRecordingImageAsync(string recordingId, CancellationToken cancellationToken)
16941701
{
16951702
// Leave as is. This is handled by supplying image url to RecordingInfo
16961703
throw new NotImplementedException();

Jellyfin.Plugin.Enigma2/RecordingsChannel.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@
77
using MediaBrowser.Common.Extensions;
88
using MediaBrowser.Controller.Channels;
99
using MediaBrowser.Controller.Entities;
10-
using MediaBrowser.Controller.LiveTv;
1110
using MediaBrowser.Controller.Providers;
1211
using MediaBrowser.Model.Channels;
1312
using MediaBrowser.Model.Dto;
1413
using MediaBrowser.Model.Entities;
1514
using MediaBrowser.Model.LiveTv;
1615
using MediaBrowser.Model.MediaInfo;
16+
using Microsoft.Extensions.Logging;
1717

1818
namespace Jellyfin.Plugin.Enigma2
1919
{
2020
public class RecordingsChannel : IChannel, IHasCacheKey, ISupportsDelete, ISupportsLatestMedia, ISupportsMediaProbe, IHasFolderAttributes
2121
{
22-
public ILiveTvManager _liveTvManager;
22+
private readonly ILogger<LiveTvService> _logger;
2323

24-
public RecordingsChannel(ILiveTvManager liveTvManager)
24+
public RecordingsChannel(ILoggerFactory loggerFactory)
2525
{
26-
_liveTvManager = liveTvManager;
26+
_logger = loggerFactory.CreateLogger<LiveTvService>();
27+
_logger.LogDebug("[Enigma2] RecordingsChannel()");
2728
}
2829

2930
public string Name => "Enigma2 Recordings";
@@ -110,7 +111,7 @@ public bool IsEnabledFor(string userId)
110111

111112
private LiveTvService GetService()
112113
{
113-
return _liveTvManager.Services.OfType<LiveTvService>().First();
114+
return LiveTvService.Instance;
114115
}
115116

116117
public bool CanDelete(BaseItem item)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using MediaBrowser.Controller.Channels;
2+
using MediaBrowser.Controller.LiveTv;
3+
using MediaBrowser.Controller.Plugins;
4+
using MediaBrowser.Controller;
5+
using Microsoft.Extensions.DependencyInjection;
6+
using System.Net.Http;
7+
using Jellyfin.Plugin.Enigma2.Helpers;
8+
9+
namespace Jellyfin.Plugin.Enigma2
10+
{
11+
public class ServiceRegistrator : IPluginServiceRegistrator
12+
{
13+
/// <inheritdoc />
14+
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
15+
{
16+
serviceCollection.AddSingleton<ILiveTvService, LiveTvService>();
17+
serviceCollection.AddSingleton<IChannel, RecordingsChannel>();
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)