The Free Software Media System - Server Backend & API
added tuner list to tv status page
Luke Pulverenti06563e83c694
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.csindex 319470554a..9d827226c9 100644--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs@@ -106,6 +106,14 @@ namespace MediaBrowser.Api.LiveTvpublic string UserId { get; set; }}+ [Route("/LiveTv/Tuners/{Id}/Reset", "POST")]+ [Api(Description = "Resets a tv tuner")]+ public class ResetTuner : IReturnVoid+ {+ [ApiMember(Name = "Id", Description = "Tuner Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]+ public string Id { get; set; }+ }+[Route("/LiveTv/Timers/{Id}", "GET")][Api(Description = "Gets a live tv timer")]public class GetTimer : IReturn<TimerInfoDto>@@ -294,25 +302,7 @@ namespace MediaBrowser.Api.LiveTvpublic object Get(GetLiveTvInfo request){- var services = _liveTvManager.GetServiceInfos(CancellationToken.None).Result;- var servicesList = services.ToList();-- var activeServiceInfo = _liveTvManager.ActiveService == null ? null :- servicesList.FirstOrDefault(i => string.Equals(i.Name, _liveTvManager.ActiveService.Name, StringComparison.OrdinalIgnoreCase));-- var info = new LiveTvInfo- {- Services = servicesList.ToList(),- ActiveServiceName = activeServiceInfo == null ? null : activeServiceInfo.Name,- IsEnabled = _liveTvManager.ActiveService != null,- Status = activeServiceInfo == null ? LiveTvServiceStatus.Unavailable : activeServiceInfo.Status,- StatusMessage = activeServiceInfo == null ? null : activeServiceInfo.StatusMessage- };-- info.EnabledUsers = _userManager.Users- .Where(i => i.Configuration.EnableLiveTvAccess && info.IsEnabled)- .Select(i => i.Id.ToString("N"))- .ToList();+ var info = _liveTvManager.GetLiveTvInfo(CancellationToken.None).Result;return ToOptimizedResult(info);}@@ -573,5 +563,14 @@ namespace MediaBrowser.Api.LiveTv{return ToOptimizedResult(_liveTvManager.GetGuideInfo());}++ public void Post(ResetTuner request)+ {+ AssertUserCanManageLiveTv();++ var task = _liveTvManager.ResetTuner(request.Id, CancellationToken.None);++ Task.WaitAll(task);+ }}}\ No newline at end of filediff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.csindex 88e2c9b4e1..ad42c50910 100644--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs@@ -24,13 +24,6 @@ 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>@@ -256,5 +249,20 @@ namespace MediaBrowser.Controller.LiveTv/// <returns>Task{QueryResult{ProgramInfoDto}}.</returns>Task<QueryResult<ProgramInfoDto>> GetRecommendedPrograms(RecommendedProgramQuery query,CancellationToken cancellationToken);++ /// <summary>+ /// Gets the live tv information.+ /// </summary>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>Task{LiveTvInfo}.</returns>+ Task<LiveTvInfo> GetLiveTvInfo(CancellationToken cancellationToken);++ /// <summary>+ /// Resets the tuner.+ /// </summary>+ /// <param name="id">The identifier.</param>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>Task.</returns>+ Task ResetTuner(string id, CancellationToken cancellationToken);}}diff --git a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.csindex 38ce50a1b9..e764e679b9 100644--- a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs+++ b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs@@ -43,6 +43,13 @@ namespace MediaBrowser.Model.LiveTv/// </summary>/// <value><c>true</c> if this instance has update available; otherwise, <c>false</c>.</value>public bool HasUpdateAvailable { get; set; }++ public List<LiveTvTunerInfoDto> Tuners { get; set; }++ public LiveTvServiceInfo()+ {+ Tuners = new List<LiveTvTunerInfoDto>();+ }}public class GuideInfo@@ -105,6 +112,62 @@ namespace MediaBrowser.Model.LiveTv}}+ public class LiveTvTunerInfoDto+ {+ /// <summary>+ /// Gets or sets the type of the source.+ /// </summary>+ /// <value>The type of the source.</value>+ public string SourceType { get; set; }++ /// <summary>+ /// Gets or sets the name.+ /// </summary>+ /// <value>The name.</value>+ public string Name { get; set; }++ /// <summary>+ /// Gets or sets the identifier.+ /// </summary>+ /// <value>The identifier.</value>+ public string Id { get; set; }++ /// <summary>+ /// Gets or sets the status.+ /// </summary>+ /// <value>The status.</value>+ public LiveTvTunerStatus Status { get; set; }++ /// <summary>+ /// Gets or sets the channel identifier.+ /// </summary>+ /// <value>The channel identifier.</value>+ public string ChannelId { get; set; }++ /// <summary>+ /// Gets or sets the recording identifier.+ /// </summary>+ /// <value>The recording identifier.</value>+ public string RecordingId { get; set; }++ /// <summary>+ /// Gets or sets the name of the program.+ /// </summary>+ /// <value>The name of the program.</value>+ public string ProgramName { get; set; }++ /// <summary>+ /// Gets or sets the clients.+ /// </summary>+ /// <value>The clients.</value>+ public List<string> Clients { get; set; }++ public LiveTvTunerInfoDto()+ {+ Clients = new List<string>();+ }+ }+public enum LiveTvServiceStatus{Ok = 0,diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.csindex 094506199b..5b25e259a6 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs@@ -224,7 +224,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvMediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery{- ItemId = recording.Id+ ItemId = recording.Id}).ToList()};@@ -271,6 +271,31 @@ namespace MediaBrowser.Server.Implementations.LiveTvreturn dto;}+ public LiveTvTunerInfoDto GetTunerInfoDto(string serviceName, LiveTvTunerInfo info)+ {+ var dto = new LiveTvTunerInfoDto+ {+ Name = info.Name,+ Id = info.Id,+ Clients = info.Clients,+ ProgramName = info.ProgramName,+ SourceType = info.SourceType,+ Status = info.Status+ };++ if (!string.IsNullOrEmpty(info.ChannelId))+ {+ dto.ChannelId = GetInternalChannelId(serviceName, info.ChannelId).ToString("N");+ }++ if (!string.IsNullOrEmpty(info.RecordingId))+ {+ dto.RecordingId = GetInternalRecordingId(serviceName, info.RecordingId).ToString("N");+ }++ return dto;+ }+/// <summary>/// Gets the channel info dto./// </summary>diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex 92df78fb91..0d2f323b46 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -1,7 +1,6 @@using MediaBrowser.Common.Extensions;using MediaBrowser.Common.IO;using MediaBrowser.Common.ScheduledTasks;-using MediaBrowser.Controller;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Drawing;using MediaBrowser.Controller.Dto;@@ -1412,7 +1411,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv}}- public async Task<IEnumerable<LiveTvServiceInfo>> GetServiceInfos(CancellationToken cancellationToken)+ private async Task<IEnumerable<LiveTvServiceInfo>> GetServiceInfos(CancellationToken cancellationToken){var tasks = Services.Select(i => GetServiceInfo(i, cancellationToken));@@ -1435,6 +1434,8 @@ namespace MediaBrowser.Server.Implementations.LiveTvinfo.Version = statusInfo.Version;info.HasUpdateAvailable = statusInfo.HasUpdateAvailable;info.HomePageUrl = service.HomePageUrl;++ info.Tuners = statusInfo.Tuners.Select(i => _tvDtoService.GetTunerInfoDto(service.Name, i)).ToList();}catch (Exception ex){@@ -1446,5 +1447,41 @@ namespace MediaBrowser.Server.Implementations.LiveTvreturn info;}++ public async Task<LiveTvInfo> GetLiveTvInfo(CancellationToken cancellationToken)+ {+ var services = await GetServiceInfos(CancellationToken.None).ConfigureAwait(false);+ var servicesList = services.ToList();++ var activeServiceInfo = ActiveService == null ? null :+ servicesList.FirstOrDefault(i => string.Equals(i.Name, ActiveService.Name, StringComparison.OrdinalIgnoreCase));++ var info = new LiveTvInfo+ {+ Services = servicesList.ToList(),+ ActiveServiceName = activeServiceInfo == null ? null : activeServiceInfo.Name,+ IsEnabled = ActiveService != null,+ Status = activeServiceInfo == null ? LiveTvServiceStatus.Unavailable : activeServiceInfo.Status,+ StatusMessage = activeServiceInfo == null ? null : activeServiceInfo.StatusMessage+ };++ info.EnabledUsers = _userManager.Users+ .Where(i => i.Configuration.EnableLiveTvAccess && info.IsEnabled)+ .Select(i => i.Id.ToString("N"))+ .ToList();++ return info;+ }++ /// <summary>+ /// Resets the tuner.+ /// </summary>+ /// <param name="id">The identifier.</param>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>Task.</returns>+ public Task ResetTuner(string id, CancellationToken cancellationToken)+ {+ return ActiveService.ResetTuner(id, cancellationToken);+ }}}diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.jsindex 7a90b12c9b..375aacbce6 100644--- a/MediaBrowser.WebDashboard/ApiClient.js+++ b/MediaBrowser.WebDashboard/ApiClient.js@@ -655,6 +655,20 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi});};+ self.resetLiveTvTuner = function (id) {++ if (!id) {+ throw new Error("null id");+ }++ var url = self.getUrl("LiveTv/Tuners/" + id + "/Reset");++ return self.ajax({+ type: "POST",+ url: url+ });+ };+self.getLiveTvSeriesTimers = function (options) {var url = self.getUrl("LiveTv/SeriesTimers", options || {});diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.configindex d1427603d5..4957f35637 100644--- a/MediaBrowser.WebDashboard/packages.config+++ b/MediaBrowser.WebDashboard/packages.config@@ -1,4 +1,4 @@<?xml version="1.0" encoding="utf-8"?><packages>- <package id="MediaBrowser.ApiClient.Javascript" version="3.0.243" targetFramework="net45" />+ <package id="MediaBrowser.ApiClient.Javascript" version="3.0.244" targetFramework="net45" /></packages>\ No newline at end of filediff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspecindex d239c43484..175ca99c4b 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.307</version>+ <version>3.0.308</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.307" />+ <dependency id="MediaBrowser.Common" version="3.0.308" /><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 329ae9ec9c..f4cafce406 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.307</version>+ <version>3.0.308</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 62323d1b32..dea3753264 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.307</version>+ <version>3.0.308</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.307" />+ <dependency id="MediaBrowser.Common" version="3.0.308" /></dependencies></metadata><files>