diff options
| author | crobibero <cody@robibe.ro> | 2021-01-03 09:35:22 -0700 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2021-01-03 09:35:22 -0700 |
| commit | a3a31952f4739a98d12de12ebe25d5535cf4a805 (patch) | |
| tree | d61abd5b89047df4e1075b8a10e715033dba79dd /MediaBrowser.Providers/Plugins | |
| parent | d1da1aa4076f6eaa408fbc50d600686b7b219fc6 (diff) | |
Fix OMDb converter
Diffstat (limited to 'MediaBrowser.Providers/Plugins')
| -rw-r--r-- | MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs index 2372e31834..a759f5408c 100644 --- a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs @@ -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) |
