Browse Source

live tv + nuget updates

Luke Pulverenti 11 years ago
parent
commit
98d53c7838

+ 29 - 1
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<TimerInfoDto>
     {
@@ -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);
+        }
     }
 }

+ 7 - 0
MediaBrowser.Controller/LiveTv/ILiveTvManager.cs

@@ -45,6 +45,13 @@ namespace MediaBrowser.Controller.LiveTv
         /// <returns>Task.</returns>
         Task CancelTimer(string id);
 
+        /// <summary>
+        /// Cancels the series timer.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <returns>Task.</returns>
+        Task CancelSeriesTimer(string id);
+        
         /// <summary>
         /// Adds the parts.
         /// </summary>

+ 8 - 0
MediaBrowser.Controller/LiveTv/ILiveTvService.cs

@@ -30,6 +30,14 @@ namespace MediaBrowser.Controller.LiveTv
         /// <returns>Task.</returns>
         Task CancelTimerAsync(string timerId, CancellationToken cancellationToken);
 
+        /// <summary>
+        /// Cancels the series timer asynchronous.
+        /// </summary>
+        /// <param name="timerId">The timer identifier.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task.</returns>
+        Task CancelSeriesTimerAsync(string timerId, CancellationToken cancellationToken);
+        
         /// <summary>
         /// Deletes the recording asynchronous.
         /// </summary>

+ 6 - 0
MediaBrowser.Model/LiveTv/RecordingInfoDto.cs

@@ -33,6 +33,12 @@ namespace MediaBrowser.Model.LiveTv
         /// </summary>
         public string ChannelName { get; set; }
 
+        /// <summary>
+        /// Gets or sets the name of the service.
+        /// </summary>
+        /// <value>The name of the service.</value>
+        public string ServiceName { get; set; }
+
         /// <summary>
         /// Name of the recording.
         /// </summary>

+ 6 - 0
MediaBrowser.Model/LiveTv/SeriesTimerInfoDto.cs

@@ -21,6 +21,12 @@ namespace MediaBrowser.Model.LiveTv
         /// </summary>
         public string ChannelId { get; set; }
 
+        /// <summary>
+        /// Gets or sets the name of the service.
+        /// </summary>
+        /// <value>The name of the service.</value>
+        public string ServiceName { get; set; }
+
         /// <summary>
         /// Gets or sets the external channel identifier.
         /// </summary>

+ 6 - 0
MediaBrowser.Model/LiveTv/TimerInfoDto.cs

@@ -31,6 +31,12 @@ namespace MediaBrowser.Model.LiveTv
         /// </summary>
         public string ChannelName { get; set; }
 
+        /// <summary>
+        /// Gets or sets the name of the service.
+        /// </summary>
+        /// <value>The name of the service.</value>
+        public string ServiceName { get; set; }
+
         /// <summary>
         /// Gets or sets the program identifier.
         /// </summary>

+ 11 - 4
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)

+ 18 - 19
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<RecordingInfoDto> 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);

+ 2 - 2
Nuget/MediaBrowser.Common.Internal.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Common.Internal</id>
-        <version>3.0.271</version>
+        <version>3.0.273</version>
         <title>MediaBrowser.Common.Internal</title>
         <authors>Luke</authors>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
         <copyright>Copyright © Media Browser 2013</copyright>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.271" />
+            <dependency id="MediaBrowser.Common" version="3.0.273" />
             <dependency id="NLog" version="2.1.0" />
             <dependency id="SimpleInjector" version="2.4.0" />
             <dependency id="sharpcompress" version="0.10.2" />

+ 1 - 1
Nuget/MediaBrowser.Common.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Common</id>
-        <version>3.0.271</version>
+        <version>3.0.273</version>
         <title>MediaBrowser.Common</title>
         <authors>Media Browser Team</authors>
         <owners>ebr,Luke,scottisafool</owners>

+ 2 - 2
Nuget/MediaBrowser.Server.Core.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Server.Core</id>
-        <version>3.0.271</version>
+        <version>3.0.273</version>
         <title>Media Browser.Server.Core</title>
         <authors>Media Browser Team</authors>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains core components required to build plugins for Media Browser Server.</description>
         <copyright>Copyright © Media Browser 2013</copyright>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.271" />
+            <dependency id="MediaBrowser.Common" version="3.0.273" />
         </dependencies>
     </metadata>
     <files>