The Free Software Media System - Server Backend & API
add tv service status reporting
Luke Pulverentib4690123049a
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.csindex ba4f0fb101..9f45df8e6a 100644--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs+++ b/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.LiveTvpublic 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 ChannelQuerydiff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.csindex 31c336932f..88e2c9b4e1 100644--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs+++ b/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>diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.csindex 7217b6e13c..955d81b031 100644--- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs+++ b/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>diff --git a/MediaBrowser.Controller/LiveTv/LiveTvServiceStatusInfo.cs b/MediaBrowser.Controller/LiveTv/LiveTvServiceStatusInfo.csnew file mode 100644index 0000000000..3da00de49a--- /dev/null+++ b/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; }+ }+}diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csprojindex 9452700b5e..353e92444f 100644--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj+++ b/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" />diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.csindex 55ca9edc78..edabd4abac 100644--- a/MediaBrowser.Model/ApiClient/IApiClient.cs+++ b/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);}}\ No newline at end of filediff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.csindex f7b4cf3735..281f1350c4 100644--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs+++ b/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;diff --git a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.csindex c93779b5a9..f59a707adf 100644--- a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs+++ b/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.LiveTvServices = new List<LiveTvServiceInfo>();}}++ public enum LiveTvServiceStatus+ {+ Ok = 0,+ Unavailable = 1+ }}diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex 5781dd69a9..2269ab0c52 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -1130,7 +1130,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvawait 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;+ }}}diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.csindex 3681209e77..f6053f9981 100644--- a/MediaBrowser.ServerApplication/ApplicationHost.cs+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs@@ -421,6 +421,7 @@ namespace MediaBrowser.ServerApplicationLocalizedStrings.ApplicationPaths = ApplicationPaths;Folder.UserManager = UserManager;BaseItem.FileSystem = FileSystemManager;+ BaseItem.UserDataManager = UserDataManager;}/// <summary>diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspecindex 0505b0992d..45ec23ac9b 100644--- a/Nuget/MediaBrowser.Common.Internal.nuspec+++ b/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" />diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspecindex e6ea16efa0..a4ce5fc2d6 100644--- a/Nuget/MediaBrowser.Common.nuspec+++ b/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>diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspecindex 2935fb958a..3571d202d2 100644--- a/Nuget/MediaBrowser.Server.Core.nuspec+++ b/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>