aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs8
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs15
2 files changed, 20 insertions, 3 deletions
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs
index 5857088d2a..83da28b8f2 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs
@@ -259,9 +259,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
/// Gets the channel info dto.
/// </summary>
/// <param name="info">The info.</param>
+ /// <param name="currentProgram">The current program.</param>
/// <param name="user">The user.</param>
/// <returns>ChannelInfoDto.</returns>
- public ChannelInfoDto GetChannelInfoDto(LiveTvChannel info, User user = null)
+ public ChannelInfoDto GetChannelInfoDto(LiveTvChannel info, LiveTvProgram currentProgram, User user = null)
{
var channelInfo = info.ChannelInfo;
@@ -289,6 +290,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
dto.ImageTags[ImageType.Primary] = imageTag.Value;
}
+ if (currentProgram != null)
+ {
+ dto.CurrentProgram = GetProgramInfoDto(currentProgram, channelInfo.Name, user);
+ }
+
return dto;
}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index c6e5a315d9..b38ef5d553 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -107,7 +107,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return number;
}).ThenBy(i => i.Name)
- .Select(i => _tvDtoService.GetChannelInfoDto(i, user))
+ .Select(i => _tvDtoService.GetChannelInfoDto(i, GetCurrentProgram(i.ChannelInfo.Id), user))
.ToArray();
var result = new QueryResult<ChannelInfoDto>
@@ -705,11 +705,22 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{
var channel = GetInternalChannel(id);
- var dto = _tvDtoService.GetChannelInfoDto(channel, user);
+ var dto = _tvDtoService.GetChannelInfoDto(channel, GetCurrentProgram(channel.ChannelInfo.Id), user);
return Task.FromResult(dto);
}
+ private LiveTvProgram GetCurrentProgram(string externalChannelId)
+ {
+ var now = DateTime.UtcNow;
+
+ return _programs.Values
+ .Where(i => string.Equals(externalChannelId, i.ProgramInfo.ChannelId, StringComparison.OrdinalIgnoreCase))
+ .OrderBy(i => i.ProgramInfo.StartDate)
+ .SkipWhile(i => now >= i.ProgramInfo.EndDate)
+ .FirstOrDefault();
+ }
+
public async Task<SeriesTimerInfoDto> GetNewTimerDefaults(CancellationToken cancellationToken)
{
var service = ActiveService;