The Free Software Media System - Server Backend & API
update setup wizard
Luke Pulverenti4307c67b5e51
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.csindex e55103230c..c1f8ac3ea1 100644--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs@@ -456,6 +456,20 @@ namespace MediaBrowser.Api.LiveTv{}+ [Route("/LiveTv/Registration", "GET")]+ [Authenticated]+ public class GetLiveTvRegistrationInfo : IReturn<MBRegistrationRecord>+ {+ [ApiMember(Name = "ChannelId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string ChannelId { get; set; }++ [ApiMember(Name = "ProgramId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string ProgramId { get; set; }++ [ApiMember(Name = "Feature", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string Feature { get; set; }+ }+public class LiveTvService : BaseApiService{private readonly ILiveTvManager _liveTvManager;@@ -471,6 +485,13 @@ namespace MediaBrowser.Api.LiveTv_httpClient = httpClient;}+ public async Task<object> Get(GetLiveTvRegistrationInfo request)+ {+ var result = await _liveTvManager.GetRegistrationInfo(request.ChannelId, request.ProgramId, request.Feature).ConfigureAwait(false);++ return ToOptimizedResult(result);+ }+public async Task<object> Get(GetSchedulesDirectCountries request){// https://json.schedulesdirect.org/20141201/available/countriesdiff --git a/MediaBrowser.Controller/LiveTv/IHasRegistrationInfo.cs b/MediaBrowser.Controller/LiveTv/IHasRegistrationInfo.csnew file mode 100644index 0000000000..3626c18e54--- /dev/null+++ b/MediaBrowser.Controller/LiveTv/IHasRegistrationInfo.cs@@ -0,0 +1,15 @@+using MediaBrowser.Model.Entities;+using System.Threading.Tasks;++namespace MediaBrowser.Controller.LiveTv+{+ public interface IHasRegistrationInfo+ {+ /// <summary>+ /// Gets the registration information.+ /// </summary>+ /// <param name="feature">The feature.</param>+ /// <returns>Task<MBRegistrationRecord>.</returns>+ Task<MBRegistrationRecord> GetRegistrationInfo(string feature);+ }+}diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.csindex df09d39b26..2b121eeeb5 100644--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs@@ -2,6 +2,7 @@using MediaBrowser.Controller.Dto;using MediaBrowser.Controller.Entities;using MediaBrowser.Model.Dto;+using MediaBrowser.Model.Entities;using MediaBrowser.Model.LiveTv;using MediaBrowser.Model.Querying;using System.Collections.Generic;@@ -362,5 +363,14 @@ namespace MediaBrowser.Controller.LiveTv/// <param name="location">The location.</param>/// <returns>Task<List<NameIdPair>>.</returns>Task<List<NameIdPair>> GetLineups(string providerType, string providerId, string country, string location);++ /// <summary>+ /// Gets the registration information.+ /// </summary>+ /// <param name="channelId">The channel identifier.</param>+ /// <param name="programId">The program identifier.</param>+ /// <param name="feature">The feature.</param>+ /// <returns>Task<MBRegistrationRecord>.</returns>+ Task<MBRegistrationRecord> GetRegistrationInfo(string channelId, string programId, string feature);}}diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csprojindex b84fe3c712..24309734f8 100644--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj@@ -199,6 +199,7 @@<Compile Include="Library\NameExtensions.cs" /><Compile Include="Library\PlaybackStopEventArgs.cs" /><Compile Include="Library\UserDataSaveEventArgs.cs" />+ <Compile Include="LiveTv\IHasRegistrationInfo.cs" /><Compile Include="LiveTv\IListingsProvider.cs" /><Compile Include="LiveTv\ILiveTvItem.cs" /><Compile Include="LiveTv\ITunerHost.cs" />diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.csindex 200c6c9a6e..708828d479 100644--- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs@@ -2,9 +2,11 @@using MediaBrowser.Common.Configuration;using MediaBrowser.Common.IO;using MediaBrowser.Common.Net;+using MediaBrowser.Common.Security;using MediaBrowser.Controller.Drawing;using MediaBrowser.Controller.LiveTv;using MediaBrowser.Model.Dto;+using MediaBrowser.Model.Entities;using MediaBrowser.Model.Events;using MediaBrowser.Model.LiveTv;using MediaBrowser.Model.Logging;@@ -19,7 +21,7 @@ using System.Threading.Tasks;namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV{- public class EmbyTV : ILiveTvService, IDisposable+ public class EmbyTV : ILiveTvService, IHasRegistrationInfo, IDisposable{private readonly IApplicationHost _appHpst;private readonly ILogger _logger;@@ -33,10 +35,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTVprivate readonly LiveTvManager _liveTvManager;private readonly IFileSystem _fileSystem;+ private readonly ISecurityManager _security;public static EmbyTV Current;- public EmbyTV(IApplicationHost appHost, ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem)+ public EmbyTV(IApplicationHost appHost, ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ISecurityManager security){Current = this;@@ -45,6 +48,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV_httpClient = httpClient;_config = config;_fileSystem = fileSystem;+ _security = security;_liveTvManager = (LiveTvManager)liveTvManager;_jsonSerializer = jsonSerializer;@@ -629,9 +633,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV.Where(i => string.Equals(i.SeriesTimerId, seriesTimer.Id, StringComparison.OrdinalIgnoreCase)).ToList();- foreach (var timer in newTimers)+ var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);++ if (registration.IsValid){- _timerProvider.AddOrUpdate(timer);+ foreach (var timer in newTimers)+ {+ _timerProvider.AddOrUpdate(timer);+ }}var newTimerIds = newTimers.Select(i => i.Id).ToList();@@ -728,5 +737,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTVpair.Value.Cancel();}}++ public Task<MBRegistrationRecord> GetRegistrationInfo(string feature)+ {+ if (string.Equals(feature, "seriesrecordings", StringComparison.OrdinalIgnoreCase))+ {+ return _security.GetRegistrationStatus("embytvseriesrecordings");+ }++ return Task.FromResult(new MBRegistrationRecord+ {+ IsValid = true,+ IsRegistered = true+ });+ }}}diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex cabe04f0fb..4109617dbb 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -2286,5 +2286,34 @@ namespace MediaBrowser.Server.Implementations.LiveTvreturn provider.GetLineups(info, country, location);}}++ public Task<MBRegistrationRecord> GetRegistrationInfo(string channelId, string programId, string feature)+ {+ ILiveTvService service;++ if (string.IsNullOrWhiteSpace(programId))+ {+ var channel = GetInternalChannel(channelId);+ service = GetService(channel);+ }+ else+ {+ var program = GetInternalProgram(programId);+ service = GetService(program);+ }++ var hasRegistration = service as IHasRegistrationInfo;++ if (hasRegistration != null)+ {+ return hasRegistration.GetRegistrationInfo(feature);+ }++ return Task.FromResult(new MBRegistrationRecord+ {+ IsValid = true,+ IsRegistered = true+ });+ }}}