Merge pull request #1513 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-03-02 15:53:55 -05:00
commit 81e96ed4f6
4 changed files with 93 additions and 64 deletions

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Channels; using System;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
@ -343,11 +344,11 @@ namespace MediaBrowser.Controller.LiveTv
/// <summary> /// <summary>
/// Adds the information to program dto. /// Adds the information to program dto.
/// </summary> /// </summary>
/// <param name="item">The item.</param> /// <param name="programs">The programs.</param>
/// <param name="dto">The dto.</param>
/// <param name="fields">The fields.</param> /// <param name="fields">The fields.</param>
/// <param name="user">The user.</param> /// <param name="user">The user.</param>
void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, List<ItemFields> fields, User user = null); /// <returns>Task.</returns>
Task AddInfoToProgramDto(List<Tuple<BaseItem,BaseItemDto>> programs, List<ItemFields> fields, User user = null);
/// <summary> /// <summary>
/// Saves the tuner host. /// Saves the tuner host.
/// </summary> /// </summary>

View File

@ -26,6 +26,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using CommonIO; using CommonIO;
namespace MediaBrowser.Server.Implementations.Dto namespace MediaBrowser.Server.Implementations.Dto
@ -92,11 +93,17 @@ namespace MediaBrowser.Server.Implementations.Dto
var syncDictionary = GetSyncedItemProgressDictionary(syncJobItems); var syncDictionary = GetSyncedItemProgressDictionary(syncJobItems);
var list = new List<BaseItemDto>(); var list = new List<BaseItemDto>();
var programTuples = new List<Tuple<BaseItem, BaseItemDto>> { };
foreach (var item in items) foreach (var item in items)
{ {
var dto = GetBaseItemDtoInternal(item, options, syncDictionary, user, owner); var dto = GetBaseItemDtoInternal(item, options, syncDictionary, user, owner);
if (item is LiveTvProgram)
{
programTuples.Add(new Tuple<BaseItem, BaseItemDto>(item, dto));
}
var byName = item as IItemByName; var byName = item as IItemByName;
if (byName != null) if (byName != null)
@ -118,6 +125,12 @@ namespace MediaBrowser.Server.Implementations.Dto
list.Add(dto); list.Add(dto);
} }
if (programTuples.Count > 0)
{
var task = _livetvManager().AddInfoToProgramDto(programTuples, options.Fields, user);
Task.WaitAll(task);
}
return list; return list;
} }
@ -139,6 +152,13 @@ namespace MediaBrowser.Server.Implementations.Dto
var dto = GetBaseItemDtoInternal(item, options, GetSyncedItemProgressDictionary(syncProgress), user, owner); var dto = GetBaseItemDtoInternal(item, options, GetSyncedItemProgressDictionary(syncProgress), user, owner);
if (item is LiveTvProgram)
{
var list = new List<Tuple<BaseItem, BaseItemDto>> { new Tuple<BaseItem, BaseItemDto>(item, dto) };
var task = _livetvManager().AddInfoToProgramDto(list, options.Fields, user);
Task.WaitAll(task);
}
var byName = item as IItemByName; var byName = item as IItemByName;
if (byName != null) if (byName != null)
@ -393,11 +413,6 @@ namespace MediaBrowser.Server.Implementations.Dto
_livetvManager().AddInfoToRecordingDto(item, dto, user); _livetvManager().AddInfoToRecordingDto(item, dto, user);
} }
else if (item is LiveTvProgram)
{
_livetvManager().AddInfoToProgramDto(item, dto, fields, user);
}
return dto; return dto;
} }

View File

@ -57,7 +57,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
// Seeing block length errors // Seeing block length errors
EnableHttpCompression = false EnableHttpCompression = false,
LogRequest = false
}; };
options.SetPostData(data); options.SetPostData(data);
@ -99,7 +101,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
// Seeing block length errors // Seeing block length errors
EnableHttpCompression = false EnableHttpCompression = false,
LogRequest = false
}; };
options.SetPostData(data); options.SetPostData(data);

View File

@ -1489,70 +1489,79 @@ namespace MediaBrowser.Server.Implementations.LiveTv
}; };
} }
public void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, List<ItemFields> fields, User user = null) public async Task AddInfoToProgramDto(List<Tuple<BaseItem, BaseItemDto>> tuples, List<ItemFields> fields, User user = null)
{ {
var program = (LiveTvProgram)item; var recordingTuples = new List<Tuple<BaseItemDto, string, string>>();
dto.StartDate = program.StartDate; foreach (var tuple in tuples)
dto.EpisodeTitle = program.EpisodeTitle; {
var program = (LiveTvProgram)tuple.Item1;
var dto = tuple.Item2;
if (program.IsRepeat) dto.StartDate = program.StartDate;
{ dto.EpisodeTitle = program.EpisodeTitle;
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 (fields.Contains(ItemFields.ChannelInfo)) if (program.IsRepeat)
{
var channel = GetInternalChannel(program.ChannelId);
if (channel != null)
{ {
dto.ChannelName = channel.Name; dto.IsRepeat = program.IsRepeat;
dto.MediaType = channel.MediaType; }
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.HasImage(ImageType.Primary)) if (fields.Contains(ItemFields.ChannelInfo))
{
var channel = GetInternalChannel(program.ChannelId);
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);
}
} }
} }
var service = GetService(program);
var serviceName = service == null ? null : service.Name;
if (fields.Contains(ItemFields.ServiceName))
{
dto.ServiceName = serviceName;
}
recordingTuples.Add(new Tuple<BaseItemDto, string, string>(dto, serviceName, program.ExternalId));
} }
if (fields.Contains(ItemFields.ServiceName)) await AddRecordingInfo(recordingTuples, CancellationToken.None).ConfigureAwait(false);
{
var service = GetService(program);
if (service != null)
{
dto.ServiceName = service.Name;
}
}
} }
public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, User user = null) public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, User user = null)