mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Fix OMDb converter
This commit is contained in:
parent
d1da1aa407
commit
a3a31952f4
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
@ -21,6 +22,9 @@ namespace MediaBrowser.Common.Json.Converters
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var converter = TypeDescriptor.GetConverter(typeToConvert);
|
||||||
|
return (T?)converter.ConvertFromString(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return JsonSerializer.Deserialize<T>(ref reader, options);
|
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)
|
internal async Task<RootObject> GetRootObject(string imdbId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var path = await EnsureItemInfo(imdbId, cancellationToken).ConfigureAwait(false);
|
var path = await EnsureItemInfo(imdbId, cancellationToken).ConfigureAwait(false);
|
||||||
|
await using var stream = File.OpenRead(path);
|
||||||
string resultString;
|
return await JsonSerializer.DeserializeAsync<RootObject>(stream, _jsonOptions, cancellationToken);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<SeasonRootObject> GetSeasonRootObject(string imdbId, int seasonId, CancellationToken cancellationToken)
|
internal async Task<SeasonRootObject> GetSeasonRootObject(string imdbId, int seasonId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var path = await EnsureSeasonInfo(imdbId, seasonId, cancellationToken).ConfigureAwait(false);
|
var path = await EnsureSeasonInfo(imdbId, seasonId, cancellationToken).ConfigureAwait(false);
|
||||||
|
await using var stream = File.OpenRead(path);
|
||||||
string resultString;
|
return await JsonSerializer.DeserializeAsync<SeasonRootObject>(stream, _jsonOptions, cancellationToken);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds)
|
internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user