Replace ReadAsStreamAsync by ReadFromJsonAsync

This commit is contained in:
Pithaya 2023-10-20 21:25:19 +02:00
parent a0092e5e8b
commit 822feebad1
2 changed files with 5 additions and 11 deletions

View File

@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Net.Http.Json;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Extensions.Json;
@ -84,9 +84,7 @@ namespace Jellyfin.Plugin.Bookshelf.Providers.GoogleBooks
using var response = await httpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
return await JsonSerializer.DeserializeAsync<BookResult>(stream, JsonDefaults.Options, cancellationToken).ConfigureAwait(false);
return await response.Content.ReadFromJsonAsync<BookResult>(JsonDefaults.Options, cancellationToken).ConfigureAwait(false);
}
private List<string> ProcessBookImage(BookResult bookResult)

View File

@ -4,8 +4,8 @@ using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
@ -177,9 +177,7 @@ namespace Jellyfin.Plugin.Bookshelf.Providers.GoogleBooks
using var response = await httpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
return await JsonSerializer.DeserializeAsync<SearchResult>(stream, JsonDefaults.Options, cancellationToken).ConfigureAwait(false);
return await response.Content.ReadFromJsonAsync<SearchResult>(JsonDefaults.Options, cancellationToken).ConfigureAwait(false);
}
private async Task<string?> FetchBookId(BookInfo item, CancellationToken cancellationToken)
@ -252,9 +250,7 @@ namespace Jellyfin.Plugin.Bookshelf.Providers.GoogleBooks
using var response = await httpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
return await JsonSerializer.DeserializeAsync<BookResult>(stream, JsonDefaults.Options, cancellationToken).ConfigureAwait(false);
return await response.Content.ReadFromJsonAsync<BookResult>(JsonDefaults.Options, cancellationToken).ConfigureAwait(false);
}
private Book? ProcessBookData(BookResult bookResult, CancellationToken cancellationToken)