|
@@ -31,7 +31,11 @@ using CommonIO;
|
|
|
using IniParser;
|
|
|
using IniParser.Model;
|
|
|
using MediaBrowser.Common.Events;
|
|
|
+using MediaBrowser.Common.Security;
|
|
|
+using MediaBrowser.Controller.Entities.Movies;
|
|
|
+using MediaBrowser.Controller.Entities.TV;
|
|
|
using MediaBrowser.Model.Events;
|
|
|
+using MediaBrowser.Server.Implementations.LiveTv.Listings;
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.LiveTv
|
|
|
{
|
|
@@ -49,6 +53,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|
|
private readonly ITaskManager _taskManager;
|
|
|
private readonly IJsonSerializer _jsonSerializer;
|
|
|
private readonly IProviderManager _providerManager;
|
|
|
+ private readonly ISecurityManager _security;
|
|
|
|
|
|
private readonly IDtoService _dtoService;
|
|
|
private readonly ILocalizationManager _localization;
|
|
@@ -71,7 +76,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|
|
public event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCreated;
|
|
|
public event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCreated;
|
|
|
|
|
|
- public LiveTvManager(IApplicationHost appHost, 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)
|
|
|
+ public LiveTvManager(IApplicationHost appHost, 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)
|
|
|
{
|
|
|
_config = config;
|
|
|
_logger = logger;
|
|
@@ -83,6 +88,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|
|
_jsonSerializer = jsonSerializer;
|
|
|
_providerManager = providerManager;
|
|
|
_fileSystem = fileSystem;
|
|
|
+ _security = security;
|
|
|
_dtoService = dtoService;
|
|
|
_userDataManager = userDataManager;
|
|
|
|
|
@@ -1423,6 +1429,49 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|
|
return new QueryResult<BaseItem>();
|
|
|
}
|
|
|
|
|
|
+ var includeItemTypes = new List<string>();
|
|
|
+ var excludeItemTypes = new List<string>();
|
|
|
+ var genres = new List<string>();
|
|
|
+
|
|
|
+ if (query.IsMovie.HasValue)
|
|
|
+ {
|
|
|
+ if (query.IsMovie.Value)
|
|
|
+ {
|
|
|
+ includeItemTypes.Add(typeof(Movie).Name);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ excludeItemTypes.Add(typeof(Movie).Name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (query.IsSeries.HasValue)
|
|
|
+ {
|
|
|
+ if (query.IsSeries.Value)
|
|
|
+ {
|
|
|
+ includeItemTypes.Add(typeof(Episode).Name);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ excludeItemTypes.Add(typeof(Episode).Name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (query.IsSports.HasValue)
|
|
|
+ {
|
|
|
+ if (query.IsSports.Value)
|
|
|
+ {
|
|
|
+ genres.Add("Sports");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (query.IsKids.HasValue)
|
|
|
+ {
|
|
|
+ if (query.IsKids.Value)
|
|
|
+ {
|
|
|
+ genres.Add("Kids");
|
|
|
+ genres.Add("Children");
|
|
|
+ genres.Add("Family");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return _libraryManager.GetItemsResult(new InternalItemsQuery(user)
|
|
|
{
|
|
|
MediaTypes = new[] { MediaType.Video },
|
|
@@ -1430,13 +1479,75 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|
|
AncestorIds = folders.Select(i => i.Id.ToString("N")).ToArray(),
|
|
|
IsFolder = false,
|
|
|
ExcludeLocationTypes = new[] { LocationType.Virtual },
|
|
|
- Limit = Math.Min(200, query.Limit ?? int.MaxValue),
|
|
|
+ Limit = query.Limit,
|
|
|
SortBy = new[] { ItemSortBy.DateCreated },
|
|
|
SortOrder = SortOrder.Descending,
|
|
|
- EnableTotalRecordCount = query.EnableTotalRecordCount
|
|
|
+ EnableTotalRecordCount = query.EnableTotalRecordCount,
|
|
|
+ IncludeItemTypes = includeItemTypes.ToArray(),
|
|
|
+ ExcludeItemTypes = excludeItemTypes.ToArray(),
|
|
|
+ Genres = genres.ToArray()
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public async Task<QueryResult<BaseItemDto>> GetRecordingSeries(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);
|
|
|
+ if (user != null && !IsLiveTvEnabled(user))
|
|
|
+ {
|
|
|
+ return new QueryResult<BaseItemDto>();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_services.Count > 1)
|
|
|
+ {
|
|
|
+ return new QueryResult<BaseItemDto>();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (user == null || (query.IsInProgress ?? false))
|
|
|
+ {
|
|
|
+ return new QueryResult<BaseItemDto>();
|
|
|
+ }
|
|
|
+
|
|
|
+ var folders = EmbyTV.EmbyTV.Current.GetRecordingFolders()
|
|
|
+ .SelectMany(i => i.Locations)
|
|
|
+ .Distinct(StringComparer.OrdinalIgnoreCase)
|
|
|
+ .Select(i => _libraryManager.FindByPath(i, true))
|
|
|
+ .Where(i => i != null)
|
|
|
+ .Where(i => i.IsVisibleStandalone(user))
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ if (folders.Count == 0)
|
|
|
+ {
|
|
|
+ return new QueryResult<BaseItemDto>();
|
|
|
+ }
|
|
|
+
|
|
|
+ var includeItemTypes = new List<string>();
|
|
|
+ var excludeItemTypes = new List<string>();
|
|
|
+
|
|
|
+ includeItemTypes.Add(typeof(Series).Name);
|
|
|
+
|
|
|
+ var internalResult = _libraryManager.GetItemsResult(new InternalItemsQuery(user)
|
|
|
+ {
|
|
|
+ Recursive = true,
|
|
|
+ AncestorIds = folders.Select(i => i.Id.ToString("N")).ToArray(),
|
|
|
+ Limit = query.Limit,
|
|
|
+ SortBy = new[] { ItemSortBy.DateCreated },
|
|
|
+ SortOrder = SortOrder.Descending,
|
|
|
+ EnableTotalRecordCount = query.EnableTotalRecordCount,
|
|
|
+ IncludeItemTypes = includeItemTypes.ToArray(),
|
|
|
+ ExcludeItemTypes = excludeItemTypes.ToArray()
|
|
|
+ });
|
|
|
+
|
|
|
+ RemoveFields(options);
|
|
|
+
|
|
|
+ var returnArray = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user).ConfigureAwait(false)).ToArray();
|
|
|
+
|
|
|
+ return new QueryResult<BaseItemDto>
|
|
|
+ {
|
|
|
+ Items = returnArray,
|
|
|
+ TotalRecordCount = internalResult.TotalRecordCount
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
public async Task<QueryResult<BaseItem>> GetInternalRecordings(RecordingQuery query, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);
|
|
@@ -1492,6 +1603,30 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|
|
recordings = recordings.Where(i => i.Status == val);
|
|
|
}
|
|
|
|
|
|
+ if (query.IsMovie.HasValue)
|
|
|
+ {
|
|
|
+ var val = query.IsMovie.Value;
|
|
|
+ recordings = recordings.Where(i => i.IsMovie == val);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (query.IsSeries.HasValue)
|
|
|
+ {
|
|
|
+ var val = query.IsSeries.Value;
|
|
|
+ recordings = recordings.Where(i => i.IsSeries == val);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (query.IsKids.HasValue)
|
|
|
+ {
|
|
|
+ var val = query.IsKids.Value;
|
|
|
+ recordings = recordings.Where(i => i.IsKids == val);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (query.IsSports.HasValue)
|
|
|
+ {
|
|
|
+ var val = query.IsSports.Value;
|
|
|
+ recordings = recordings.Where(i => i.IsSports == val);
|
|
|
+ }
|
|
|
+
|
|
|
if (!string.IsNullOrEmpty(query.SeriesTimerId))
|
|
|
{
|
|
|
var guid = new Guid(query.SeriesTimerId);
|
|
@@ -1950,16 +2085,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|
|
dto.Number = channel.Number;
|
|
|
dto.ChannelNumber = channel.Number;
|
|
|
dto.ChannelType = channel.ChannelType;
|
|
|
- dto.ServiceName = GetService(channel).Name;
|
|
|
+ dto.ServiceName = channel.ServiceName;
|
|
|
|
|
|
if (options.Fields.Contains(ItemFields.MediaSources))
|
|
|
{
|
|
|
dto.MediaSources = channel.GetMediaSources(true).ToList();
|
|
|
}
|
|
|
|
|
|
- var channelIdString = channel.Id.ToString("N");
|
|
|
if (options.AddCurrentProgram)
|
|
|
{
|
|
|
+ var channelIdString = channel.Id.ToString("N");
|
|
|
var currentProgram = programs.FirstOrDefault(i => string.Equals(i.ChannelId, channelIdString));
|
|
|
|
|
|
if (currentProgram != null)
|
|
@@ -2091,6 +2226,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|
|
|
|
|
public async Task CreateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken)
|
|
|
{
|
|
|
+ var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
|
|
|
+
|
|
|
+ if (!registration.IsValid)
|
|
|
+ {
|
|
|
+ _logger.Info("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);
|
|
@@ -2653,33 +2796,28 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public Task<MBRegistrationRecord> GetRegistrationInfo(string channelId, string programId, string feature)
|
|
|
+ public Task<MBRegistrationRecord> GetRegistrationInfo(string feature)
|
|
|
{
|
|
|
- ILiveTvService service;
|
|
|
-
|
|
|
- if (string.IsNullOrWhiteSpace(programId))
|
|
|
- {
|
|
|
- var channel = GetInternalChannel(channelId);
|
|
|
- service = GetService(channel);
|
|
|
- }
|
|
|
- else
|
|
|
+ if (string.Equals(feature, "seriesrecordings", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- var program = GetInternalProgram(programId);
|
|
|
- service = GetService(program);
|
|
|
+ feature = "embytvseriesrecordings";
|
|
|
}
|
|
|
|
|
|
- var hasRegistration = service as IHasRegistrationInfo;
|
|
|
-
|
|
|
- if (hasRegistration != null)
|
|
|
+ if (string.Equals(feature, "dvr", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- return hasRegistration.GetRegistrationInfo(feature);
|
|
|
+ var config = GetConfiguration();
|
|
|
+ if (config.TunerHosts.Count(i => i.IsEnabled) > 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 Task.FromResult(new MBRegistrationRecord
|
|
|
- {
|
|
|
- IsValid = true,
|
|
|
- IsRegistered = true
|
|
|
- });
|
|
|
+ return _security.GetRegistrationStatus(feature);
|
|
|
}
|
|
|
|
|
|
public List<NameValuePair> GetSatIniMappings()
|