Пример #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);
        }
Пример #3
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,
                ExternalChannelId     = info.ChannelId,
                ExternalSeriesTimerId = info.SeriesTimerId,
                ServiceName           = service.Name,
                ExternalProgramId     = info.ProgramId,
                Priority              = info.Priority,
                RunTimeTicks          = (info.EndDate - info.StartDate).Ticks
            };

            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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        public RecordingInfoDto GetRecordingInfoDto(ILiveTvRecording recording, LiveTvChannel channel, ILiveTvService service, User user = null)
        {
            var info = recording.RecordingInfo;

            var dto = new RecordingInfoDto
            {
                Id              = GetInternalRecordingId(service.Name, info.Id).ToString("N"),
                SeriesTimerId   = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"),
                Type            = recording.GetClientTypeName(),
                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,
                StatusName      = GetStatusName(info.Status),
                Path            = info.Path,
                Genres          = info.Genres,
                IsRepeat        = info.IsRepeat,
                EpisodeTitle    = info.EpisodeTitle,
                ChannelType     = info.ChannelType,
                MediaType       = info.ChannelType == ChannelType.Radio ? MediaType.Audio : MediaType.Video,
                CommunityRating = GetClientCommunityRating(info.CommunityRating),
                OfficialRating  = info.OfficialRating,
                Audio           = info.Audio,
                IsHD            = info.IsHD,
                ServiceName     = service.Name,
                IsMovie         = info.IsMovie,
                IsSeries        = info.IsSeries,
                IsSports        = info.IsSports,
                IsLive          = info.IsLive,
                IsNews          = info.IsNews,
                IsKids          = info.IsKids,
                IsPremiere      = info.IsPremiere,
                RunTimeTicks    = (info.EndDate - info.StartDate).Ticks,
                OriginalAirDate = info.OriginalAirDate,

                MediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery
                {
                    ItemId = recording.Id
                }).ToList()
            };

            if (info.Status == RecordingStatus.InProgress)
            {
                var now   = DateTime.UtcNow.Ticks;
                var start = info.StartDate.Ticks;
                var end   = info.EndDate.Ticks;

                var pct = now - start;
                pct /= end;
                pct *= 100;
                dto.CompletionPercentage = pct;
            }

            var imageTag = GetImageTag(recording);

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

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

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

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

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

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

            return(dto);
        }
Пример #6
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);
        }