update recording program resolution

This commit is contained in:
Luke Pulverenti 2016-02-06 16:32:02 -05:00
parent c7684178ce
commit d0a5ffa422

View file

@ -664,12 +664,22 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
throw new ArgumentNullException("timer");
}
ProgramInfo info = null;
if (string.IsNullOrWhiteSpace(timer.ProgramId))
{
throw new InvalidOperationException("timer.ProgramId is null. Cannot record.");
_logger.Info("Timer {0} has null programId", timer.Id);
}
else
{
info = GetProgramInfoFromCache(timer.ChannelId, timer.ProgramId);
}
var info = GetProgramInfoFromCache(timer.ChannelId, timer.ProgramId);
if (info == null)
{
_logger.Info("Unable to find program with Id {0}. Will search using start date", timer.ProgramId);
info = GetProgramInfoFromCache(timer.ChannelId, timer.StartDate);
}
if (info == null)
{
@ -867,6 +877,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
return epgData.FirstOrDefault(p => string.Equals(p.Id, programId, StringComparison.OrdinalIgnoreCase));
}
private ProgramInfo GetProgramInfoFromCache(string channelId, DateTime startDateUtc)
{
var epgData = GetEpgDataForChannel(channelId);
var startDateTicks = startDateUtc.Ticks;
// Find the first program that starts within 3 minutes
return epgData.FirstOrDefault(p => Math.Abs(startDateTicks - p.StartDate.Ticks) <= TimeSpan.FromMinutes(3).Ticks);
}
private string RecordingPath
{
get