예제 #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
            };

            if (user != null)
            {
                dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, info.GetUserDataKey()));

                dto.PlayAccess = info.GetPlayAccess(user);
            }

            var imageTag = GetImageTag(info);

            if (imageTag.HasValue)
            {
                dto.ImageTags[ImageType.Primary] = imageTag.Value;
            }

            if (currentProgram != null)
            {
                dto.CurrentProgram = GetProgramInfoDto(currentProgram, info, user);
            }

            return(dto);
        }
예제 #2
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(),
                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, new List <ItemFields>
                {
                    ItemFields.PrimaryImageAspectRatio
                });
            }

            if (currentProgram != null)
            {
                dto.CurrentProgram = GetProgramInfoDto(currentProgram, info, user);
            }

            return(dto);
        }