2
0
Эх сурвалжийг харах

add tv service status reporting

Luke Pulverenti 11 жил өмнө
parent
commit
b469012304

+ 3 - 14
MediaBrowser.Api/LiveTv/LiveTvService.cs

@@ -5,7 +5,6 @@ using MediaBrowser.Model.LiveTv;
 using MediaBrowser.Model.Querying;
 using ServiceStack;
 using System;
-using System.Collections.Generic;
 using System.Globalization;
 using System.Linq;
 using System.Threading;
@@ -83,7 +82,7 @@ namespace MediaBrowser.Api.LiveTv
 
         [ApiMember(Name = "Status", Description = "Optional filter by recordings that are in progress, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
         public bool? IsInProgress { get; set; }
-        
+
         [ApiMember(Name = "SeriesTimerId", Description = "Optional filter by recordings belonging to a series timer", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
         public string SeriesTimerId { get; set; }
     }
@@ -295,27 +294,17 @@ namespace MediaBrowser.Api.LiveTv
 
         public object Get(GetLiveTvInfo request)
         {
-            var services = _liveTvManager.Services
-                .Select(GetServiceInfo)
-                .ToList();
+            var services = _liveTvManager.GetServiceInfos(CancellationToken.None).Result;
 
             var info = new LiveTvInfo
             {
-                Services = services,
+                Services = services.ToList(),
                 ActiveServiceName = _liveTvManager.ActiveService == null ? null : _liveTvManager.ActiveService.Name
             };
 
             return ToOptimizedResult(info);
         }
 
-        private LiveTvServiceInfo GetServiceInfo(ILiveTvService service)
-        {
-            return new LiveTvServiceInfo
-            {
-                Name = service.Name
-            };
-        }
-
         public object Get(GetChannels request)
         {
             var result = _liveTvManager.GetChannels(new ChannelQuery

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

@@ -24,6 +24,13 @@ namespace MediaBrowser.Controller.LiveTv
         /// <value>The services.</value>
         IReadOnlyList<ILiveTvService> Services { get; }
 
+        /// <summary>
+        /// Gets the service infos.
+        /// </summary>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task{IEnumerable{LiveTvServiceInfo}}.</returns>
+        Task<IEnumerable<LiveTvServiceInfo>> GetServiceInfos(CancellationToken cancellationToken);
+
         /// <summary>
         /// Gets the new timer defaults asynchronous.
         /// </summary>

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

@@ -26,6 +26,13 @@ namespace MediaBrowser.Controller.LiveTv
         /// <value>The name.</value>
         string Name { get; }
 
+        /// <summary>
+        /// Gets the status information asynchronous.
+        /// </summary>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task{LiveTvServiceStatusInfo}.</returns>
+        Task<LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken cancellationToken);
+
         /// <summary>
         /// Gets the channels async.
         /// </summary>

+ 19 - 0
MediaBrowser.Controller/LiveTv/LiveTvServiceStatusInfo.cs

@@ -0,0 +1,19 @@
+using MediaBrowser.Model.LiveTv;
+
+namespace MediaBrowser.Controller.LiveTv
+{
+    public class LiveTvServiceStatusInfo
+    {
+        /// <summary>
+        /// Gets or sets the status.
+        /// </summary>
+        /// <value>The status.</value>
+        public LiveTvServiceStatus Status { get; set; }
+
+        /// <summary>
+        /// Gets or sets the status message.
+        /// </summary>
+        /// <value>The status message.</value>
+        public string StatusMessage { get; set; }
+    }
+}

+ 1 - 0
MediaBrowser.Controller/MediaBrowser.Controller.csproj

@@ -121,6 +121,7 @@
     <Compile Include="LiveTv\ILiveTvManager.cs" />
     <Compile Include="LiveTv\ILiveTvService.cs" />
     <Compile Include="LiveTv\LiveTvException.cs" />
+    <Compile Include="LiveTv\LiveTvServiceStatusInfo.cs" />
     <Compile Include="LiveTv\StreamResponseInfo.cs" />
     <Compile Include="LiveTv\LiveTvProgram.cs" />
     <Compile Include="LiveTv\LiveTvVideoRecording.cs" />

+ 83 - 0
MediaBrowser.Model/ApiClient/IApiClient.cs

@@ -951,6 +951,15 @@ namespace MediaBrowser.Model.ApiClient
         /// <returns>Task{LiveTvInfo}.</returns>
         Task<QueryResult<ChannelInfoDto>> GetLiveTvChannelsAsync(ChannelQuery query, CancellationToken cancellationToken);
 
+        /// <summary>
+        /// Gets the live tv channel asynchronous.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="userId">The user identifier.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task{ChannelInfoDto}.</returns>
+        Task<ChannelInfoDto> GetLiveTvChannelAsync(string id, string userId, CancellationToken cancellationToken);
+        
         /// <summary>
         /// Gets the live tv recordings asynchronous.
         /// </summary>
@@ -959,6 +968,15 @@ namespace MediaBrowser.Model.ApiClient
         /// <returns>Task{QueryResult{RecordingInfoDto}}.</returns>
         Task<QueryResult<RecordingInfoDto>> GetLiveTvRecordingsAsync(RecordingQuery query, CancellationToken cancellationToken);
 
+        /// <summary>
+        /// Gets the live tv recording asynchronous.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="userId">The user identifier.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task{RecordingInfoDto}.</returns>
+        Task<RecordingInfoDto> GetLiveTvRecordingAsync(string id, string userId, CancellationToken cancellationToken);
+        
         /// <summary>
         /// Gets the live tv recording groups asynchronous.
         /// </summary>
@@ -966,5 +984,70 @@ namespace MediaBrowser.Model.ApiClient
         /// <param name="cancellationToken">The cancellation token.</param>
         /// <returns>Task{QueryResult{RecordingGroupDto}}.</returns>
         Task<QueryResult<RecordingGroupDto>> GetLiveTvRecordingGroupsAsync(RecordingGroupQuery query, CancellationToken cancellationToken);
+
+        /// <summary>
+        /// Gets the live tv recording group asynchronous.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="userId">The user identifier.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task{RecordingGroupDto}.</returns>
+        Task<RecordingGroupDto> GetLiveTvRecordingGroupAsync(string id, string userId, CancellationToken cancellationToken);
+        
+        /// <summary>
+        /// Gets the live tv timers asynchronous.
+        /// </summary>
+        /// <param name="query">The query.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task{QueryResult{TimerInfoDto}}.</returns>
+        Task<QueryResult<TimerInfoDto>> GetLiveTvTimersAsync(TimerQuery query, CancellationToken cancellationToken);
+
+        /// <summary>
+        /// Gets the live tv timer asynchronous.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task{TimerInfoDto}.</returns>
+        Task<TimerInfoDto> GetLiveTvTimerAsync(string id, CancellationToken cancellationToken);
+        
+        /// <summary>
+        /// Gets the live tv series timers asynchronous.
+        /// </summary>
+        /// <param name="query">The query.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task{QueryResult{SeriesTimerInfoDto}}.</returns>
+        Task<QueryResult<SeriesTimerInfoDto>> GetLiveTvSeriesTimersAsync(SeriesTimerQuery query, CancellationToken cancellationToken);
+
+        /// <summary>
+        /// Gets the live tv series timer asynchronous.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task{SeriesTimerInfoDto}.</returns>
+        Task<SeriesTimerInfoDto> GetLiveTvSeriesTimerAsync(string id, CancellationToken cancellationToken);
+
+        /// <summary>
+        /// Cancels the live tv timer asynchronous.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task.</returns>
+        Task CancelLiveTvTimerAsync(string id, CancellationToken cancellationToken);
+
+        /// <summary>
+        /// Cancels the live tv series timer asynchronous.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task.</returns>
+        Task CancelLiveTvSeriesTimerAsync(string id, CancellationToken cancellationToken);
+        
+        /// <summary>
+        /// Deletes the live tv recording asynchronous.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task.</returns>
+        Task DeleteLiveTvRecordingAsync(string id, CancellationToken cancellationToken);
     }
 }

+ 1 - 1
MediaBrowser.Model/Configuration/ServerConfiguration.cs

@@ -234,7 +234,7 @@ namespace MediaBrowser.Model.Configuration
             : base()
         {
             MediaEncodingQuality = EncodingQuality.HighSpeed;
-            ImageSavingConvention = ImageSavingConvention.Legacy;
+            ImageSavingConvention = ImageSavingConvention.Compatible;
             HttpServerPortNumber = 8096;
             LegacyWebSocketPortNumber = 8945;
             EnableHttpLevelLogging = true;

+ 18 - 0
MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs

@@ -13,6 +13,18 @@ namespace MediaBrowser.Model.LiveTv
         /// </summary>
         /// <value>The name.</value>
         public string Name { get; set; }
+
+        /// <summary>
+        /// Gets or sets the status.
+        /// </summary>
+        /// <value>The status.</value>
+        public LiveTvServiceStatus Status { get; set; }
+
+        /// <summary>
+        /// Gets or sets the status message.
+        /// </summary>
+        /// <value>The status message.</value>
+        public string StatusMessage { get; set; }
     }
 
     public class GuideInfo
@@ -49,4 +61,10 @@ namespace MediaBrowser.Model.LiveTv
             Services = new List<LiveTvServiceInfo>();
         }
     }
+
+    public enum LiveTvServiceStatus
+    {
+        Ok = 0,
+        Unavailable = 1
+    }
 }

+ 33 - 1
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -1130,7 +1130,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
             await service.UpdateSeriesTimerAsync(info, cancellationToken).ConfigureAwait(false);
         }
 
-        private List<string> GetRecordingGroupNames(RecordingInfo recording)
+        private IEnumerable<string> GetRecordingGroupNames(RecordingInfo recording)
         {
             var list = new List<string>();
 
@@ -1292,5 +1292,37 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 }
             }
         }
+
+        public async Task<IEnumerable<LiveTvServiceInfo>> GetServiceInfos(CancellationToken cancellationToken)
+        {
+            var tasks = Services.Select(i => GetServiceInfo(i, cancellationToken));
+
+            return await Task.WhenAll(tasks).ConfigureAwait(false);
+        }
+
+        private async Task<LiveTvServiceInfo> GetServiceInfo(ILiveTvService service, CancellationToken cancellationToken)
+        {
+            var info = new LiveTvServiceInfo
+            {
+                Name = service.Name
+            };
+
+            try
+            {
+                var statusInfo = await service.GetStatusInfoAsync(cancellationToken).ConfigureAwait(false);
+
+                info.Status = statusInfo.Status;
+                info.StatusMessage = statusInfo.StatusMessage;
+            }
+            catch (Exception ex)
+            {
+                _logger.ErrorException("Error getting service status info from {0}", ex, service.Name);
+
+                info.Status = LiveTvServiceStatus.Unavailable;
+                info.StatusMessage = ex.Message;
+            }
+
+            return info;
+        }
     }
 }

+ 1 - 0
MediaBrowser.ServerApplication/ApplicationHost.cs

@@ -421,6 +421,7 @@ namespace MediaBrowser.ServerApplication
             LocalizedStrings.ApplicationPaths = ApplicationPaths;
             Folder.UserManager = UserManager;
             BaseItem.FileSystem = FileSystemManager;
+            BaseItem.UserDataManager = UserDataManager;
         }
 
         /// <summary>

+ 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.302</version>
+        <version>3.0.303</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.302" />
+            <dependency id="MediaBrowser.Common" version="3.0.303" />
             <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.302</version>
+        <version>3.0.303</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.302</version>
+        <version>3.0.303</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.302" />
+            <dependency id="MediaBrowser.Common" version="3.0.303" />
         </dependencies>
     </metadata>
     <files>