|
|
|
@ -6,9 +6,11 @@ using System.Globalization;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using MediaBrowser.Common;
|
|
|
|
|
using MediaBrowser.Common.Json;
|
|
|
|
|
using MediaBrowser.Common.Net;
|
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
@ -19,14 +21,12 @@ using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
|
|
|
|
using MediaBrowser.Model.Providers;
|
|
|
|
|
using MediaBrowser.Model.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.Plugins.Omdb
|
|
|
|
|
{
|
|
|
|
|
public class OmdbItemProvider : IRemoteMetadataProvider<Series, SeriesInfo>,
|
|
|
|
|
IRemoteMetadataProvider<Movie, MovieInfo>, IRemoteMetadataProvider<Trailer, TrailerInfo>, IHasOrder
|
|
|
|
|
{
|
|
|
|
|
private readonly IJsonSerializer _jsonSerializer;
|
|
|
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
|
private readonly IFileSystem _fileSystem;
|
|
|
|
@ -34,14 +34,12 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|
|
|
|
private readonly IApplicationHost _appHost;
|
|
|
|
|
|
|
|
|
|
public OmdbItemProvider(
|
|
|
|
|
IJsonSerializer jsonSerializer,
|
|
|
|
|
IApplicationHost appHost,
|
|
|
|
|
IHttpClientFactory httpClientFactory,
|
|
|
|
|
ILibraryManager libraryManager,
|
|
|
|
|
IFileSystem fileSystem,
|
|
|
|
|
IServerConfigurationManager configurationManager)
|
|
|
|
|
{
|
|
|
|
|
_jsonSerializer = jsonSerializer;
|
|
|
|
|
_httpClientFactory = httpClientFactory;
|
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
|
_fileSystem = fileSystem;
|
|
|
|
@ -138,7 +136,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
resultList.AddRange(searchResultList.Search);
|
|
|
|
@ -146,7 +144,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|
|
|
|
}
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
resultList.Add(result);
|
|
|
|
@ -221,7 +219,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|
|
|
|
result.Item.SetProviderId(MetadataProvider.Imdb, imdbId);
|
|
|
|
|
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;
|
|
|
|
@ -253,7 +251,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
|
|
|
|
result.Item.SetProviderId(MetadataProvider.Imdb, imdbId);
|
|
|
|
|
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;
|
|
|
|
|