aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-11-29 11:58:24 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-11-29 11:58:24 -0500
commit235b838fbe262f3f41cd64c8506d067c9ef9253e (patch)
tree4c210d714cf6a0035c1bda623847d7d7b883a3ed /MediaBrowser.Server.Implementations
parent4892fb4e95f982527769620595e924c364204310 (diff)
support deleting and canceling live tv recordings and timers
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs57
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs9
2 files changed, 62 insertions, 4 deletions
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 00ac83f15..4d3d87788 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -397,6 +397,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
Status = info.Status
};
+ if (!string.IsNullOrEmpty(info.ProgramId))
+ {
+ dto.ProgramId = GetInternalProgramIdId(service.Name, info.ProgramId).ToString("N");
+ }
+
return dto;
}
@@ -503,13 +508,61 @@ namespace MediaBrowser.Server.Implementations.LiveTv
ExternalId = info.Id,
ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"),
Status = info.Status,
- IsRecurring = info.IsRecurring,
- RecurringDays = info.RecurringDays
+ IsRecurring = info.IsRecurring
};
+ if (!string.IsNullOrEmpty(info.ProgramId))
+ {
+ dto.ProgramId = GetInternalProgramIdId(service.Name, info.ProgramId).ToString("N");
+ }
+
return dto;
}
+ public async Task DeleteRecording(string recordingId)
+ {
+ var recordings = await GetRecordings(new RecordingQuery
+ {
+
+ }, CancellationToken.None).ConfigureAwait(false);
+
+ var recording = recordings.Items
+ .FirstOrDefault(i => string.Equals(recordingId, i.Id, StringComparison.OrdinalIgnoreCase));
+
+ if (recording == null)
+ {
+ throw new ResourceNotFoundException(string.Format("Recording with Id {0} not found", recordingId));
+ }
+
+ var channel = GetChannel(recording.ChannelId);
+ var service = GetServices(channel.ServiceName, null)
+ .First();
+
+ await service.DeleteRecordingAsync(recording.ExternalId, CancellationToken.None).ConfigureAwait(false);
+ }
+
+ public async Task CancelTimer(string id)
+ {
+ var timers = await GetTimers(new TimerQuery
+ {
+
+ }, CancellationToken.None).ConfigureAwait(false);
+
+ var timer = timers.Items
+ .FirstOrDefault(i => string.Equals(id, i.Id, StringComparison.OrdinalIgnoreCase));
+
+ if (timer == null)
+ {
+ throw new ResourceNotFoundException(string.Format("Timer with Id {0} not found", id));
+ }
+
+ var channel = GetChannel(timer.ChannelId);
+
+ var service = GetServices(channel.ServiceName, null)
+ .First();
+
+ await service.CancelTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false);
+ }
}
}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
index c3803d9bb..00bf9e55b 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.LiveTv
{
- class RefreshChannelsScheduledTask : IScheduledTask
+ class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask
{
private readonly ILiveTvManager _liveTvManager;
@@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
public Task Execute(System.Threading.CancellationToken cancellationToken, IProgress<double> progress)
{
- var manager = (LiveTvManager) _liveTvManager;
+ var manager = (LiveTvManager)_liveTvManager;
return manager.RefreshChannels(progress, cancellationToken);
}
@@ -50,5 +50,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
new IntervalTrigger{ Interval = TimeSpan.FromHours(2)}
};
}
+
+ public bool IsHidden
+ {
+ get { return _liveTvManager.Services.Count == 0; }
+ }
}
}