diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-01-23 17:15:15 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-01-23 17:15:15 -0500 |
| commit | 06563e83c694126f0744ccc81a3682cd0d0d874c (patch) | |
| tree | c99b094767e627534e45aed8091ce40f8d82baa0 | |
| parent | 8e7b97db521913cca9043e1fe1b1edb857053af3 (diff) | |
added tuner list to tv status page
| -rw-r--r-- | MediaBrowser.Api/LiveTv/LiveTvService.cs | 37 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 22 | ||||
| -rw-r--r-- | MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs | 63 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs | 27 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 41 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/ApiClient.js | 14 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/packages.config | 2 | ||||
| -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 |
10 files changed, 181 insertions, 35 deletions
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 319470554..9d827226c 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -106,6 +106,14 @@ namespace MediaBrowser.Api.LiveTv public 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.LiveTv public 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 file diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 88e2c9b4e..ad42c5091 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -25,13 +25,6 @@ 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> @@ -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.cs index 38ce50a1b..e764e679b 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.cs index 094506199..5b25e259a 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -224,7 +224,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv MediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery { - ItemId = recording.Id + ItemId = recording.Id }).ToList() }; @@ -271,6 +271,31 @@ namespace MediaBrowser.Server.Implementations.LiveTv return 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.cs index 92df78fb9..0d2f323b4 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.LiveTv info.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.LiveTv return 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.js index 7a90b12c9..375aacbce 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.config index d1427603d..4957f3563 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 file diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index d239c4348..175ca99c4 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.nuspec index 329ae9ec9..f4cafce40 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.nuspec index 62323d1b3..dea375326 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> |
