mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 09:59:06 -07:00
fixes #550 - Add internal interfaces for live tv
This commit is contained in:
parent
0a313b5087
commit
98442402a5
74
MediaBrowser.Api/LiveTv/LiveTvService.cs
Normal file
74
MediaBrowser.Api/LiveTv/LiveTvService.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using ServiceStack.ServiceHost;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api.LiveTv
|
||||
{
|
||||
[Route("/LiveTv/Services", "GET")]
|
||||
[Api(Description = "Gets available live tv services.")]
|
||||
public class GetServices : IReturn<List<LiveTvServiceInfo>>
|
||||
{
|
||||
}
|
||||
|
||||
[Route("/LiveTv/Channels", "GET")]
|
||||
[Api(Description = "Gets available live tv channels.")]
|
||||
public class GetChannels : IReturn<List<ChannelInfoDto>>
|
||||
{
|
||||
// Add filter by service if needed, and/or other filters
|
||||
}
|
||||
|
||||
public class LiveTvService : BaseApiService
|
||||
{
|
||||
private readonly ILiveTvManager _liveTvManager;
|
||||
|
||||
public LiveTvService(ILiveTvManager liveTvManager)
|
||||
{
|
||||
_liveTvManager = liveTvManager;
|
||||
}
|
||||
|
||||
public object Get(GetServices request)
|
||||
{
|
||||
var services = _liveTvManager.Services;
|
||||
|
||||
var result = services.Select(GetServiceInfo)
|
||||
.ToList();
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
public object Get(GetChannels request)
|
||||
{
|
||||
var services = _liveTvManager.Services;
|
||||
|
||||
var result = services.Select(GetServiceInfo)
|
||||
.ToList();
|
||||
|
||||
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
|
||||
{
|
||||
Name = service.Name
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -81,6 +81,7 @@
|
||||
<Compile Include="Library\LibraryHelpers.cs" />
|
||||
<Compile Include="Library\LibraryService.cs" />
|
||||
<Compile Include="Library\LibraryStructureService.cs" />
|
||||
<Compile Include="LiveTv\LiveTvService.cs" />
|
||||
<Compile Include="LocalizationService.cs" />
|
||||
<Compile Include="MoviesService.cs" />
|
||||
<Compile Include="NotificationsService.cs" />
|
||||
|
21
MediaBrowser.Controller/LiveTv/ChannelInfo.cs
Normal file
21
MediaBrowser.Controller/LiveTv/ChannelInfo.cs
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ChannelInfo
|
||||
/// </summary>
|
||||
public class ChannelInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the service.
|
||||
/// </summary>
|
||||
/// <value>The name of the service.</value>
|
||||
public string ServiceName { get; set; }
|
||||
}
|
||||
}
|
30
MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
Normal file
30
MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages all live tv services installed on the server
|
||||
/// </summary>
|
||||
public interface ILiveTvManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the services.
|
||||
/// </summary>
|
||||
/// <value>The services.</value>
|
||||
IReadOnlyList<ILiveTvService> Services { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds the parts.
|
||||
/// </summary>
|
||||
/// <param name="services">The services.</param>
|
||||
void AddParts(IEnumerable<ILiveTvService> services);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channel info dto.
|
||||
/// </summary>
|
||||
/// <param name="info">The info.</param>
|
||||
/// <returns>ChannelInfoDto.</returns>
|
||||
ChannelInfoDto GetChannelInfoDto(ChannelInfo info);
|
||||
}
|
||||
}
|
25
MediaBrowser.Controller/LiveTv/ILiveTvService.cs
Normal file
25
MediaBrowser.Controller/LiveTv/ILiveTvService.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a single live tv back end (next pvr, media portal, etc).
|
||||
/// </summary>
|
||||
public interface ILiveTvService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channels async.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{ChannelInfo}}.</returns>
|
||||
Task<IEnumerable<ChannelInfo>> GetChannelsAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
@ -96,6 +96,9 @@
|
||||
<Compile Include="Library\ILibraryPrescanTask.cs" />
|
||||
<Compile Include="Library\IMetadataSaver.cs" />
|
||||
<Compile Include="Library\ItemUpdateType.cs" />
|
||||
<Compile Include="LiveTv\ChannelInfo.cs" />
|
||||
<Compile Include="LiveTv\ILiveTvManager.cs" />
|
||||
<Compile Include="LiveTv\ILiveTvService.cs" />
|
||||
<Compile Include="Localization\ILocalizationManager.cs" />
|
||||
<Compile Include="Notifications\INotificationsRepository.cs" />
|
||||
<Compile Include="Notifications\NotificationUpdateEventArgs.cs" />
|
||||
|
@ -215,6 +215,12 @@
|
||||
<Compile Include="..\MediaBrowser.Model\IO\IZipClient.cs">
|
||||
<Link>IO\IZipClient.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs">
|
||||
<Link>LiveTv\ChannelInfoDto.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs">
|
||||
<Link>LiveTv\LiveTvServiceInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs">
|
||||
<Link>Logging\ILogger.cs</Link>
|
||||
</Compile>
|
||||
|
@ -199,6 +199,12 @@
|
||||
<Compile Include="..\MediaBrowser.Model\IO\IZipClient.cs">
|
||||
<Link>IO\IZipClient.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs">
|
||||
<Link>LiveTv\ChannelInfoDto.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs">
|
||||
<Link>LiveTv\LiveTvServiceInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs">
|
||||
<Link>Logging\ILogger.cs</Link>
|
||||
</Compile>
|
||||
|
21
MediaBrowser.Model/LiveTv/ChannelInfoDto.cs
Normal file
21
MediaBrowser.Model/LiveTv/ChannelInfoDto.cs
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
namespace MediaBrowser.Model.LiveTv
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ChannelInfoDto
|
||||
/// </summary>
|
||||
public class ChannelInfoDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the service.
|
||||
/// </summary>
|
||||
/// <value>The name of the service.</value>
|
||||
public string ServiceName { get; set; }
|
||||
}
|
||||
}
|
15
MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs
Normal file
15
MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
namespace MediaBrowser.Model.LiveTv
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ServiceInfo
|
||||
/// </summary>
|
||||
public class LiveTvServiceInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -66,6 +66,8 @@
|
||||
<Compile Include="IO\IIsoManager.cs" />
|
||||
<Compile Include="IO\IIsoMount.cs" />
|
||||
<Compile Include="IO\IIsoMounter.cs" />
|
||||
<Compile Include="LiveTv\ChannelInfoDto.cs" />
|
||||
<Compile Include="LiveTv\LiveTvServiceInfo.cs" />
|
||||
<Compile Include="Net\WebSocketMessage.cs" />
|
||||
<Compile Include="Net\WebSocketMessageType.cs" />
|
||||
<Compile Include="Net\WebSocketState.cs" />
|
||||
|
45
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
Normal file
45
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
{
|
||||
/// <summary>
|
||||
/// Class LiveTvManager
|
||||
/// </summary>
|
||||
public class LiveTvManager : ILiveTvManager
|
||||
{
|
||||
private readonly List<ILiveTvService> _services = new List<ILiveTvService>();
|
||||
/// <summary>
|
||||
/// Gets the services.
|
||||
/// </summary>
|
||||
/// <value>The services.</value>
|
||||
public IReadOnlyList<ILiveTvService> Services
|
||||
{
|
||||
get { return _services; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the parts.
|
||||
/// </summary>
|
||||
/// <param name="services">The services.</param>
|
||||
public void AddParts(IEnumerable<ILiveTvService> services)
|
||||
{
|
||||
_services.AddRange(services);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channel info dto.
|
||||
/// </summary>
|
||||
/// <param name="info">The info.</param>
|
||||
/// <returns>ChannelInfoDto.</returns>
|
||||
public ChannelInfoDto GetChannelInfoDto(ChannelInfo info)
|
||||
{
|
||||
return new ChannelInfoDto
|
||||
{
|
||||
Name = info.Name,
|
||||
ServiceName = info.ServiceName
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -148,6 +148,7 @@
|
||||
<Compile Include="Library\Validators\PeoplePostScanTask.cs" />
|
||||
<Compile Include="Library\Validators\StudiosPostScanTask.cs" />
|
||||
<Compile Include="Library\Validators\StudiosValidator.cs" />
|
||||
<Compile Include="LiveTv\LiveTvManager.cs" />
|
||||
<Compile Include="Localization\LocalizationManager.cs" />
|
||||
<Compile Include="MediaEncoder\MediaEncoder.cs" />
|
||||
<Compile Include="Persistence\SqliteChapterRepository.cs" />
|
||||
|
@ -15,6 +15,7 @@ using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Controller.MediaInfo;
|
||||
using MediaBrowser.Controller.Notifications;
|
||||
@ -39,6 +40,7 @@ using MediaBrowser.Server.Implementations.EntryPoints;
|
||||
using MediaBrowser.Server.Implementations.HttpServer;
|
||||
using MediaBrowser.Server.Implementations.IO;
|
||||
using MediaBrowser.Server.Implementations.Library;
|
||||
using MediaBrowser.Server.Implementations.LiveTv;
|
||||
using MediaBrowser.Server.Implementations.Localization;
|
||||
using MediaBrowser.Server.Implementations.MediaEncoder;
|
||||
using MediaBrowser.Server.Implementations.Persistence;
|
||||
@ -154,6 +156,8 @@ namespace MediaBrowser.ServerApplication
|
||||
private IIsoManager IsoManager { get; set; }
|
||||
private ISessionManager SessionManager { get; set; }
|
||||
|
||||
private ILiveTvManager LiveTvManager { get; set; }
|
||||
|
||||
private ILocalizationManager LocalizationManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -285,6 +289,9 @@ namespace MediaBrowser.ServerApplication
|
||||
DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataRepository, ItemRepository, ImageProcessor);
|
||||
RegisterSingleInstance(DtoService);
|
||||
|
||||
LiveTvManager = new LiveTvManager();
|
||||
RegisterSingleInstance(LiveTvManager);
|
||||
|
||||
var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
|
||||
var itemsTask = Task.Run(async () => await ConfigureItemRepositories().ConfigureAwait(false));
|
||||
var userdataTask = Task.Run(async () => await ConfigureUserDataRepositories().ConfigureAwait(false));
|
||||
|
Loading…
Reference in New Issue
Block a user