update EmbyTV

pull/702/head
Luke Pulverenti 9 years ago
parent b9699fde05
commit fe5537f779

@ -134,11 +134,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
public async Task RefreshSeriesTimers(CancellationToken cancellationToken, IProgress<double> progress)
{
var timers = await GetSeriesTimersAsync(cancellationToken).ConfigureAwait(false);
var seriesTimers = await GetSeriesTimersAsync(cancellationToken).ConfigureAwait(false);
List<ChannelInfo> channels = null;
foreach (var timer in timers)
foreach (var timer in seriesTimers)
{
List<ProgramInfo> epgData;
@ -157,6 +157,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
}
await UpdateTimersForSeriesTimer(epgData, timer).ConfigureAwait(false);
}
var timers = await GetTimersAsync(cancellationToken).ConfigureAwait(false);
foreach (var timer in timers.ToList())
{
if (DateTime.UtcNow > timer.EndDate && !_activeRecordings.ContainsKey(timer.Id))
{
_timerProvider.Delete(timer);
}
}
}
private List<ChannelInfo> _channelCache = null;
@ -684,7 +694,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
TimerId = timer.Id,
ShowId = info.ShowId
};
_recordingProvider.Add(recording);
_recordingProvider.AddOrUpdate(recording);
}
try
@ -709,7 +719,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
recording.Path = recordPath;
recording.Status = RecordingStatus.InProgress;
recording.DateLastUpdated = DateTime.UtcNow;
_recordingProvider.Update(recording);
_recordingProvider.AddOrUpdate(recording);
_logger.Info("Beginning recording.");
@ -757,7 +767,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
}
recording.DateLastUpdated = DateTime.UtcNow;
_recordingProvider.Update(recording);
_recordingProvider.AddOrUpdate(recording);
if (recording.Status == RecordingStatus.Completed)
{
@ -828,12 +838,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
private async Task UpdateTimersForSeriesTimer(List<ProgramInfo> epgData, SeriesTimerInfo seriesTimer)
{
var newTimers = GetTimersForSeries(seriesTimer, epgData, _recordingProvider.GetAll()).ToList();
var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
if (registration.IsValid)
{
var newTimers = GetTimersForSeries(seriesTimer, epgData, _recordingProvider.GetAll()).ToList();
foreach (var timer in newTimers)
{
_timerProvider.AddOrUpdate(timer);

@ -112,6 +112,20 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
UpdateList(list);
}
public void AddOrUpdate(T item)
{
var list = GetAll().ToList();
if (!list.Any(i => EqualityComparer(i, item)))
{
Add(item);
}
else
{
Update(item);
}
}
public virtual void Delete(T item)
{
var list = GetAll().Where(i => !EqualityComparer(i, item)).ToList();

@ -76,20 +76,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
AddTimer(item);
}
public void AddOrUpdate(TimerInfo item)
{
var list = GetAll().ToList();
if (!list.Any(i => EqualityComparer(i, item)))
{
Add(item);
}
else
{
Update(item);
}
}
private void AddTimer(TimerInfo item)
{
var startDate = RecordingHelper.GetStartTime(item);

Loading…
Cancel
Save