added tuner list to tv status page

pull/702/head
Luke Pulverenti 11 years ago
parent 8e7b97db52
commit 06563e83c6

@ -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);
}
}
}

@ -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);
}
}

@ -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,

@ -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>

@ -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);
}
}
}

@ -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 || {});

@ -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>

@ -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" />

@ -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>

@ -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>

Loading…
Cancel
Save