From 98d53c7838f8495ccf0f908879527f1e127c2b36 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 Dec 2013 09:19:24 -0500 Subject: [PATCH] live tv + nuget updates --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 30 ++++++++++++++- .../LiveTv/ILiveTvManager.cs | 7 ++++ .../LiveTv/ILiveTvService.cs | 8 ++++ MediaBrowser.Model/LiveTv/RecordingInfoDto.cs | 6 +++ .../LiveTv/SeriesTimerInfoDto.cs | 6 +++ MediaBrowser.Model/LiveTv/TimerInfoDto.cs | 6 +++ .../LiveTv/LiveTvDtoService.cs | 15 ++++++-- .../LiveTv/LiveTvManager.cs | 37 +++++++++---------- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 11 files changed, 96 insertions(+), 29 deletions(-) diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 979088ee00..24d76c0d2b 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -114,7 +114,7 @@ namespace MediaBrowser.Api.LiveTv { } - [Route("/LiveTv/Timers/{Id}", "GET")] + [Route("/LiveTv/SeriesTimers/{Id}", "GET")] [Api(Description = "Gets a live tv series timer")] public class GetSeriesTimer : IReturn { @@ -128,6 +128,20 @@ namespace MediaBrowser.Api.LiveTv { } + [Route("/LiveTv/SeriesTimers/{Id}", "DELETE")] + [Api(Description = "Cancels a live tv series timer")] + public class CancelSeriesTimer : IReturnVoid + { + [ApiMember(Name = "Id", Description = "Timer Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Id { get; set; } + } + + [Route("/LiveTv/SeriesTimers/{Id}", "POST")] + [Api(Description = "Updates a live tv series timer")] + public class UpdateSeriesTimer : SeriesTimerInfoDto, IReturnVoid + { + } + public class LiveTvService : BaseApiService { private readonly ILiveTvManager _liveTvManager; @@ -265,5 +279,19 @@ namespace MediaBrowser.Api.LiveTv return ToOptimizedResult(result); } + + public void Delete(CancelSeriesTimer request) + { + var task = _liveTvManager.CancelSeriesTimer(request.Id); + + Task.WaitAll(task); + } + + public void Post(UpdateSeriesTimer request) + { + var task = _liveTvManager.UpdateSeriesTimer(request, CancellationToken.None); + + Task.WaitAll(task); + } } } \ No newline at end of file diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 9ed7b633d9..d9e9298cec 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -45,6 +45,13 @@ namespace MediaBrowser.Controller.LiveTv /// Task. Task CancelTimer(string id); + /// + /// Cancels the series timer. + /// + /// The identifier. + /// Task. + Task CancelSeriesTimer(string id); + /// /// Adds the parts. /// diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 8b1801f9e8..a5c91663ee 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -30,6 +30,14 @@ namespace MediaBrowser.Controller.LiveTv /// Task. Task CancelTimerAsync(string timerId, CancellationToken cancellationToken); + /// + /// Cancels the series timer asynchronous. + /// + /// The timer identifier. + /// The cancellation token. + /// Task. + Task CancelSeriesTimerAsync(string timerId, CancellationToken cancellationToken); + /// /// Deletes the recording asynchronous. /// diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs index d17ebee6dc..501e3b6210 100644 --- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs @@ -33,6 +33,12 @@ namespace MediaBrowser.Model.LiveTv /// public string ChannelName { get; set; } + /// + /// Gets or sets the name of the service. + /// + /// The name of the service. + public string ServiceName { get; set; } + /// /// Name of the recording. /// diff --git a/MediaBrowser.Model/LiveTv/SeriesTimerInfoDto.cs b/MediaBrowser.Model/LiveTv/SeriesTimerInfoDto.cs index 3862c07450..0853400135 100644 --- a/MediaBrowser.Model/LiveTv/SeriesTimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/SeriesTimerInfoDto.cs @@ -21,6 +21,12 @@ namespace MediaBrowser.Model.LiveTv /// public string ChannelId { get; set; } + /// + /// Gets or sets the name of the service. + /// + /// The name of the service. + public string ServiceName { get; set; } + /// /// Gets or sets the external channel identifier. /// diff --git a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs index 6b7ab42d3c..d962f784f1 100644 --- a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs @@ -31,6 +31,12 @@ namespace MediaBrowser.Model.LiveTv /// public string ChannelName { get; set; } + /// + /// Gets or sets the name of the service. + /// + /// The name of the service. + public string ServiceName { get; set; } + /// /// Gets or sets the program identifier. /// diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs index f93821cc97..fc030dbf8d 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -46,7 +46,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv RequiredPostPaddingSeconds = info.RequiredPostPaddingSeconds, RequiredPrePaddingSeconds = info.RequiredPrePaddingSeconds, ExternalChannelId = info.ChannelId, - ExternalSeriesTimerId = info.SeriesTimerId + ExternalSeriesTimerId = info.SeriesTimerId, + ServiceName = service.Name }; var duration = info.EndDate - info.StartDate; @@ -71,7 +72,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, - ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), RequestedPostPaddingSeconds = info.RequestedPostPaddingSeconds, RequestedPrePaddingSeconds = info.RequestedPrePaddingSeconds, RequiredPostPaddingSeconds = info.RequiredPostPaddingSeconds, @@ -80,9 +80,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv Priority = info.Priority, RecurrenceType = info.RecurrenceType, ExternalChannelId = info.ChannelId, - ExternalProgramId = info.ProgramId + ExternalProgramId = info.ProgramId, + ServiceName = service.Name }; + if (!string.IsNullOrEmpty(info.ChannelId)) + { + dto.ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"); + } + if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); @@ -139,7 +145,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv CommunityRating = info.CommunityRating, OfficialRating = info.OfficialRating, Audio = info.Audio, - IsHD = info.IsHD + IsHD = info.IsHD, + ServiceName = service.Name }; if (user != null) diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 318f450f12..37794cb3da 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -348,22 +348,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv 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)); + var recording = await GetRecording(recordingId, CancellationToken.None).ConfigureAwait(false); 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) + var service = GetServices(recording.ServiceName, null) .First(); await service.DeleteRecordingAsync(recording.ExternalId, CancellationToken.None).ConfigureAwait(false); @@ -371,25 +363,32 @@ namespace MediaBrowser.Server.Implementations.LiveTv public async Task CancelTimer(string id) { - var timers = await GetTimers(new TimerQuery + var timer = await GetTimer(id, CancellationToken.None).ConfigureAwait(false); + + if (timer == null) { + throw new ResourceNotFoundException(string.Format("Timer with Id {0} not found", id)); + } - }, CancellationToken.None).ConfigureAwait(false); + var service = GetServices(timer.ServiceName, null) + .First(); + + await service.CancelTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false); + } - var timer = timers.Items - .FirstOrDefault(i => string.Equals(id, i.Id, StringComparison.OrdinalIgnoreCase)); + public async Task CancelSeriesTimer(string id) + { + var timer = await GetSeriesTimer(id, CancellationToken.None).ConfigureAwait(false); 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) + var service = GetServices(timer.ServiceName, null) .First(); - await service.CancelTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false); + await service.CancelSeriesTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false); } public async Task GetRecording(string id, CancellationToken cancellationToken, User user = null) @@ -416,7 +415,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return results.Items.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.CurrentCulture)); } - + public Task UpdateTimer(TimerInfoDto timer, CancellationToken cancellationToken) { var info = _tvDtoService.GetTimerInfo(timer); diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 116671f44a..d453d67573 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.271 + 3.0.273 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 126ddf4ca1..16ebaa8a80 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.271 + 3.0.273 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 7de6b9e00a..33470aa627 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.271 + 3.0.273 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +