public VideoMessage(ProgramInfoDto item, bool isResume, long? resumeTicks = null)
        {
            ProgrammeItem = item;
            IsResume = isResume;
            PlayerSourceType = PlayerSourceType.Programme;

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

                ProgrammeItem.UserData.PlaybackPositionTicks = resumeTicks.Value;
            }
        }
        public static async Task<string> RecordProgramme(ProgramInfoDto item, IApiClient apiClient, INavigationService navigationService, ILog log)
        {
            try
            {
                var timer = await apiClient.GetDefaultLiveTvTimerInfo(item.Id);

                if (timer != null)
                {
                    await apiClient.CreateLiveTvTimerAsync(timer);

                    return timer.Id;
                }
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException(ex, "RecordProgrammeCommand", navigationService, log);
            }

            return null;
        }
        public static async Task<string> CreateSeriesLink(ProgramInfoDto item, IApiClient apiClient, INavigationService navigationService, ILog log)
        {
            try
            {
                var timer = await apiClient.GetDefaultLiveTvTimerInfo(item.Id);

                if (timer != null)
                {
                    await apiClient.CreateLiveTvSeriesTimerAsync(timer);

                    Messenger.Default.Send(new NotificationMessage(Constants.Messages.NewSeriesRecordingAddedMsg));

                    return timer.Id;
                }
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException(ex, "RecordProgrammeCommand", navigationService, log);
            }

            return null;
        }
        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",
                MediaType = item.MediaType
            };

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

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

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

            return dto;
        }
        public ProgramInfoDto GetProgramInfoDto(LiveTvProgram item, User user = null)
        {
            var program = item.ProgramInfo;
            
            var dto = new ProgramInfoDto
            {
                Id = GetInternalProgramId(item.ServiceName, program.Id).ToString("N"),
                ChannelId = GetInternalChannelId(item.ServiceName, program.ChannelId).ToString("N"),
                Overview = program.Overview,
                EndDate = program.EndDate,
                Genres = program.Genres,
                ExternalId = program.Id,
                Name = program.Name,
                ServiceName = item.ServiceName,
                StartDate = program.StartDate,
                OfficialRating = program.OfficialRating,
                IsHD = program.IsHD,
                OriginalAirDate = program.OriginalAirDate,
                Audio = program.Audio,
                CommunityRating = GetClientCommunityRating(program.CommunityRating),
                AspectRatio = program.AspectRatio,
                IsRepeat = program.IsRepeat,
                EpisodeTitle = program.EpisodeTitle,
                ChannelName = program.ChannelName,
                IsMovie = program.IsMovie,
                IsSeries = program.IsSeries,
                IsSports = program.IsSports,
                IsLive = program.IsLive,
                IsNews = program.IsNews,
                IsKids = program.IsKids,
                IsPremiere = program.IsPremiere,
                RunTimeTicks = (program.EndDate - program.StartDate).Ticks
            };

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

            return dto;
        }
        public ProgramInfoDto GetProgramInfoDto(ProgramInfo program, Channel channel, User user = null)
        {
            var dto = new ProgramInfoDto
            {
                Id = GetInternalProgramId(channel.ServiceName, program.Id).ToString("N"),
                ChannelId = channel.Id.ToString("N"),
                Overview = program.Overview,
                EndDate = program.EndDate,
                Genres = program.Genres,
                ExternalId = program.Id,
                Name = program.Name,
                ServiceName = channel.ServiceName,
                StartDate = program.StartDate,
                OfficialRating = program.OfficialRating,
                IsHD = program.IsHD,
                OriginalAirDate = program.OriginalAirDate,
                Audio = program.Audio,
                CommunityRating = program.CommunityRating,
                AspectRatio = program.AspectRatio,
                IsRepeat = program.IsRepeat,
                EpisodeTitle = program.EpisodeTitle,
                ChannelName = program.ChannelName,
                IsMovie = program.IsMovie,
                IsSeries = program.IsSeries,
                IsSports = program.IsSports
            };

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

            return dto;
        }