update recording data

pull/702/head
Luke Pulverenti 9 years ago
parent e52eb2219b
commit 11a5bbf9b5

@ -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>

@ -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;
} }

@ -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);

@ -1489,9 +1489,14 @@ 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>>();
foreach (var tuple in tuples)
{
var program = (LiveTvProgram)tuple.Item1;
var dto = tuple.Item2;
dto.StartDate = program.StartDate; dto.StartDate = program.StartDate;
dto.EpisodeTitle = program.EpisodeTitle; dto.EpisodeTitle = program.EpisodeTitle;
@ -1545,14 +1550,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv
} }
} }
if (fields.Contains(ItemFields.ServiceName))
{
var service = GetService(program); 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<BaseItemDto, string, string>(dto, serviceName, program.ExternalId));
} }
await AddRecordingInfo(recordingTuples, CancellationToken.None).ConfigureAwait(false);
} }
public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, User user = null) public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, User user = null)

Loading…
Cancel
Save