diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index a39781d6a..3f164ee6f 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -761,6 +761,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv programs = programs.Where(p => p.IsMovie == query.IsMovie); } + if (query.IsSports.HasValue) + { + programs = programs.Where(p => p.IsSports == query.IsSports); + } + programs = _libraryManager.Sort(programs, user, query.SortBy, query.SortOrder ?? SortOrder.Ascending) .Cast<LiveTvProgram>(); @@ -826,10 +831,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv programs = programs.Where(p => p.IsMovie == query.IsMovie.Value); } + if (query.IsSports.HasValue) + { + programs = programs.Where(p => p.IsSports == query.IsSports.Value); + } + var programList = programs.ToList(); var genres = programList.SelectMany(i => i.Genres) - .Distinct(StringComparer.OrdinalIgnoreCase) + .DistinctNames() .Select(i => _libraryManager.GetGenre(i)) .ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase); @@ -996,6 +1006,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv innerProgress = new ActionableProgress<double>(); innerProgress.RegisterAction(p => progress.Report(90 + (p * .1))); await CleanDatabaseInternal(progress, cancellationToken).ConfigureAwait(false); + + foreach (var program in _programs.Values + .Where(i => (i.StartDate - DateTime.UtcNow).TotalDays <= 1) + .ToList()) + { + RefreshIfNeeded(program); + } } finally { @@ -1128,8 +1145,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv _refreshedPrograms.Clear(); progress.Report(90); + RefreshIfNeeded(programs.Take(500)); + // Load these now which will prefetch metadata - await GetRecordings(new RecordingQuery(), cancellationToken).ConfigureAwait(false); + var dtoOptions = new DtoOptions(); + dtoOptions.Fields.Remove(ItemFields.SyncInfo); + await GetRecordings(new RecordingQuery(), dtoOptions, cancellationToken).ConfigureAwait(false); progress.Report(100); } @@ -1195,8 +1216,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv var days = Math.Round(((double)maxPrograms) / programsPerDay); - // No less than 2, no more than 7 - return Math.Max(2, Math.Min(days, 7)); + return Math.Max(3, Math.Min(days, 14)); } private async Task<IEnumerable<Tuple<string, ChannelInfo>>> GetChannels(ILiveTvService service, CancellationToken cancellationToken) @@ -1304,7 +1324,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv }; } - public async Task<QueryResult<RecordingInfoDto>> GetRecordings(RecordingQuery query, CancellationToken cancellationToken) + public async Task<QueryResult<RecordingInfoDto>> GetRecordings(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken) { var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId); @@ -1320,6 +1340,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv }) .ToArray(); + if (user != null) + { + _dtoService.FillSyncInfo(returnArray, new DtoOptions(), user); + } + return new QueryResult<RecordingInfoDto> { Items = returnArray, @@ -1392,7 +1417,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv public async Task DeleteRecording(string recordingId) { - var recording = await GetRecording(recordingId, CancellationToken.None).ConfigureAwait(false); + var dtoOptions = new DtoOptions(); + dtoOptions.Fields.Remove(ItemFields.SyncInfo); + + var recording = await GetRecording(recordingId, dtoOptions, CancellationToken.None).ConfigureAwait(false); if (recording == null) { @@ -1432,14 +1460,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv await service.CancelSeriesTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false); } - public async Task<RecordingInfoDto> GetRecording(string id, CancellationToken cancellationToken, User user = null) + public async Task<RecordingInfoDto> GetRecording(string id, DtoOptions options, CancellationToken cancellationToken, User user = null) { var results = await GetRecordings(new RecordingQuery { UserId = user == null ? null : user.Id.ToString("N"), Id = id - }, cancellationToken).ConfigureAwait(false); + }, options, cancellationToken).ConfigureAwait(false); return results.Items.FirstOrDefault(); } @@ -1719,11 +1747,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv public async Task<QueryResult<RecordingGroupDto>> GetRecordingGroups(RecordingGroupQuery query, CancellationToken cancellationToken) { + var dtoOptions = new DtoOptions(); + dtoOptions.Fields.Remove(ItemFields.SyncInfo); + var recordingResult = await GetRecordings(new RecordingQuery { UserId = query.UserId - }, cancellationToken).ConfigureAwait(false); + }, dtoOptions, cancellationToken).ConfigureAwait(false); var recordings = recordingResult.Items; |
