From 7e22ce5f5e145f29c2eafb7596163822797144d5 Mon Sep 17 00:00:00 2001 From: softworkz Date: Sat, 4 Jun 2016 04:56:04 +0200 Subject: [PATCH] OmdbProvider instantiation --- .../Omdb/OmdbImageProvider.cs | 19 +++++++++++++++---- MediaBrowser.Providers/Omdb/OmdbProvider.cs | 4 ---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs b/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs index e795d638d8..5631189403 100644 --- a/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbImageProvider.cs @@ -1,4 +1,6 @@ -using MediaBrowser.Common.Net; +using CommonIO; +using MediaBrowser.Common.Net; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; @@ -6,6 +8,7 @@ using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Providers; +using MediaBrowser.Model.Serialization; using System.Collections.Generic; using System.IO; using System.Text; @@ -17,10 +20,16 @@ namespace MediaBrowser.Providers.Omdb public class OmdbImageProvider : IRemoteImageProvider, IHasOrder { private readonly IHttpClient _httpClient; + private readonly IJsonSerializer _jsonSerializer; + private readonly IFileSystem _fileSystem; + private readonly IServerConfigurationManager _configurationManager; - public OmdbImageProvider(IHttpClient httpClient) + public OmdbImageProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, IFileSystem fileSystem, IServerConfigurationManager configurationManager) { + _jsonSerializer = jsonSerializer; _httpClient = httpClient; + _fileSystem = fileSystem; + _configurationManager = configurationManager; } public IEnumerable GetSupportedImages(IHasImages item) @@ -37,9 +46,11 @@ namespace MediaBrowser.Providers.Omdb var list = new List(); - if (!string.IsNullOrWhiteSpace(imdbId) && OmdbProvider.Current != null) + var provider = new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager); + + if (!string.IsNullOrWhiteSpace(imdbId)) { - OmdbProvider.RootObject rootObject = await OmdbProvider.Current.GetRootObject(imdbId, cancellationToken); + OmdbProvider.RootObject rootObject = await provider.GetRootObject(imdbId, cancellationToken).ConfigureAwait(false); if (!string.IsNullOrEmpty(rootObject.Poster)) { diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs index 9873447bec..4056073f2c 100644 --- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs @@ -25,16 +25,12 @@ namespace MediaBrowser.Providers.Omdb private readonly IHttpClient _httpClient; private readonly CultureInfo _usCulture = new CultureInfo("en-US"); - public static OmdbProvider Current; - public OmdbProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, IFileSystem fileSystem, IServerConfigurationManager configurationManager) { _jsonSerializer = jsonSerializer; _httpClient = httpClient; _fileSystem = fileSystem; _configurationManager = configurationManager; - - Current = this; } public async Task Fetch(BaseItem item, string imdbId, string language, string country, CancellationToken cancellationToken)