From 11a5bbf9b53f9462b66e5ff1ead51d04eed460ea Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 2 Mar 2016 13:42:39 -0500 Subject: [PATCH] update recording data --- .../LiveTv/ILiveTvManager.cs | 9 +- .../Dto/DtoService.cs | 25 +++- .../EntryPoints/UsageReporter.cs | 8 +- .../LiveTv/LiveTvManager.cs | 107 ++++++++++-------- 4 files changed, 89 insertions(+), 60 deletions(-) diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 05c7448c36..501e48a74b 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Channels; +using System; +using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Dto; @@ -343,11 +344,11 @@ namespace MediaBrowser.Controller.LiveTv /// /// Adds the information to program dto. /// - /// The item. - /// The dto. + /// The programs. /// The fields. /// The user. - void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, List fields, User user = null); + /// Task. + Task AddInfoToProgramDto(List> programs, List fields, User user = null); /// /// Saves the tuner host. /// diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 07686e91ca..a19a122c38 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -26,6 +26,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading.Tasks; using CommonIO; namespace MediaBrowser.Server.Implementations.Dto @@ -92,11 +93,17 @@ namespace MediaBrowser.Server.Implementations.Dto var syncDictionary = GetSyncedItemProgressDictionary(syncJobItems); var list = new List(); + var programTuples = new List> { }; foreach (var item in items) { var dto = GetBaseItemDtoInternal(item, options, syncDictionary, user, owner); + if (item is LiveTvProgram) + { + programTuples.Add(new Tuple(item, dto)); + } + var byName = item as IItemByName; if (byName != null) @@ -118,6 +125,12 @@ namespace MediaBrowser.Server.Implementations.Dto list.Add(dto); } + if (programTuples.Count > 0) + { + var task = _livetvManager().AddInfoToProgramDto(programTuples, options.Fields, user); + Task.WaitAll(task); + } + return list; } @@ -139,6 +152,13 @@ namespace MediaBrowser.Server.Implementations.Dto var dto = GetBaseItemDtoInternal(item, options, GetSyncedItemProgressDictionary(syncProgress), user, owner); + if (item is LiveTvProgram) + { + var list = new List> { new Tuple(item, dto) }; + var task = _livetvManager().AddInfoToProgramDto(list, options.Fields, user); + Task.WaitAll(task); + } + var byName = item as IItemByName; if (byName != null) @@ -393,11 +413,6 @@ namespace MediaBrowser.Server.Implementations.Dto _livetvManager().AddInfoToRecordingDto(item, dto, user); } - else if (item is LiveTvProgram) - { - _livetvManager().AddInfoToProgramDto(item, dto, fields, user); - } - return dto; } diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs b/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs index be2817fd29..2473f3af69 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs @@ -57,7 +57,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints CancellationToken = cancellationToken, // Seeing block length errors - EnableHttpCompression = false + EnableHttpCompression = false, + + LogRequest = false }; options.SetPostData(data); @@ -99,7 +101,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints CancellationToken = cancellationToken, // Seeing block length errors - EnableHttpCompression = false + EnableHttpCompression = false, + + LogRequest = false }; options.SetPostData(data); diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 442ab76f64..abb2710e72 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1489,70 +1489,79 @@ namespace MediaBrowser.Server.Implementations.LiveTv }; } - public void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, List fields, User user = null) + public async Task AddInfoToProgramDto(List> tuples, List fields, User user = null) { - var program = (LiveTvProgram)item; + var recordingTuples = new List>(); - dto.StartDate = program.StartDate; - dto.EpisodeTitle = program.EpisodeTitle; - - if (program.IsRepeat) - { - dto.IsRepeat = program.IsRepeat; - } - if (program.IsMovie) - { - dto.IsMovie = program.IsMovie; - } - if (program.IsSeries) - { - dto.IsSeries = program.IsSeries; - } - if (program.IsSports) - { - dto.IsSports = program.IsSports; - } - if (program.IsLive) - { - dto.IsLive = program.IsLive; - } - if (program.IsNews) - { - dto.IsNews = program.IsNews; - } - if (program.IsKids) + foreach (var tuple in tuples) { - dto.IsKids = program.IsKids; - } - if (program.IsPremiere) - { - dto.IsPremiere = program.IsPremiere; - } + var program = (LiveTvProgram)tuple.Item1; + var dto = tuple.Item2; - if (fields.Contains(ItemFields.ChannelInfo)) - { - var channel = GetInternalChannel(program.ChannelId); + dto.StartDate = program.StartDate; + dto.EpisodeTitle = program.EpisodeTitle; + + if (program.IsRepeat) + { + dto.IsRepeat = program.IsRepeat; + } + if (program.IsMovie) + { + dto.IsMovie = program.IsMovie; + } + if (program.IsSeries) + { + dto.IsSeries = program.IsSeries; + } + if (program.IsSports) + { + dto.IsSports = program.IsSports; + } + if (program.IsLive) + { + dto.IsLive = program.IsLive; + } + if (program.IsNews) + { + dto.IsNews = program.IsNews; + } + if (program.IsKids) + { + dto.IsKids = program.IsKids; + } + if (program.IsPremiere) + { + dto.IsPremiere = program.IsPremiere; + } - if (channel != null) + if (fields.Contains(ItemFields.ChannelInfo)) { - dto.ChannelName = channel.Name; - dto.MediaType = channel.MediaType; + var channel = GetInternalChannel(program.ChannelId); - if (channel.HasImage(ImageType.Primary)) + if (channel != null) { - dto.ChannelPrimaryImageTag = _tvDtoService.GetImageTag(channel); + dto.ChannelName = channel.Name; + dto.MediaType = channel.MediaType; + + if (channel.HasImage(ImageType.Primary)) + { + dto.ChannelPrimaryImageTag = _tvDtoService.GetImageTag(channel); + } } } - } - if (fields.Contains(ItemFields.ServiceName)) - { var service = GetService(program); - if (service != null) + var serviceName = service == null ? null : service.Name; + + if (fields.Contains(ItemFields.ServiceName)) { - dto.ServiceName = service.Name; + dto.ServiceName = serviceName; } + + recordingTuples.Add(new Tuple(dto, serviceName, program.ExternalId)); } + + await AddRecordingInfo(recordingTuples, CancellationToken.None).ConfigureAwait(false); } public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, User user = null)