/// <summary> /// Initiate the nextPvr session /// </summary> private async Task InitiateSession(CancellationToken cancellationToken) { _logger.Info("[NextPvr] Start InitiateSession"); var baseUrl = Plugin.Instance.Configuration.WebServiceUrl; var options = new HttpRequestOptions { CancellationToken = cancellationToken, Url = string.Format("{0}/public/Util/NPVR/Client/Instantiate", baseUrl) }; using (var stream = await _httpClient.Get(options).ConfigureAwait(false)) { var clientKeys = new InstantiateResponse().GetClientKeys(stream, _jsonSerializer, _logger); var sid = clientKeys.sid; var salt = clientKeys.salt; _logger.Info(string.Format("[NextPvr] Sid: {0}", sid)); var loggedIn = await Login(sid, salt, cancellationToken).ConfigureAwait(false); if (loggedIn) { _logger.Info("[NextPvr] Session initiated."); Sid = sid; } } }
/// <summary> /// Initiate the nextPvr session /// </summary> private async Task InitiateSession(CancellationToken cancellationToken) { _logger.LogInformation("[NextPVR] Start InitiateSession"); var baseUrl = Plugin.Instance.Configuration.WebServiceUrl; var httpClient = _httpClientFactory.CreateClient(NamedClient.Default); await using var stream = await httpClient.GetStreamAsync(string.Format("{0}/service?method=session.initiate&ver=1.0&device=jellyfin", baseUrl), cancellationToken).ConfigureAwait(false); var clientKeys = new InstantiateResponse().GetClientKeys(stream, _jsonSerializer, _logger); var sid = clientKeys.sid; var salt = clientKeys.salt; _logger.LogInformation(string.Format("[NextPVR] Sid: {0}", sid)); var loggedIn = await Login(sid, salt, cancellationToken).ConfigureAwait(false); if (loggedIn) { _logger.LogInformation("[NextPVR] Session initiated."); Sid = sid; LastUpdatedSidDateTime = DateTimeOffset.UtcNow; bool flag = await GetDefaultSettingsAsync(cancellationToken); Plugin.Instance.Configuration.GetEpisodeImage = "true" == await GetBackendSettingAsync(cancellationToken, "/Settings/General/ArtworkFromSchedulesDirect"); } else { _logger.LogError("[NextPVR] PIN not accepted."); throw new UnauthorizedAccessException("NextPVR PIN not accepted"); } }