diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-01-16 12:23:30 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-01-16 12:23:30 -0500 |
| commit | b4690123049a70a11101b27af6baaee3572d1549 (patch) | |
| tree | d56b5bb7890ba76180877de0cbbbe403af830b1a | |
| parent | 7d81888038a007eb84c6240acb80bf7ca611eb5c (diff) | |
add tv service status reporting
| -rw-r--r-- | MediaBrowser.Api/LiveTv/LiveTvService.cs | 17 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/LiveTvServiceStatusInfo.cs | 19 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 1 | ||||
| -rw-r--r-- | MediaBrowser.Model/ApiClient/IApiClient.cs | 83 | ||||
| -rw-r--r-- | MediaBrowser.Model/Configuration/ServerConfiguration.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs | 18 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 34 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/ApplicationHost.cs | 1 | ||||
| -rw-r--r-- | Nuget/MediaBrowser.Common.Internal.nuspec | 4 | ||||
| -rw-r--r-- | Nuget/MediaBrowser.Common.nuspec | 2 | ||||
| -rw-r--r-- | Nuget/MediaBrowser.Server.Core.nuspec | 4 |
13 files changed, 178 insertions, 21 deletions
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index ba4f0fb10..9f45df8e6 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.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 diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 31c336932..88e2c9b4e 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -25,6 +25,13 @@ namespace MediaBrowser.Controller.LiveTv 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> /// <param name="cancellationToken">The cancellation token.</param> diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 7217b6e13..955d81b03 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -27,6 +27,13 @@ namespace MediaBrowser.Controller.LiveTv 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> /// <param name="cancellationToken">The cancellation token.</param> diff --git a/MediaBrowser.Controller/LiveTv/LiveTvServiceStatusInfo.cs b/MediaBrowser.Controller/LiveTv/LiveTvServiceStatusInfo.cs new file mode 100644 index 000000000..3da00de49 --- /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.csproj index 9452700b5..353e92444 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.cs index 55ca9edc7..edabd4aba 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -952,6 +952,15 @@ namespace MediaBrowser.Model.ApiClient 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> /// <param name="query">The query.</param> @@ -960,11 +969,85 @@ namespace MediaBrowser.Model.ApiClient 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> /// <param name="query">The query.</param> /// <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 file diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index f7b4cf373..281f1350c 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.cs index c93779b5a..f59a707ad 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.LiveTv Services = 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.cs index 5781dd69a..2269ab0c5 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/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; + } } } diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 3681209e7..f6053f998 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -421,6 +421,7 @@ namespace MediaBrowser.ServerApplication LocalizedStrings.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.nuspec index 0505b0992..45ec23ac9 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.nuspec index e6ea16efa..a4ce5fc2d 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.nuspec index 2935fb958..3571d202d 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> |
