update recordings on schedule

This commit is contained in:
Luke Pulverenti
2019-05-09 13:14:09 -04:00
parent 46ea3e4c21
commit f7a7fced43
2 changed files with 33 additions and 12 deletions
@@ -18,13 +18,41 @@ using MediaBrowser.Model.LiveTv;
namespace MediaBrowser.Plugins.VuPlus
{
public class RecordingsChannel : IChannel, IHasCacheKey, ISupportsDelete, ISupportsLatestMedia, ISupportsMediaProbe, IHasFolderAttributes
public class RecordingsChannel : IChannel, IHasCacheKey, ISupportsDelete, ISupportsLatestMedia, ISupportsMediaProbe, IHasFolderAttributes, IHasChangeEvent
{
public ILiveTvManager _liveTvManager;
public event EventHandler ContentChanged;
private Timer _updateTimer;
public void OnContentChanged()
{
if (ContentChanged != null)
{
ContentChanged(this, EventArgs.Empty);
}
}
private void OnUpdateTimerCallback(object state)
{
OnContentChanged();
}
public RecordingsChannel(ILiveTvManager liveTvManager)
{
_liveTvManager = liveTvManager;
var interval = TimeSpan.FromMinutes(15);
_updateTimer = new Timer(OnUpdateTimerCallback, null, interval, interval);
}
public void Dispose()
{
if (_updateTimer != null)
{
_updateTimer.Dispose();
_updateTimer = null;
}
}
public string Name
@@ -153,13 +181,6 @@ namespace MediaBrowser.Plugins.VuPlus
return GetService().DeleteRecordingAsync(id, cancellationToken);
}
public async Task<IEnumerable<ChannelItemInfo>> GetLatestMedia(ChannelLatestMediaSearch request, CancellationToken cancellationToken)
{
var result = await GetChannelItems(new InternalChannelItemQuery(), i => true, cancellationToken).ConfigureAwait(false);
return result.Items.OrderByDescending(i => i.DateCreated ?? DateTimeOffset.MinValue);
}
public Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(query.FolderId))