aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/LiveTv
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-03-22 02:49:36 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-03-22 02:49:36 -0400
commit4f025c8e4a33dafdeee3199c72eedce733645273 (patch)
treeabaab0d65f8521d72883c0de18934eb915e432e7 /MediaBrowser.Server.Implementations/LiveTv
parent49c678037a329f35de0ff09999b79cd8a1d4694d (diff)
update tv queries
Diffstat (limited to 'MediaBrowser.Server.Implementations/LiveTv')
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs67
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs83
2 files changed, 18 insertions, 132 deletions
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs
index 81ad6a387..3da0d15d3 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs
@@ -152,21 +152,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return pattern;
}
- /// <summary>
- /// Convert the provider 0-5 scale to our 0-10 scale
- /// </summary>
- /// <param name="val"></param>
- /// <returns></returns>
- private float? GetClientCommunityRating(float? val)
- {
- if (!val.HasValue)
- {
- return null;
- }
-
- return val.Value;
- }
-
public LiveTvTunerInfoDto GetTunerInfoDto(string serviceName, LiveTvTunerInfo info, string channelName)
{
var dto = new LiveTvTunerInfoDto
@@ -195,54 +180,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return dto;
}
- /// <summary>
- /// Gets the channel info dto.
- /// </summary>
- /// <param name="info">The info.</param>
- /// <param name="options">The options.</param>
- /// <param name="currentProgram">The current program.</param>
- /// <param name="user">The user.</param>
- /// <returns>ChannelInfoDto.</returns>
- public ChannelInfoDto GetChannelInfoDto(LiveTvChannel info, DtoOptions options, LiveTvProgram currentProgram, User user = null)
- {
- var dto = new ChannelInfoDto
- {
- Name = info.Name,
- ServiceName = info.ServiceName,
- ChannelType = info.ChannelType,
- Number = info.Number,
- Type = info.GetClientTypeName(),
- Id = info.Id.ToString("N"),
- MediaType = info.MediaType,
- ExternalId = info.ExternalId,
- MediaSources = info.GetMediaSources(true).ToList(),
- ServerId = _appHost.SystemId
- };
-
- if (user != null)
- {
- dto.UserData = _userDataManager.GetUserDataDto(info, user);
-
- dto.PlayAccess = info.GetPlayAccess(user);
- }
-
- var imageTag = GetImageTag(info);
-
- if (imageTag != null)
- {
- dto.ImageTags[ImageType.Primary] = imageTag;
-
- _dtoService.AttachPrimaryImageAspectRatio(dto, info);
- }
-
- if (currentProgram != null)
- {
- dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, options, user);
- }
-
- return dto;
- }
-
internal string GetImageTag(IHasImages info)
{
try
@@ -324,7 +261,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
if (!string.IsNullOrEmpty(dto.ChannelId) && string.IsNullOrEmpty(info.ChannelId))
{
- var channel = await liveTv.GetChannel(dto.ChannelId, cancellationToken).ConfigureAwait(false);
+ var channel = liveTv.GetInternalChannel(dto.ChannelId);
if (channel != null)
{
@@ -387,7 +324,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
if (!string.IsNullOrEmpty(dto.ChannelId) && string.IsNullOrEmpty(info.ChannelId))
{
- var channel = await liveTv.GetChannel(dto.ChannelId, cancellationToken).ConfigureAwait(false);
+ var channel = liveTv.GetInternalChannel(dto.ChannelId);
if (channel != null)
{
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 22516e7a6..6c00d61f2 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -244,42 +244,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return result;
}
- public async Task<QueryResult<ChannelInfoDto>> GetChannels(LiveTvChannelQuery query, DtoOptions options, CancellationToken cancellationToken)
- {
- var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);
-
- var internalResult = await GetInternalChannels(query, cancellationToken).ConfigureAwait(false);
-
- var returnList = new List<ChannelInfoDto>();
-
- var now = DateTime.UtcNow;
-
- var programs = query.AddCurrentProgram ? _libraryManager.QueryItems(new InternalItemsQuery
- {
- IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
- MaxStartDate = now,
- MinEndDate = now,
- ChannelIds = internalResult.Items.Select(i => i.Id.ToString("N")).ToArray()
-
- }).Items.Cast<LiveTvProgram>().OrderBy(i => i.StartDate).ToList() : new List<LiveTvProgram>();
-
- foreach (var channel in internalResult.Items)
- {
- var channelIdString = channel.Id.ToString("N");
- var currentProgram = programs.FirstOrDefault(i => string.Equals(i.ChannelId, channelIdString, StringComparison.OrdinalIgnoreCase));
-
- returnList.Add(_tvDtoService.GetChannelInfoDto(channel, options, currentProgram, user));
- }
-
- var result = new QueryResult<ChannelInfoDto>
- {
- Items = returnList.ToArray(),
- TotalRecordCount = internalResult.TotalRecordCount
- };
-
- return result;
- }
-
public LiveTvChannel GetInternalChannel(string id)
{
return GetInternalChannel(new Guid(id));
@@ -1859,52 +1823,37 @@ namespace MediaBrowser.Server.Implementations.LiveTv
};
}
- public async Task<ChannelInfoDto> GetChannel(string id, CancellationToken cancellationToken, User user = null)
+ public void AddChannelInfo(List<Tuple<BaseItemDto, LiveTvChannel>> tuples, DtoOptions options, User user)
{
- var channel = GetInternalChannel(id);
-
var now = DateTime.UtcNow;
+ var channelIds = tuples.Select(i => i.Item2.Id.ToString("N")).Distinct().ToArray();
+
var programs = _libraryManager.GetItemList(new InternalItemsQuery(user)
{
IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
- ChannelIds = new[] { id },
+ ChannelIds = channelIds,
MaxStartDate = now,
MinEndDate = now,
- Limit = 1,
+ Limit = channelIds.Length,
SortBy = new[] { "StartDate" }
- }, new string[] { }).Cast<LiveTvProgram>();
-
- var currentProgram = programs.FirstOrDefault();
-
- var dto = _tvDtoService.GetChannelInfoDto(channel, new DtoOptions(), currentProgram, user);
+ }, new string[] { }).ToList();
- return dto;
- }
-
- public void AddChannelInfo(BaseItemDto dto, LiveTvChannel channel, DtoOptions options, User user)
- {
- dto.MediaSources = channel.GetMediaSources(true).ToList();
-
- var now = DateTime.UtcNow;
-
- var programs = _libraryManager.GetItemList(new InternalItemsQuery(user)
+ foreach (var tuple in tuples)
{
- IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
- ChannelIds = new[] { channel.Id.ToString("N") },
- MaxStartDate = now,
- MinEndDate = now,
- Limit = 1,
- SortBy = new[] { "StartDate" }
+ var dto = tuple.Item1;
+ var channel = tuple.Item2;
- }, new string[] { }).Cast<LiveTvProgram>();
+ dto.MediaSources = channel.GetMediaSources(true).ToList();
- var currentProgram = programs.FirstOrDefault();
+ var channelIdString = channel.Id.ToString("N");
+ var currentProgram = programs.FirstOrDefault(i => string.Equals(i.ChannelId, channelIdString));
- if (currentProgram != null)
- {
- dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, options, user);
+ if (currentProgram != null)
+ {
+ dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, options, user);
+ }
}
}