aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/LiveTv/LiveTvManager.cs')
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvManager.cs85
1 files changed, 29 insertions, 56 deletions
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index b597a935a..c360a6a82 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller.Configuration;
@@ -22,7 +22,6 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.IO;
-using MediaBrowser.Common.Security;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Events;
@@ -51,7 +50,6 @@ namespace Emby.Server.Implementations.LiveTv
private readonly ITaskManager _taskManager;
private readonly IJsonSerializer _jsonSerializer;
private readonly IProviderManager _providerManager;
- private readonly ISecurityManager _security;
private readonly Func<IChannelManager> _channelManager;
private readonly IDtoService _dtoService;
@@ -78,7 +76,23 @@ namespace Emby.Server.Implementations.LiveTv
private IServerApplicationHost _appHost;
private IHttpClient _httpClient;
- public LiveTvManager(IServerApplicationHost appHost, IHttpClient httpClient, IServerConfigurationManager config, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer, IProviderManager providerManager, IFileSystem fileSystem, ISecurityManager security, Func<IChannelManager> channelManager)
+ public LiveTvManager(
+ IServerApplicationHost appHost,
+ IHttpClient httpClient,
+ IServerConfigurationManager config,
+ ILogger logger,
+ IItemRepository itemRepo,
+ IImageProcessor imageProcessor,
+ IUserDataManager userDataManager,
+ IDtoService dtoService,
+ IUserManager userManager,
+ ILibraryManager libraryManager,
+ ITaskManager taskManager,
+ ILocalizationManager localization,
+ IJsonSerializer jsonSerializer,
+ IProviderManager providerManager,
+ IFileSystem fileSystem,
+ Func<IChannelManager> channelManager)
{
_appHost = appHost;
_config = config;
@@ -91,7 +105,6 @@ namespace Emby.Server.Implementations.LiveTv
_jsonSerializer = jsonSerializer;
_providerManager = providerManager;
_fileSystem = fileSystem;
- _security = security;
_dtoService = dtoService;
_userDataManager = userDataManager;
_channelManager = channelManager;
@@ -104,10 +117,7 @@ namespace Emby.Server.Implementations.LiveTv
/// Gets the services.
/// </summary>
/// <value>The services.</value>
- public IReadOnlyList<ILiveTvService> Services
- {
- get { return _services; }
- }
+ public IReadOnlyList<ILiveTvService> Services => _services;
private LiveTvOptions GetConfiguration()
{
@@ -167,15 +177,9 @@ namespace Emby.Server.Implementations.LiveTv
});
}
- public ITunerHost[] TunerHosts
- {
- get { return _tunerHosts; }
- }
+ public ITunerHost[] TunerHosts => _tunerHosts;
- public IListingsProvider[] ListingProviders
- {
- get { return _listingProviders; }
- }
+ public IListingsProvider[] ListingProviders => _listingProviders;
public List<NameIdPair> GetTunerHostTypes()
{
@@ -323,7 +327,7 @@ namespace Emby.Server.Implementations.LiveTv
return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
}
- private void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo)
+ private static void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo)
{
// Not all of the plugins are setting this
mediaSource.IsInfiniteStream = true;
@@ -1056,7 +1060,7 @@ namespace Emby.Server.Implementations.LiveTv
var numComplete = 0;
double progressPerService = _services.Length == 0
? 0
- : 1 / _services.Length;
+ : 1.0 / _services.Length;
var newChannelIdList = new List<Guid>();
var newProgramIdList = new List<Guid>();
@@ -1262,7 +1266,7 @@ namespace Emby.Server.Implementations.LiveTv
}
numComplete++;
- double percent = numComplete / allChannelsList.Count;
+ double percent = numComplete / (double) allChannelsList.Count;
progress.Report(85 * percent + 15);
}
@@ -1307,7 +1311,7 @@ namespace Emby.Server.Implementations.LiveTv
}
numComplete++;
- double percent = numComplete / list.Count;
+ double percent = numComplete / (double) list.Count;
progress.Report(100 * percent);
}
@@ -1418,6 +1422,7 @@ namespace Emby.Server.Implementations.LiveTv
if (query.IsInProgress ?? false)
{
+ //TODO Fix The co-variant conversion between Video[] and BaseItem[], this can generate runtime issues.
result.Items = result
.Items
.OfType<Video>()
@@ -1993,7 +1998,7 @@ namespace Emby.Server.Implementations.LiveTv
Name = program.Name,
OfficialRating = program.OfficialRating
};
- }
+ }
if (service == null)
{
@@ -2095,14 +2100,6 @@ namespace Emby.Server.Implementations.LiveTv
public async Task CreateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken)
{
- var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
-
- if (!registration.IsValid)
- {
- _logger.LogInformation("Creating series recordings requires an active Emby Premiere subscription.");
- return;
- }
-
var service = GetService(timer.ServiceName);
var info = await _tvDtoService.GetSeriesTimerInfo(timer, true, this, cancellationToken).ConfigureAwait(false);
@@ -2188,7 +2185,7 @@ namespace Emby.Server.Implementations.LiveTv
return Services.Select(GetServiceInfo).ToArray();
}
- private LiveTvServiceInfo GetServiceInfo(ILiveTvService service)
+ private static LiveTvServiceInfo GetServiceInfo(ILiveTvService service)
{
return new LiveTvServiceInfo
{
@@ -2245,7 +2242,7 @@ namespace Emby.Server.Implementations.LiveTv
return service.ResetTuner(parts[1], cancellationToken);
}
- private void RemoveFields(DtoOptions options)
+ private static void RemoveFields(DtoOptions options)
{
var fields = options.Fields.ToList();
@@ -2444,30 +2441,6 @@ namespace Emby.Server.Implementations.LiveTv
}
}
- public Task<MBRegistrationRecord> GetRegistrationInfo(string feature)
- {
- if (string.Equals(feature, "seriesrecordings", StringComparison.OrdinalIgnoreCase))
- {
- feature = "embytvseriesrecordings";
- }
-
- if (string.Equals(feature, "dvr-l", StringComparison.OrdinalIgnoreCase))
- {
- var config = GetConfiguration();
- if (config.TunerHosts.Length > 0 &&
- config.ListingProviders.Count(i => (i.EnableAllTuners || i.EnabledTuners.Length > 0) && string.Equals(i.Type, SchedulesDirect.TypeName, StringComparison.OrdinalIgnoreCase)) > 0)
- {
- return Task.FromResult(new MBRegistrationRecord
- {
- IsRegistered = true,
- IsValid = true
- });
- }
- }
-
- return _security.GetRegistrationStatus(feature);
- }
-
public Task<List<ChannelInfo>> GetChannelsForListingsProvider(string id, CancellationToken cancellationToken)
{
var info = GetConfiguration().ListingProviders.First(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase));