예제 #1
0
        /// <summary>
        /// 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, 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()
            };

            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 = GetProgramInfoDto(currentProgram, info, user);
            }

            return dto;
        }
예제 #2
0
        public void AddChannelInfo(BaseItemDto dto, LiveTvChannel channel, DtoOptions options, User user)
        {
            dto.MediaSources = channel.GetMediaSources(true).ToList();

            var now = DateTime.UtcNow;

            var programs = _libraryManager.GetItems(new InternalItemsQuery
            {
                IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
                ChannelIds = new[] { channel.Id.ToString("N") },
                MaxStartDate = now,
                MinEndDate = now,
                Limit = 1,
                SortBy = new[] { "StartDate" }

            }).Items.Cast<LiveTvProgram>();

            var currentProgram = programs.FirstOrDefault();

            if (currentProgram != null)
            {
                dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, options, user);
            }
        }