Adding RecordingInfo
This commit is contained in:
parent
f3ecfc4e05
commit
28ab28768a
|
@ -21,6 +21,13 @@ namespace MediaBrowser.Api.LiveTv
|
|||
// Add filter by service if needed, and/or other filters
|
||||
}
|
||||
|
||||
[Route("/LiveTv/Recordings", "GET")]
|
||||
[Api(Description = "Gets available live tv recordings.")]
|
||||
public class GetRecordings : IReturn<List<RecordingInfo>>
|
||||
{
|
||||
// Add filter by service if needed, and/or other filters
|
||||
}
|
||||
|
||||
public class LiveTvService : BaseApiService
|
||||
{
|
||||
private readonly ILiveTvManager _liveTvManager;
|
||||
|
@ -40,26 +47,6 @@ namespace MediaBrowser.Api.LiveTv
|
|||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
public object Get(GetChannels request)
|
||||
{
|
||||
var result = GetChannelsAsync(request).Result;
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ChannelInfoDto>> GetChannelsAsync(GetChannels request)
|
||||
{
|
||||
var services = _liveTvManager.Services;
|
||||
|
||||
var channelTasks = services.Select(i => i.GetChannelsAsync(CancellationToken.None));
|
||||
|
||||
var channelLists = await Task.WhenAll(channelTasks).ConfigureAwait(false);
|
||||
|
||||
// Aggregate all channels from all services
|
||||
return channelLists.SelectMany(i => i)
|
||||
.Select(_liveTvManager.GetChannelInfoDto);
|
||||
}
|
||||
|
||||
private LiveTvServiceInfo GetServiceInfo(ILiveTvService service)
|
||||
{
|
||||
return new LiveTvServiceInfo
|
||||
|
@ -67,5 +54,43 @@ namespace MediaBrowser.Api.LiveTv
|
|||
Name = service.Name
|
||||
};
|
||||
}
|
||||
|
||||
public object Get(GetChannels request)
|
||||
{
|
||||
var result = GetChannelsAsync(request).Result;
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<ChannelInfoDto>> GetChannelsAsync(GetChannels request)
|
||||
{
|
||||
var services = _liveTvManager.Services;
|
||||
|
||||
var tasks = services.Select(i => i.GetChannelsAsync(CancellationToken.None));
|
||||
|
||||
var channelLists = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
// Aggregate all channels from all services
|
||||
return channelLists.SelectMany(i => i)
|
||||
.Select(_liveTvManager.GetChannelInfoDto);
|
||||
}
|
||||
|
||||
public object Get(GetRecordings request)
|
||||
{
|
||||
var result = GetRecordingsAsync(request).Result;
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<RecordingInfo>> GetRecordingsAsync(GetRecordings request)
|
||||
{
|
||||
var services = _liveTvManager.Services;
|
||||
|
||||
var tasks = services.Select(i => i.GetRecordingsAsync(CancellationToken.None));
|
||||
|
||||
var recordings = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
return recordings.SelectMany(i => i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace MediaBrowser.Controller.LiveTv
|
|||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the service.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Model.LiveTv;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.LiveTv
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
|
||||
namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
|
@ -21,5 +22,7 @@ namespace MediaBrowser.Controller.LiveTv
|
|||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{ChannelInfo}}.</returns>
|
||||
Task<IEnumerable<ChannelInfo>> GetChannelsAsync(CancellationToken cancellationToken);
|
||||
|
||||
Task<IEnumerable<RecordingInfo>> GetRecordingsAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,6 +233,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs">
|
||||
<Link>LiveTv\LiveTvServiceInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\RecordingInfo.cs">
|
||||
<Link>LiveTv\RecordingInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs">
|
||||
<Link>Logging\ILogger.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -220,6 +220,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs">
|
||||
<Link>LiveTv\LiveTvServiceInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\RecordingInfo.cs">
|
||||
<Link>LiveTv\RecordingInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs">
|
||||
<Link>Logging\ILogger.cs</Link>
|
||||
</Compile>
|
||||
|
|
12
MediaBrowser.Model/Dto/RecordingInfoDto.cs
Normal file
12
MediaBrowser.Model/Dto/RecordingInfoDto.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Model.Dto
|
||||
{
|
||||
public class RecordingInfoDto
|
||||
{
|
||||
}
|
||||
}
|
|
@ -12,6 +12,8 @@ namespace MediaBrowser.Model.LiveTv
|
|||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the service.
|
||||
/// </summary>
|
||||
|
|
27
MediaBrowser.Model/LiveTv/RecordingInfo.cs
Normal file
27
MediaBrowser.Model/LiveTv/RecordingInfo.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.LiveTv
|
||||
{
|
||||
public class RecordingInfo
|
||||
{
|
||||
public string ChannelId { get; set; }
|
||||
|
||||
public string ChannelName { get; set; }
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The start date of the recording, in UTC
|
||||
/// </summary>
|
||||
public DateTime StartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The end date of the recording, in UTC
|
||||
/// </summary>
|
||||
public DateTime EndDate { get; set; }
|
||||
}
|
||||
}
|
|
@ -73,6 +73,7 @@
|
|||
<Compile Include="LiveTv\ChannelInfoDto.cs" />
|
||||
<Compile Include="LiveTv\ChannelType.cs" />
|
||||
<Compile Include="LiveTv\LiveTvServiceInfo.cs" />
|
||||
<Compile Include="LiveTv\RecordingInfo.cs" />
|
||||
<Compile Include="Net\WebSocketMessage.cs" />
|
||||
<Compile Include="Net\WebSocketMessageType.cs" />
|
||||
<Compile Include="Net\WebSocketState.cs" />
|
||||
|
|
|
@ -39,7 +39,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||
{
|
||||
Name = info.Name,
|
||||
ServiceName = info.ServiceName,
|
||||
ChannelType = info.ChannelType
|
||||
ChannelType = info.ChannelType,
|
||||
Id = info.Id
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
66
MediaBrowser.ServerApplication/NextPvr/LiveTvService.cs
Normal file
66
MediaBrowser.ServerApplication/NextPvr/LiveTvService.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
|
||||
namespace MediaBrowser.Plugins.NextPvr
|
||||
{
|
||||
/// <summary>
|
||||
/// Class LiveTvService
|
||||
/// </summary>
|
||||
public class LiveTvService : ILiveTvService
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private IApplicationPaths _appPaths;
|
||||
private IJsonSerializer _json;
|
||||
private IHttpClient _httpClient;
|
||||
|
||||
public LiveTvService(ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channels async.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{ChannelInfo}}.</returns>
|
||||
public Task<IEnumerable<ChannelInfo>> GetChannelsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
//using (var stream = await _httpClient.Get(new HttpRequestOptions()
|
||||
// {
|
||||
// Url = "",
|
||||
// CancellationToken = cancellationToken
|
||||
// }))
|
||||
//{
|
||||
|
||||
//}
|
||||
_logger.Info("GetChannelsAsync");
|
||||
|
||||
var channels = new List<ChannelInfo>
|
||||
{
|
||||
new ChannelInfo
|
||||
{
|
||||
Name = "NBC",
|
||||
ServiceName = Name
|
||||
}
|
||||
};
|
||||
|
||||
return Task.FromResult<IEnumerable<ChannelInfo>>(channels);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name
|
||||
{
|
||||
get { return "Next Pvr"; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -237,7 +237,4 @@ Global
|
|||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
Loading…
Reference in New Issue
Block a user