Пример #1
0
        public VideoMessage(RecordingInfoDto item, bool isResume, long? resumeTicks = null)
        {
            RecordingItem = item;
            IsResume = isResume;
            PlayerSourceType = PlayerSourceType.Recording;

            if (RecordingItem != null && resumeTicks.HasValue)
            {
                if (RecordingItem.UserData == null)
                {
                    RecordingItem.UserData = new UserItemDataDto();
                }

                RecordingItem.UserData.PlaybackPositionTicks = resumeTicks.Value;
            }
        }
Пример #2
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,

                MediaSources = recording.GetMediaSources(true).ToList()
            };

            dto.MediaStreams = dto.MediaSources.SelectMany(i => i.MediaStreams).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 != null)
            {
                dto.ImageTags[ImageType.Primary] = imageTag;
                _dtoService.AttachPrimaryImageAspectRatio(dto, recording);
            }

            if (user != null)
            {
                dto.UserData = _userDataManager.GetUserDataDto(recording, user);

                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;
        }
Пример #3
0
        public RecordingInfoDto GetRecordingInfoDto(LiveTvRecording 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,
                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,
                Url = info.Url,
                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
            };

            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()));
            }

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

            if (channel != null)
            {
                dto.ChannelName = channel.ChannelInfo.Name;
            }
            
            return dto;
        }
Пример #4
0
        public RecordingInfoDto GetRecordingInfoDto(RecordingInfo info, ILiveTvService service, User user = null)
        {
            var dto = new RecordingInfoDto
            {
                Id = GetInternalRecordingId(service.Name, info.Id).ToString("N"),
                ChannelName = info.ChannelName,
                Overview = info.Overview,
                EndDate = info.EndDate,
                Name = info.Name,
                StartDate = info.StartDate,
                ExternalId = info.Id,
                ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"),
                Status = 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 = info.CommunityRating,
                OfficialRating = info.OfficialRating,
                Audio = info.Audio,
                IsHD = info.IsHD,
                ServiceName = service.Name,
                Url = info.Url
            };

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

            var duration = info.EndDate - info.StartDate;
            dto.DurationMs = Convert.ToInt32(duration.TotalMilliseconds);

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

            return dto;
        }