Exemple #1
0
        /// <summary>
        /// Cancel the Series Timer
        /// </summary>
        /// <param name="timerId">The Timer Id</param>
        /// <param name="cancellationToken">The CancellationToken</param>
        /// <returns></returns>
        public async Task CancelSeriesTimerAsync(string timerId, CancellationToken cancellationToken)
        {
            _logger.Info(string.Format("[NextPvr] Start Cancel SeriesRecording Async for recordingId: {0}", timerId));
            await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);

            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            var options = new HttpRequestOptions
            {
                CancellationToken = cancellationToken,
                Url = string.Format("{0}/public/ScheduleService/CancelRecurr/{1}?sid={2}", baseUrl, timerId, Sid)
            };

            using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
            {
                bool?error = new CancelDeleteRecordingResponse().RecordingError(stream, _jsonSerializer, _logger);

                if (error == null || error == true)
                {
                    _logger.Error(string.Format("[NextPvr] Failed to cancel the recording with recordingId: {0}", timerId));
                    throw new ApplicationException(string.Format("Failed to cancel the recording with recordingId: {0}", timerId));
                }
                _logger.Info("[NextPvr] Cancelled Recording for recordingId: {0}", timerId);
            }
        }
Exemple #2
0
        /// <summary>
        /// Delete the Recording async from the disk
        /// </summary>
        /// <param name="recordingId">The recordingId</param>
        /// <param name="cancellationToken">The cancellationToken</param>
        /// <returns></returns>
        public async Task DeleteRecordingAsync(string recordingId, CancellationToken cancellationToken)
        {
            _logger.Info(string.Format("[NextPvr] Start Delete Recording Async for recordingId: {0}", recordingId));
            await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);

            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            var options = new HttpRequestOptions
            {
                CancellationToken = cancellationToken,
                Url = string.Format("{0}/public/ScheduleService/Delete/{1}?sid={2}", baseUrl, recordingId, Sid)
            };

            using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
            {
                LastRecordingChange = DateTimeOffset.UtcNow;

                bool?error = new CancelDeleteRecordingResponse().RecordingError(stream, _jsonSerializer, _logger);

                if (error == null || error == true)
                {
                    _logger.Error(string.Format("[NextPvr] Failed to delete the recording for recordingId: {0}", recordingId));
                    throw new Exception(string.Format("Failed to delete the recording for recordingId: {0}", recordingId));
                }
                _logger.Info("[NextPvr] Deleted Recording with recordingId: {0}", recordingId);
            }
        }
Exemple #3
0
        /// <summary>
        /// Delete the Recording async from the disk
        /// </summary>
        /// <param name="recordingId">The recordingId</param>
        /// <param name="cancellationToken">The cancellationToken</param>
        /// <returns></returns>
        public async Task DeleteRecordingAsync(string recordingId, CancellationToken cancellationToken)
        {
            //_logger.Info(string.Format("[VDR] Start Delete Recording Async for recordingId: {0}", recordingId));
            _logger.Info("[VDR] Start Delete Recording NOT IMPLIMENTED");
            throw new NotImplementedException();

            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            var options = new HttpRequestOptions
            {
                CancellationToken = cancellationToken,
                Url = string.Format("{0}/public/ScheduleService/Delete/{1}?sid={2}", baseUrl, recordingId, Sid)
            };

            using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
            {
                bool?error = new CancelDeleteRecordingResponse().RecordingError(stream, _jsonSerializer, _logger);

                if (error == null || error == true)
                {
                    _logger.Error(string.Format("[VDR] Failed to delete the recording for recordingId: {0}", recordingId));
                    throw new ApplicationException(string.Format("Failed to delete the recording for recordingId: {0}", recordingId));
                }
                _logger.Info("[VDR] Deleted Recording with recordingId: {0}", recordingId);
            }
        }
Exemple #4
0
        /// <summary>
        /// Create a new recording
        /// </summary>
        /// <param name="info">The TimerInfo</param>
        /// <param name="cancellationToken">The cancellationToken</param>
        /// <returns></returns>
        public async Task CreateTimerAsync(TimerInfo info, CancellationToken cancellationToken)
        {
            _logger.LogInformation(string.Format("[NextPVR] Start CreateTimer Async for ChannelId: {0} & Name: {1}", info.ChannelId, info.Name));
            await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);

            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            UtilsHelper.DebugInformation(_logger, string.Format("[NextPVR] TimerSettings CreateTimer: {0} for ChannelId: {1} & Name: {2}", info.ProgramId, info.ChannelId, info.Name));
            await using var stream = await _httpClientFactory.CreateClient(NamedClient.Default)
                                     .GetStreamAsync(string.Format("{0}/service?method=recording.save&sid={1}&event_id={2}&pre_padding={3}&post_padding={4}", baseUrl, Sid,
                                                                   int.Parse(info.ProgramId, _usCulture),
                                                                   info.PrePaddingSeconds / 60,
                                                                   info.PostPaddingSeconds / 60,
                                                                   info.Id), cancellationToken);

            bool?error = new CancelDeleteRecordingResponse().RecordingError(stream, _jsonSerializer, _logger);

            if (error == null || error == true)
            {
                _logger.LogError(string.Format("[NextPVR] Failed to create the timer with programId: {0}", info.ProgramId));
                throw new Exception(string.Format("Failed to create the timer with programId: {0}", info.ProgramId));
            }

            _logger.LogError("[NextPVR] CreateTimer async for programId: {0}", info.ProgramId);
        }
Exemple #5
0
        /// <summary>
        /// Update the series Timer
        /// </summary>
        /// <param name="info">The series program info</param>
        /// <param name="cancellationToken">The CancellationToken</param>
        /// <returns></returns>
        public async Task CreateUpdateSeriesTimerAsync(SeriesTimerInfo info, string url, CancellationToken cancellationToken)
        {
            UtilsHelper.DebugInformation(_logger, string.Format("[NextPVR] TimerSettings CreateSeriesTimerAsync: {0} for ChannelId: {1} & Name: {2}", info.ProgramId, info.ChannelId, info.Name));
            await using var stream = await _httpClientFactory.CreateClient(NamedClient.Default)
                                     .GetStreamAsync(url, cancellationToken);

            bool?error = new CancelDeleteRecordingResponse().RecordingError(stream, _jsonSerializer, _logger);

            if (error == null || error == true)
            {
                _logger.LogError("[NextPVR] Failed to create or update the timer with Recurring ID: {0}", info.Id);
                throw new Exception(string.Format("Failed to create or update the timer with Recurring ID: {0}", info.Id));
            }

            _logger.LogInformation("[NextPVR] CreateUpdateSeriesTimer async for Program ID: {0} Recurring ID {1}", info.ProgramId, info.Id);
            //Thread.Sleep(1000);
        }
Exemple #6
0
        /// <summary>
        /// Cancel the Series Timer
        /// </summary>
        /// <param name="timerId">The Timer Id</param>
        /// <param name="cancellationToken">The CancellationToken</param>
        /// <returns></returns>
        public async Task CancelSeriesTimerAsync(string timerId, CancellationToken cancellationToken)
        {
            _logger.LogInformation(string.Format("[NextPVR] Start Cancel SeriesRecording Async for recordingId: {0}", timerId));
            await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);

            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            await using var stream = await _httpClientFactory.CreateClient(NamedClient.Default)
                                     .GetStreamAsync(string.Format("{0}/service?method=recording.recurring.delete&recurring_id={1}&sid={2}", baseUrl, timerId, Sid), cancellationToken);

            bool?error = new CancelDeleteRecordingResponse().RecordingError(stream, _jsonSerializer, _logger);

            if (error == null || error == true)
            {
                _logger.LogError("[NextPVR] Failed to cancel the recording with recordingId: {0}", timerId);
                throw new Exception(string.Format("Failed to cancel the recording with recordingId: {0}", timerId));
            }

            _logger.LogInformation("[NextPVR] Cancelled Recording for recordingId: {0}", timerId);
        }