diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
index bdf072b50..f7b4cf373 100644
--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
@@ -223,7 +223,10 @@ namespace MediaBrowser.Model.Configuration
public string TranscodingTempPath { get; set; }
public bool EnableAutomaticRestart { get; set; }
-
+
+
+ public LiveTvOptions LiveTvOptions { get; set; }
+
///
/// Initializes a new instance of the class.
///
@@ -287,6 +290,8 @@ namespace MediaBrowser.Model.Configuration
{
MaxBackdrops = 1
};
+
+ LiveTvOptions = new LiveTvOptions();
}
}
@@ -303,4 +308,9 @@ namespace MediaBrowser.Model.Configuration
HighQuality,
MaxQuality
}
+
+ public class LiveTvOptions
+ {
+ public int? GuideDays { get; set; }
+ }
}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 91766e0f8..ef8f515f5 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -1,6 +1,7 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller;
+using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -27,7 +28,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
///
public class LiveTvManager : ILiveTvManager, IDisposable
{
- private readonly IServerApplicationPaths _appPaths;
+ private readonly IServerConfigurationManager _config;
private readonly IFileSystem _fileSystem;
private readonly ILogger _logger;
private readonly IItemRepository _itemRepo;
@@ -46,9 +47,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private List _channelIdList = new List();
private Dictionary _programs = new Dictionary();
- public LiveTvManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, IMediaEncoder mediaEncoder)
+ public LiveTvManager(IServerConfigurationManager config, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, IMediaEncoder mediaEncoder)
{
- _appPaths = appPaths;
+ _config = config;
_fileSystem = fileSystem;
_logger = logger;
_itemRepo = itemRepo;
@@ -217,7 +218,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private async Task GetChannel(ChannelInfo channelInfo, string serviceName, CancellationToken cancellationToken)
{
- var path = Path.Combine(_appPaths.ItemsByNamePath, "channels", _fileSystem.GetValidFilename(channelInfo.Name));
+ var path = Path.Combine(_config.ApplicationPaths.ItemsByNamePath, "channels", _fileSystem.GetValidFilename(channelInfo.Name));
var fileInfo = new DirectoryInfo(path);
@@ -659,6 +660,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
numComplete = 0;
var programs = new List();
+ var guideDays = GetGuideDays(list.Count);
+
foreach (var item in list)
{
// Avoid implicitly captured closure
@@ -666,8 +669,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
try
{
- var start = DateTime.UtcNow;
- var end = start.AddDays(3);
+ var start = DateTime.UtcNow.AddHours(-1);
+ var end = start.AddDays(guideDays);
var channelPrograms = await service.GetProgramsAsync(currentChannel.ChannelInfo.Id, start, end, cancellationToken).ConfigureAwait(false);
@@ -695,6 +698,23 @@ namespace MediaBrowser.Server.Implementations.LiveTv
_programs = programs.ToDictionary(i => i.Id);
}
+ private double GetGuideDays(int channelCount)
+ {
+ if (_config.Configuration.LiveTvOptions.GuideDays.HasValue)
+ {
+ return _config.Configuration.LiveTvOptions.GuideDays.Value;
+ }
+
+ var programsPerDay = channelCount * 48;
+
+ const int maxPrograms = 32000;
+
+ var days = Math.Round(((double)maxPrograms) / programsPerDay);
+
+ // No less than 2, no more than 14
+ return Math.Max(2, Math.Min(days, 14));
+ }
+
private async Task>> GetChannels(ILiveTvService service, CancellationToken cancellationToken)
{
var channels = await service.GetChannelsAsync(cancellationToken).ConfigureAwait(false);
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index 21efe8f9f..27f874cb0 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -291,7 +291,7 @@ namespace MediaBrowser.ServerApplication
await RegisterMediaEncoder(innerProgress).ConfigureAwait(false);
progress.Report(90);
- LiveTvManager = new LiveTvManager(ApplicationPaths, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, MediaEncoder);
+ LiveTvManager = new LiveTvManager(ServerConfigurationManager, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, MediaEncoder);
RegisterSingleInstance(LiveTvManager);
var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs
index 9d3e3e468..1a8871c28 100644
--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs
+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs
@@ -505,6 +505,7 @@ namespace MediaBrowser.WebDashboard.Api
"livetvtimer.js",
"livetvseriestimer.js",
"livetvseriestimers.js",
+ "livetvsettings.js",
"livetvsuggested.js",
"livetvtimers.js",
"loginpage.js",
diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
index 50113c19f..8379503d4 100644
--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
@@ -184,6 +184,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
@@ -433,6 +436,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest