public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service) { var dto = new TimerInfoDto { Id = GetInternalTimerId(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, 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 }; 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; }
public override void WireMessages() { Messenger.Default.Register<NotificationMessage>(this, m => { if (m.Notification.Equals(Constants.Messages.ScheduledRecordingChangedMsg)) { SelectedRecording = (TimerInfoDto) m.Sender; //ServerIdItem = SelectedRecording; } }); }
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 (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 }; 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; }
public async Task<TimerInfo> GetTimerInfo(TimerInfoDto dto, bool isNew, LiveTvManager liveTv, CancellationToken cancellationToken) { var info = new TimerInfo { Overview = dto.Overview, EndDate = dto.EndDate, Name = dto.Name, StartDate = dto.StartDate, Status = dto.Status, PrePaddingSeconds = dto.PrePaddingSeconds, PostPaddingSeconds = dto.PostPaddingSeconds, IsPostPaddingRequired = dto.IsPostPaddingRequired, IsPrePaddingRequired = dto.IsPrePaddingRequired, Priority = dto.Priority, SeriesTimerId = dto.ExternalSeriesTimerId, ProgramId = dto.ExternalProgramId, ChannelId = dto.ExternalChannelId, Id = dto.ExternalId }; // Convert internal server id's to external tv provider id's if (!isNew && !string.IsNullOrEmpty(dto.Id) && string.IsNullOrEmpty(info.Id)) { var timer = await liveTv.GetSeriesTimer(dto.Id, cancellationToken).ConfigureAwait(false); info.Id = timer.ExternalId; } if (!string.IsNullOrEmpty(dto.ChannelId) && string.IsNullOrEmpty(info.ChannelId)) { var channel = liveTv.GetInternalChannel(dto.ChannelId); if (channel != null) { info.ChannelId = channel.ExternalId; } } if (!string.IsNullOrEmpty(dto.ProgramId) && string.IsNullOrEmpty(info.ProgramId)) { var program = liveTv.GetInternalProgram(dto.ProgramId); if (program != null) { info.ProgramId = program.ExternalId; } } if (!string.IsNullOrEmpty(dto.SeriesTimerId) && string.IsNullOrEmpty(info.SeriesTimerId)) { var timer = await liveTv.GetSeriesTimer(dto.SeriesTimerId, cancellationToken).ConfigureAwait(false); if (timer != null) { info.SeriesTimerId = timer.ExternalId; } } return info; }
public async Task UpdateTimer(TimerInfoDto timer, CancellationToken cancellationToken) { var info = await _tvDtoService.GetTimerInfo(timer, false, this, cancellationToken).ConfigureAwait(false); var service = string.IsNullOrEmpty(timer.ServiceName) ? ActiveService : GetServices(timer.ServiceName, null).First(); await service.UpdateTimerAsync(info, cancellationToken).ConfigureAwait(false); }
public async Task CreateTimer(TimerInfoDto timer, CancellationToken cancellationToken) { var service = string.IsNullOrEmpty(timer.ServiceName) ? ActiveService : GetServices(timer.ServiceName, null).First(); var info = await _tvDtoService.GetTimerInfo(timer, true, this, cancellationToken).ConfigureAwait(false); // Set priority from default values var defaultValues = await service.GetNewTimerDefaultsAsync(cancellationToken).ConfigureAwait(false); info.Priority = defaultValues.Priority; await service.CreateTimerAsync(info, cancellationToken).ConfigureAwait(false); }
public async Task UpdateTimer(TimerInfoDto timer, CancellationToken cancellationToken) { var info = await _tvDtoService.GetTimerInfo(timer, false, this, cancellationToken).ConfigureAwait(false); var service = GetService(timer.ServiceName); await service.UpdateTimerAsync(info, cancellationToken).ConfigureAwait(false); _lastRecordingRefreshTime = DateTime.MinValue; }
public async Task CreateTimer(TimerInfoDto timer, CancellationToken cancellationToken) { var service = GetService(timer.ServiceName); var info = await _tvDtoService.GetTimerInfo(timer, true, this, cancellationToken).ConfigureAwait(false); // Set priority from default values var defaultValues = await service.GetNewTimerDefaultsAsync(cancellationToken).ConfigureAwait(false); info.Priority = defaultValues.Priority; await service.CreateTimerAsync(info, cancellationToken).ConfigureAwait(false); _lastRecordingRefreshTime = DateTime.MinValue; }
public async Task CreateTimer(TimerInfoDto timer, CancellationToken cancellationToken) { var service = GetService(timer.ServiceName); var info = await _tvDtoService.GetTimerInfo(timer, true, this, cancellationToken).ConfigureAwait(false); // Set priority from default values var defaultValues = await service.GetNewTimerDefaultsAsync(cancellationToken).ConfigureAwait(false); info.Priority = defaultValues.Priority; string newTimerId = null; var supportsNewTimerIds = service as ISupportsNewTimerIds; if (supportsNewTimerIds != null) { newTimerId = await supportsNewTimerIds.CreateTimer(info, cancellationToken).ConfigureAwait(false); newTimerId = _tvDtoService.GetInternalTimerId(timer.ServiceName, newTimerId).ToString("N"); } else { await service.CreateTimerAsync(info, cancellationToken).ConfigureAwait(false); } _lastRecordingRefreshTime = DateTime.MinValue; _logger.Info("New recording scheduled"); EventHelper.QueueEventIfNotNull(TimerCreated, this, new GenericEventArgs<TimerEventInfo> { Argument = new TimerEventInfo { ProgramId = _tvDtoService.GetInternalProgramId(timer.ServiceName, info.ProgramId).ToString("N"), Id = newTimerId } }, _logger); }
public static async Task<bool> CancelRecording(TimerInfoDto item, INavigationService navigationService, IApiClient apiClient, ILog log, bool goBack = false) { return await CancelRecording(item.Id, navigationService, apiClient, log, goBack); }