mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-01 11:23:36 +02:00
Remove custom Json serializer from Providers
This commit is contained in:
parent
bfdd4727b5
commit
e09d3ba9ef
|
@ -1,9 +1,12 @@
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Common.Json;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
@ -19,13 +22,11 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
{
|
{
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly IJsonSerializer _json;
|
|
||||||
|
|
||||||
public AudioDbAlbumImageProvider(IServerConfigurationManager config, IHttpClientFactory httpClientFactory, IJsonSerializer json)
|
public AudioDbAlbumImageProvider(IServerConfigurationManager config, IHttpClientFactory httpClientFactory)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_json = json;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -56,7 +57,8 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
|
|
||||||
var path = AudioDbAlbumProvider.GetAlbumInfoPath(_config.ApplicationPaths, id);
|
var path = AudioDbAlbumProvider.GetAlbumInfoPath(_config.ApplicationPaths, id);
|
||||||
|
|
||||||
var obj = _json.DeserializeFromFile<AudioDbAlbumProvider.RootObject>(path);
|
var jsonString = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
|
||||||
|
var obj = JsonSerializer.Deserialize<AudioDbAlbumProvider.RootObject>(jsonString, JsonDefaults.GetOptions());
|
||||||
|
|
||||||
if (obj != null && obj.album != null && obj.album.Count > 0)
|
if (obj != null && obj.album != null && obj.album.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,10 +6,12 @@ using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
|
using MediaBrowser.Common.Json;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
|
@ -27,16 +29,14 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly IJsonSerializer _json;
|
|
||||||
|
|
||||||
public static AudioDbAlbumProvider Current;
|
public static AudioDbAlbumProvider Current;
|
||||||
|
|
||||||
public AudioDbAlbumProvider(IServerConfigurationManager config, IFileSystem fileSystem, IHttpClientFactory httpClientFactory, IJsonSerializer json)
|
public AudioDbAlbumProvider(IServerConfigurationManager config, IFileSystem fileSystem, IHttpClientFactory httpClientFactory)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_json = json;
|
|
||||||
|
|
||||||
Current = this;
|
Current = this;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,8 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
|
|
||||||
var path = GetAlbumInfoPath(_config.ApplicationPaths, id);
|
var path = GetAlbumInfoPath(_config.ApplicationPaths, id);
|
||||||
|
|
||||||
var obj = _json.DeserializeFromFile<RootObject>(path);
|
var jsonString = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
|
||||||
|
var obj = JsonSerializer.Deserialize<RootObject>(jsonString, JsonDefaults.GetOptions());
|
||||||
|
|
||||||
if (obj != null && obj.album != null && obj.album.Count > 0)
|
if (obj != null && obj.album != null && obj.album.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Common.Json;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
@ -19,12 +22,10 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
{
|
{
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly IJsonSerializer _json;
|
|
||||||
|
|
||||||
public AudioDbArtistImageProvider(IServerConfigurationManager config, IJsonSerializer json, IHttpClientFactory httpClientFactory)
|
public AudioDbArtistImageProvider(IServerConfigurationManager config, IHttpClientFactory httpClientFactory)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_json = json;
|
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +59,8 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
|
|
||||||
var path = AudioDbArtistProvider.GetArtistInfoPath(_config.ApplicationPaths, id);
|
var path = AudioDbArtistProvider.GetArtistInfoPath(_config.ApplicationPaths, id);
|
||||||
|
|
||||||
var obj = _json.DeserializeFromFile<AudioDbArtistProvider.RootObject>(path);
|
var jsonString = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
|
||||||
|
var obj = JsonSerializer.Deserialize<AudioDbArtistProvider.RootObject>(jsonString, JsonDefaults.GetOptions());
|
||||||
|
|
||||||
if (obj != null && obj.artists != null && obj.artists.Count > 0)
|
if (obj != null && obj.artists != null && obj.artists.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,10 +5,12 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
|
using MediaBrowser.Common.Json;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
|
@ -29,14 +31,12 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly IJsonSerializer _json;
|
|
||||||
|
|
||||||
public AudioDbArtistProvider(IServerConfigurationManager config, IFileSystem fileSystem, IHttpClientFactory httpClientFactory, IJsonSerializer json)
|
public AudioDbArtistProvider(IServerConfigurationManager config, IFileSystem fileSystem, IHttpClientFactory httpClientFactory)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_json = json;
|
|
||||||
Current = this;
|
Current = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,8 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
|
|
||||||
var path = GetArtistInfoPath(_config.ApplicationPaths, id);
|
var path = GetArtistInfoPath(_config.ApplicationPaths, id);
|
||||||
|
|
||||||
var obj = _json.DeserializeFromFile<RootObject>(path);
|
var jsonString = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
|
||||||
|
var obj = JsonSerializer.Deserialize<RootObject>(jsonString, JsonDefaults.GetOptions());
|
||||||
|
|
||||||
if (obj != null && obj.artists != null && obj.artists.Count > 0)
|
if (obj != null && obj.artists != null && obj.artists.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,13 +12,11 @@ using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Plugins.Omdb
|
namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
{
|
{
|
||||||
public class OmdbEpisodeProvider : IRemoteMetadataProvider<Episode, EpisodeInfo>, IHasOrder
|
public class OmdbEpisodeProvider : IRemoteMetadataProvider<Episode, EpisodeInfo>, IHasOrder
|
||||||
{
|
{
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly OmdbItemProvider _itemProvider;
|
private readonly OmdbItemProvider _itemProvider;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
@ -26,19 +24,17 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
private readonly IApplicationHost _appHost;
|
private readonly IApplicationHost _appHost;
|
||||||
|
|
||||||
public OmdbEpisodeProvider(
|
public OmdbEpisodeProvider(
|
||||||
IJsonSerializer jsonSerializer,
|
|
||||||
IApplicationHost appHost,
|
IApplicationHost appHost,
|
||||||
IHttpClientFactory httpClientFactory,
|
IHttpClientFactory httpClientFactory,
|
||||||
ILibraryManager libraryManager,
|
ILibraryManager libraryManager,
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
IServerConfigurationManager configurationManager)
|
IServerConfigurationManager configurationManager)
|
||||||
{
|
{
|
||||||
_jsonSerializer = jsonSerializer;
|
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_configurationManager = configurationManager;
|
_configurationManager = configurationManager;
|
||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
_itemProvider = new OmdbItemProvider(jsonSerializer, _appHost, httpClientFactory, libraryManager, fileSystem, configurationManager);
|
_itemProvider = new OmdbItemProvider(_appHost, httpClientFactory, libraryManager, fileSystem, configurationManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
// After TheTvDb
|
// After TheTvDb
|
||||||
|
@ -69,7 +65,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
{
|
{
|
||||||
if (info.IndexNumber.HasValue && info.ParentIndexNumber.HasValue)
|
if (info.IndexNumber.HasValue && info.ParentIndexNumber.HasValue)
|
||||||
{
|
{
|
||||||
result.HasMetadata = await new OmdbProvider(_jsonSerializer, _httpClientFactory, _fileSystem, _appHost, _configurationManager)
|
result.HasMetadata = await new OmdbProvider(_httpClientFactory, _fileSystem, _appHost, _configurationManager)
|
||||||
.FetchEpisodeData(result, info.IndexNumber.Value, info.ParentIndexNumber.Value, info.GetProviderId(MetadataProvider.Imdb), seriesImdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
.FetchEpisodeData(result, info.IndexNumber.Value, info.ParentIndexNumber.Value, info.GetProviderId(MetadataProvider.Imdb), seriesImdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common;
|
using MediaBrowser.Common;
|
||||||
|
@ -15,21 +15,18 @@ using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Plugins.Omdb
|
namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
{
|
{
|
||||||
public class OmdbImageProvider : IRemoteImageProvider, IHasOrder
|
public class OmdbImageProvider : IRemoteImageProvider, IHasOrder
|
||||||
{
|
{
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IServerConfigurationManager _configurationManager;
|
private readonly IServerConfigurationManager _configurationManager;
|
||||||
private readonly IApplicationHost _appHost;
|
private readonly IApplicationHost _appHost;
|
||||||
|
|
||||||
public OmdbImageProvider(IJsonSerializer jsonSerializer, IApplicationHost appHost, IHttpClientFactory httpClientFactory, IFileSystem fileSystem, IServerConfigurationManager configurationManager)
|
public OmdbImageProvider(IApplicationHost appHost, IHttpClientFactory httpClientFactory, IFileSystem fileSystem, IServerConfigurationManager configurationManager)
|
||||||
{
|
{
|
||||||
_jsonSerializer = jsonSerializer;
|
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_configurationManager = configurationManager;
|
_configurationManager = configurationManager;
|
||||||
|
@ -56,7 +53,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
|
|
||||||
var list = new List<RemoteImageInfo>();
|
var list = new List<RemoteImageInfo>();
|
||||||
|
|
||||||
var provider = new OmdbProvider(_jsonSerializer, _httpClientFactory, _fileSystem, _appHost, _configurationManager);
|
var provider = new OmdbProvider(_httpClientFactory, _fileSystem, _appHost, _configurationManager);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(imdbId))
|
if (!string.IsNullOrWhiteSpace(imdbId))
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,9 +6,11 @@ using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common;
|
using MediaBrowser.Common;
|
||||||
|
using MediaBrowser.Common.Json;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
@ -19,14 +21,12 @@ using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Plugins.Omdb
|
namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
{
|
{
|
||||||
public class OmdbItemProvider : IRemoteMetadataProvider<Series, SeriesInfo>,
|
public class OmdbItemProvider : IRemoteMetadataProvider<Series, SeriesInfo>,
|
||||||
IRemoteMetadataProvider<Movie, MovieInfo>, IRemoteMetadataProvider<Trailer, TrailerInfo>, IHasOrder
|
IRemoteMetadataProvider<Movie, MovieInfo>, IRemoteMetadataProvider<Trailer, TrailerInfo>, IHasOrder
|
||||||
{
|
{
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
@ -34,14 +34,12 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
private readonly IApplicationHost _appHost;
|
private readonly IApplicationHost _appHost;
|
||||||
|
|
||||||
public OmdbItemProvider(
|
public OmdbItemProvider(
|
||||||
IJsonSerializer jsonSerializer,
|
|
||||||
IApplicationHost appHost,
|
IApplicationHost appHost,
|
||||||
IHttpClientFactory httpClientFactory,
|
IHttpClientFactory httpClientFactory,
|
||||||
ILibraryManager libraryManager,
|
ILibraryManager libraryManager,
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
IServerConfigurationManager configurationManager)
|
IServerConfigurationManager configurationManager)
|
||||||
{
|
{
|
||||||
_jsonSerializer = jsonSerializer;
|
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
@ -138,7 +136,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
|
|
||||||
if (isSearch)
|
if (isSearch)
|
||||||
{
|
{
|
||||||
var searchResultList = await _jsonSerializer.DeserializeFromStreamAsync<SearchResultList>(stream).ConfigureAwait(false);
|
var searchResultList = await JsonSerializer.DeserializeAsync<SearchResultList>(stream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||||
if (searchResultList != null && searchResultList.Search != null)
|
if (searchResultList != null && searchResultList.Search != null)
|
||||||
{
|
{
|
||||||
resultList.AddRange(searchResultList.Search);
|
resultList.AddRange(searchResultList.Search);
|
||||||
|
@ -146,7 +144,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var result = await _jsonSerializer.DeserializeFromStreamAsync<SearchResult>(stream).ConfigureAwait(false);
|
var result = await JsonSerializer.DeserializeAsync<SearchResult>(stream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||||
if (string.Equals(result.Response, "true", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(result.Response, "true", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
resultList.Add(result);
|
resultList.Add(result);
|
||||||
|
@ -221,7 +219,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
result.Item.SetProviderId(MetadataProvider.Imdb, imdbId);
|
result.Item.SetProviderId(MetadataProvider.Imdb, imdbId);
|
||||||
result.HasMetadata = true;
|
result.HasMetadata = true;
|
||||||
|
|
||||||
await new OmdbProvider(_jsonSerializer, _httpClientFactory, _fileSystem, _appHost, _configurationManager).Fetch(result, imdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
await new OmdbProvider(_httpClientFactory, _fileSystem, _appHost, _configurationManager).Fetch(result, imdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -253,7 +251,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
result.Item.SetProviderId(MetadataProvider.Imdb, imdbId);
|
result.Item.SetProviderId(MetadataProvider.Imdb, imdbId);
|
||||||
result.HasMetadata = true;
|
result.HasMetadata = true;
|
||||||
|
|
||||||
await new OmdbProvider(_jsonSerializer, _httpClientFactory, _fileSystem, _appHost, _configurationManager).Fetch(result, imdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
await new OmdbProvider(_httpClientFactory, _fileSystem, _appHost, _configurationManager).Fetch(result, imdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -7,31 +7,30 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common;
|
using MediaBrowser.Common;
|
||||||
|
using MediaBrowser.Common.Json;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Plugins.Omdb
|
namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
{
|
{
|
||||||
public class OmdbProvider
|
public class OmdbProvider
|
||||||
{
|
{
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IServerConfigurationManager _configurationManager;
|
private readonly IServerConfigurationManager _configurationManager;
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
private readonly IApplicationHost _appHost;
|
private readonly IApplicationHost _appHost;
|
||||||
|
|
||||||
public OmdbProvider(IJsonSerializer jsonSerializer, IHttpClientFactory httpClientFactory, IFileSystem fileSystem, IApplicationHost appHost, IServerConfigurationManager configurationManager)
|
public OmdbProvider(IHttpClientFactory httpClientFactory, IFileSystem fileSystem, IApplicationHost appHost, IServerConfigurationManager configurationManager)
|
||||||
{
|
{
|
||||||
_jsonSerializer = jsonSerializer;
|
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_configurationManager = configurationManager;
|
_configurationManager = configurationManager;
|
||||||
|
@ -220,7 +219,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = _jsonSerializer.DeserializeFromString<RootObject>(resultString);
|
var result = JsonSerializer.Deserialize<RootObject>(resultString, JsonDefaults.GetOptions());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +238,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = _jsonSerializer.DeserializeFromString<SeasonRootObject>(resultString);
|
var result = JsonSerializer.Deserialize<SeasonRootObject>(resultString, JsonDefaults.GetOptions());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,9 +298,10 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
|
|
||||||
using var response = await GetOmdbResponse(_httpClientFactory.CreateClient(NamedClient.Default), url, cancellationToken).ConfigureAwait(false);
|
using var response = await GetOmdbResponse(_httpClientFactory.CreateClient(NamedClient.Default), url, cancellationToken).ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
var rootObject = await _jsonSerializer.DeserializeFromStreamAsync<RootObject>(stream).ConfigureAwait(false);
|
var rootObject = await JsonSerializer.DeserializeAsync<RootObject>(stream, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
_jsonSerializer.SerializeToFile(rootObject, path);
|
await using FileStream jsonFileStream = File.Create(path);
|
||||||
|
await JsonSerializer.SerializeAsync(jsonFileStream, rootObject, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -337,9 +337,10 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||||
|
|
||||||
using var response = await GetOmdbResponse(_httpClientFactory.CreateClient(NamedClient.Default), url, cancellationToken).ConfigureAwait(false);
|
using var response = await GetOmdbResponse(_httpClientFactory.CreateClient(NamedClient.Default), url, cancellationToken).ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
var rootObject = await _jsonSerializer.DeserializeFromStreamAsync<SeasonRootObject>(stream).ConfigureAwait(false);
|
var rootObject = await JsonSerializer.DeserializeAsync<SeasonRootObject>(stream, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
_jsonSerializer.SerializeToFile(rootObject, path);
|
await using FileStream jsonFileStream = File.Create(path);
|
||||||
|
await JsonSerializer.SerializeAsync(jsonFileStream, rootObject, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue