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 /MediaBrowser.Server.Implementations | |
| parent | 8e7b97db521913cca9043e1fe1b1edb857053af3 (diff) | |
added tuner list to tv status page
Diffstat (limited to 'MediaBrowser.Server.Implementations')
| -rw-r--r-- | MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs | 27 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 41 |
2 files changed, 65 insertions, 3 deletions
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); + } } } |
