Fix OMDb converter
This commit is contained in:
parent
d1da1aa407
commit
a3a31952f4
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
|
@ -21,6 +22,9 @@ namespace MediaBrowser.Common.Json.Converters
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var converter = TypeDescriptor.GetConverter(typeToConvert);
|
||||
return (T?)converter.ConvertFromString(str);
|
||||
}
|
||||
|
||||
return JsonSerializer.Deserialize<T>(ref reader, options);
|
||||
|
|
|
@ -214,39 +214,15 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|||
internal async Task<RootObject> GetRootObject(string imdbId, CancellationToken cancellationToken)
|
||||
{
|
||||
var path = await EnsureItemInfo(imdbId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
string resultString;
|
||||
|
||||
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
using (var reader = new StreamReader(stream, new UTF8Encoding(false)))
|
||||
{
|
||||
resultString = reader.ReadToEnd();
|
||||
resultString = resultString.Replace("\"N/A\"", "\"\"");
|
||||
}
|
||||
}
|
||||
|
||||
var result = JsonSerializer.Deserialize<RootObject>(resultString, _jsonOptions);
|
||||
return result;
|
||||
await using var stream = File.OpenRead(path);
|
||||
return await JsonSerializer.DeserializeAsync<RootObject>(stream, _jsonOptions, cancellationToken);
|
||||
}
|
||||
|
||||
internal async Task<SeasonRootObject> GetSeasonRootObject(string imdbId, int seasonId, CancellationToken cancellationToken)
|
||||
{
|
||||
var path = await EnsureSeasonInfo(imdbId, seasonId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
string resultString;
|
||||
|
||||
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
using (var reader = new StreamReader(stream, new UTF8Encoding(false)))
|
||||
{
|
||||
resultString = reader.ReadToEnd();
|
||||
resultString = resultString.Replace("\"N/A\"", "\"\"");
|
||||
}
|
||||
}
|
||||
|
||||
var result = JsonSerializer.Deserialize<SeasonRootObject>(resultString, _jsonOptions);
|
||||
return result;
|
||||
await using var stream = File.OpenRead(path);
|
||||
return await JsonSerializer.DeserializeAsync<SeasonRootObject>(stream, _jsonOptions, cancellationToken);
|
||||
}
|
||||
|
||||
internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds)
|
||||
|
|
Loading…
Reference in New Issue
Block a user