/// <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);
        }
Beispiel #2
0
        public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service, LiveTvProgram program, LiveTvChannel channel)
        {
            var dto = new TimerInfoDto
            {
                Id                    = GetInternalTimerId(service.Name, info.Id).ToString("N"),
                Overview              = info.Overview,
                EndDate               = info.EndDate,
                Name                  = info.Name,
                StartDate             = info.StartDate,
                ExternalId            = info.Id,
                ChannelId             = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"),
                Status                = info.Status,
                SeriesTimerId         = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"),
                PrePaddingSeconds     = info.PrePaddingSeconds,
                PostPaddingSeconds    = info.PostPaddingSeconds,
                IsPostPaddingRequired = info.IsPostPaddingRequired,
                IsPrePaddingRequired  = info.IsPrePaddingRequired,
                KeepUntil             = info.KeepUntil,
                ExternalChannelId     = info.ChannelId,
                ExternalSeriesTimerId = info.SeriesTimerId,
                ServiceName           = service.Name,
                ExternalProgramId     = info.ProgramId,
                Priority              = info.Priority,
                RunTimeTicks          = (info.EndDate - info.StartDate).Ticks,
                ServerId              = _appHost.SystemId
            };

            if (!string.IsNullOrEmpty(info.ProgramId))
            {
                dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N");
            }

            if (program != null)
            {
                dto.ProgramInfo = _dtoService.GetBaseItemDto(program, new DtoOptions());

                if (info.Status != RecordingStatus.Cancelled && info.Status != RecordingStatus.Error)
                {
                    dto.ProgramInfo.TimerId = dto.Id;
                    dto.ProgramInfo.Status  = info.Status.ToString();
                }

                dto.ProgramInfo.SeriesTimerId = dto.SeriesTimerId;

                if (!string.IsNullOrWhiteSpace(info.SeriesTimerId))
                {
                    FillImages(dto.ProgramInfo, info.Name, info.SeriesId);
                }
            }

            if (channel != null)
            {
                dto.ChannelName = channel.Name;
            }

            return(dto);
        }
        public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service, LiveTvProgram program, LiveTvChannel channel)
        {
            var dto = new TimerInfoDto
            {
                Id                    = GetInternalTimerId(service.Name, info.Id).ToString("N"),
                Overview              = info.Overview,
                EndDate               = info.EndDate,
                Name                  = info.Name,
                StartDate             = info.StartDate,
                ExternalId            = info.Id,
                ChannelId             = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"),
                Status                = info.Status,
                SeriesTimerId         = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"),
                PrePaddingSeconds     = info.PrePaddingSeconds,
                PostPaddingSeconds    = info.PostPaddingSeconds,
                IsPostPaddingRequired = info.IsPostPaddingRequired,
                IsPrePaddingRequired  = info.IsPrePaddingRequired,
                ExternalChannelId     = info.ChannelId,
                ExternalSeriesTimerId = info.SeriesTimerId,
                ServiceName           = service.Name,
                ExternalProgramId     = info.ProgramId,
                Priority              = info.Priority,
                RunTimeTicks          = (info.EndDate - info.StartDate).Ticks,
                ServerId              = _appHost.SystemId
            };

            if (!string.IsNullOrEmpty(info.ProgramId))
            {
                dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N");
            }

            if (program != null)
            {
                dto.ProgramInfo = GetProgramInfoDto(program, channel);

                dto.ProgramInfo.TimerId       = dto.Id;
                dto.ProgramInfo.SeriesTimerId = dto.SeriesTimerId;
            }

            if (channel != null)
            {
                dto.ChannelName = channel.Name;
            }

            return(dto);
        }
        /// <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);
        }
        public ProgramInfoDto GetProgramInfoDto(LiveTvProgram item, LiveTvChannel channel, User user = null)
        {
            var dto = new ProgramInfoDto
            {
                Id              = GetInternalProgramId(item.ServiceName, item.ExternalId).ToString("N"),
                ChannelId       = GetInternalChannelId(item.ServiceName, item.ExternalChannelId).ToString("N"),
                Overview        = item.Overview,
                Genres          = item.Genres,
                ExternalId      = item.ExternalId,
                Name            = item.Name,
                ServiceName     = item.ServiceName,
                StartDate       = item.StartDate,
                OfficialRating  = item.OfficialRating,
                IsHD            = item.IsHD,
                OriginalAirDate = item.PremiereDate,
                Audio           = item.Audio,
                CommunityRating = GetClientCommunityRating(item.CommunityRating),
                IsRepeat        = item.IsRepeat,
                EpisodeTitle    = item.EpisodeTitle,
                IsMovie         = item.IsMovie,
                IsSeries        = item.IsSeries,
                IsSports        = item.IsSports,
                IsLive          = item.IsLive,
                IsNews          = item.IsNews,
                IsKids          = item.IsKids,
                IsPremiere      = item.IsPremiere,
                Type            = "Program"
            };

            if (item.EndDate.HasValue)
            {
                dto.EndDate = item.EndDate.Value;

                dto.RunTimeTicks = (item.EndDate.Value - item.StartDate).Ticks;
            }

            if (channel != null)
            {
                dto.ChannelName = channel.Name;

                if (!string.IsNullOrEmpty(channel.PrimaryImagePath))
                {
                    dto.ChannelPrimaryImageTag = GetImageTag(channel);
                }
            }

            var imageTag = GetImageTag(item);

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

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

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

            return(dto);
        }