mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
added live tv settings page
This commit is contained in:
parent
109e3b4966
commit
edd19f6c45
@ -224,6 +224,9 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
|
|
||||||
public bool EnableAutomaticRestart { get; set; }
|
public bool EnableAutomaticRestart { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public LiveTvOptions LiveTvOptions { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -287,6 +290,8 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
{
|
{
|
||||||
MaxBackdrops = 1
|
MaxBackdrops = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LiveTvOptions = new LiveTvOptions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,4 +308,9 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
HighQuality,
|
HighQuality,
|
||||||
MaxQuality
|
MaxQuality
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class LiveTvOptions
|
||||||
|
{
|
||||||
|
public int? GuideDays { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
@ -27,7 +28,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class LiveTvManager : ILiveTvManager, IDisposable
|
public class LiveTvManager : ILiveTvManager, IDisposable
|
||||||
{
|
{
|
||||||
private readonly IServerApplicationPaths _appPaths;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IItemRepository _itemRepo;
|
private readonly IItemRepository _itemRepo;
|
||||||
@ -46,9 +47,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
private List<Guid> _channelIdList = new List<Guid>();
|
private List<Guid> _channelIdList = new List<Guid>();
|
||||||
private Dictionary<Guid, LiveTvProgram> _programs = new Dictionary<Guid, LiveTvProgram>();
|
private Dictionary<Guid, LiveTvProgram> _programs = new Dictionary<Guid, LiveTvProgram>();
|
||||||
|
|
||||||
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;
|
_fileSystem = fileSystem;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_itemRepo = itemRepo;
|
_itemRepo = itemRepo;
|
||||||
@ -217,7 +218,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
|
|
||||||
private async Task<LiveTvChannel> GetChannel(ChannelInfo channelInfo, string serviceName, CancellationToken cancellationToken)
|
private async Task<LiveTvChannel> 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);
|
var fileInfo = new DirectoryInfo(path);
|
||||||
|
|
||||||
@ -659,6 +660,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
numComplete = 0;
|
numComplete = 0;
|
||||||
var programs = new List<LiveTvProgram>();
|
var programs = new List<LiveTvProgram>();
|
||||||
|
|
||||||
|
var guideDays = GetGuideDays(list.Count);
|
||||||
|
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
// Avoid implicitly captured closure
|
// Avoid implicitly captured closure
|
||||||
@ -666,8 +669,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var start = DateTime.UtcNow;
|
var start = DateTime.UtcNow.AddHours(-1);
|
||||||
var end = start.AddDays(3);
|
var end = start.AddDays(guideDays);
|
||||||
|
|
||||||
var channelPrograms = await service.GetProgramsAsync(currentChannel.ChannelInfo.Id, start, end, cancellationToken).ConfigureAwait(false);
|
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);
|
_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<IEnumerable<Tuple<string, ChannelInfo>>> GetChannels(ILiveTvService service, CancellationToken cancellationToken)
|
private async Task<IEnumerable<Tuple<string, ChannelInfo>>> GetChannels(ILiveTvService service, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var channels = await service.GetChannelsAsync(cancellationToken).ConfigureAwait(false);
|
var channels = await service.GetChannelsAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
@ -291,7 +291,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
await RegisterMediaEncoder(innerProgress).ConfigureAwait(false);
|
await RegisterMediaEncoder(innerProgress).ConfigureAwait(false);
|
||||||
progress.Report(90);
|
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);
|
RegisterSingleInstance(LiveTvManager);
|
||||||
|
|
||||||
var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
|
var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
|
||||||
|
@ -505,6 +505,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
"livetvtimer.js",
|
"livetvtimer.js",
|
||||||
"livetvseriestimer.js",
|
"livetvseriestimer.js",
|
||||||
"livetvseriestimers.js",
|
"livetvseriestimers.js",
|
||||||
|
"livetvsettings.js",
|
||||||
"livetvsuggested.js",
|
"livetvsuggested.js",
|
||||||
"livetvtimers.js",
|
"livetvtimers.js",
|
||||||
"loginpage.js",
|
"loginpage.js",
|
||||||
|
@ -184,6 +184,9 @@
|
|||||||
<Content Include="dashboard-ui\livetvseriestimer.html">
|
<Content Include="dashboard-ui\livetvseriestimer.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\livetvsettings.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\livetvtimers.html">
|
<Content Include="dashboard-ui\livetvtimers.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
@ -433,6 +436,9 @@
|
|||||||
<Content Include="dashboard-ui\scripts\livetvseriestimer.js">
|
<Content Include="dashboard-ui\scripts\livetvseriestimer.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\scripts\livetvsettings.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\scripts\livetvtimer.js">
|
<Content Include="dashboard-ui\scripts\livetvtimer.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
Loading…
Reference in New Issue
Block a user