update EmbyTV
This commit is contained in:
parent
b9699fde05
commit
fe5537f779
|
@ -134,11 +134,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
|
|
||||||
public async Task RefreshSeriesTimers(CancellationToken cancellationToken, IProgress<double> progress)
|
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;
|
List<ChannelInfo> channels = null;
|
||||||
|
|
||||||
foreach (var timer in timers)
|
foreach (var timer in seriesTimers)
|
||||||
{
|
{
|
||||||
List<ProgramInfo> epgData;
|
List<ProgramInfo> epgData;
|
||||||
|
|
||||||
|
@ -157,6 +157,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
}
|
}
|
||||||
await UpdateTimersForSeriesTimer(epgData, timer).ConfigureAwait(false);
|
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;
|
private List<ChannelInfo> _channelCache = null;
|
||||||
|
@ -684,7 +694,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
TimerId = timer.Id,
|
TimerId = timer.Id,
|
||||||
ShowId = info.ShowId
|
ShowId = info.ShowId
|
||||||
};
|
};
|
||||||
_recordingProvider.Add(recording);
|
_recordingProvider.AddOrUpdate(recording);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -709,7 +719,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
recording.Path = recordPath;
|
recording.Path = recordPath;
|
||||||
recording.Status = RecordingStatus.InProgress;
|
recording.Status = RecordingStatus.InProgress;
|
||||||
recording.DateLastUpdated = DateTime.UtcNow;
|
recording.DateLastUpdated = DateTime.UtcNow;
|
||||||
_recordingProvider.Update(recording);
|
_recordingProvider.AddOrUpdate(recording);
|
||||||
|
|
||||||
_logger.Info("Beginning recording.");
|
_logger.Info("Beginning recording.");
|
||||||
|
|
||||||
|
@ -757,7 +767,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
}
|
}
|
||||||
|
|
||||||
recording.DateLastUpdated = DateTime.UtcNow;
|
recording.DateLastUpdated = DateTime.UtcNow;
|
||||||
_recordingProvider.Update(recording);
|
_recordingProvider.AddOrUpdate(recording);
|
||||||
|
|
||||||
if (recording.Status == RecordingStatus.Completed)
|
if (recording.Status == RecordingStatus.Completed)
|
||||||
{
|
{
|
||||||
|
@ -828,12 +838,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
|
|
||||||
private async Task UpdateTimersForSeriesTimer(List<ProgramInfo> epgData, SeriesTimerInfo seriesTimer)
|
private async Task UpdateTimersForSeriesTimer(List<ProgramInfo> epgData, SeriesTimerInfo seriesTimer)
|
||||||
{
|
{
|
||||||
|
var newTimers = GetTimersForSeries(seriesTimer, epgData, _recordingProvider.GetAll()).ToList();
|
||||||
|
|
||||||
var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
|
var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
|
||||||
|
|
||||||
if (registration.IsValid)
|
if (registration.IsValid)
|
||||||
{
|
{
|
||||||
var newTimers = GetTimersForSeries(seriesTimer, epgData, _recordingProvider.GetAll()).ToList();
|
|
||||||
|
|
||||||
foreach (var timer in newTimers)
|
foreach (var timer in newTimers)
|
||||||
{
|
{
|
||||||
_timerProvider.AddOrUpdate(timer);
|
_timerProvider.AddOrUpdate(timer);
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
private void UpdateList(List<T> newList)
|
private void UpdateList(List<T> newList)
|
||||||
{
|
{
|
||||||
var file = _dataPath + ".json";
|
var file = _dataPath + ".json";
|
||||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(file));
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(file));
|
||||||
|
|
||||||
lock (_fileDataLock)
|
lock (_fileDataLock)
|
||||||
{
|
{
|
||||||
|
@ -112,6 +112,20 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
UpdateList(list);
|
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)
|
public virtual void Delete(T item)
|
||||||
{
|
{
|
||||||
var list = GetAll().Where(i => !EqualityComparer(i, item)).ToList();
|
var list = GetAll().Where(i => !EqualityComparer(i, item)).ToList();
|
||||||
|
|
|
@ -76,20 +76,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
AddTimer(item);
|
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)
|
private void AddTimer(TimerInfo item)
|
||||||
{
|
{
|
||||||
var startDate = RecordingHelper.GetStartTime(item);
|
var startDate = RecordingHelper.GetStartTime(item);
|
||||||
|
@ -108,7 +94,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
public void StartTimer(TimerInfo item, TimeSpan length)
|
public void StartTimer(TimerInfo item, TimeSpan length)
|
||||||
{
|
{
|
||||||
StopTimer(item);
|
StopTimer(item);
|
||||||
|
|
||||||
var timer = new Timer(TimerCallback, item.Id, length, TimeSpan.Zero);
|
var timer = new Timer(TimerCallback, item.Id, length, TimeSpan.Zero);
|
||||||
|
|
||||||
if (!_timers.TryAdd(item.Id, timer))
|
if (!_timers.TryAdd(item.Id, timer))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user