Resolved Jellyfin 10.7 plugin API breaking changes
This commit is contained in:
1 parent
d786e04081
commit
b9c0362e68
7 files changed
+67
-151
No files matched your search
@@ -20,7 +20,7 @@ namespace Jellyfin.Plugin.Kinopoisk.ApiModel
|
|||||||
public CountryItem[] Countries { get; set; }
|
public CountryItem[] Countries { get; set; }
|
||||||
public GenreItem[] Genres { get; set; }
|
public GenreItem[] Genres { get; set; }
|
||||||
public string Rating { get; set; }
|
public string Rating { get; set; }
|
||||||
public string RatingVoteCount { get; set; }
|
public int RatingVoteCount { get; set; }
|
||||||
public string PosterUrl { get; set; }
|
public string PosterUrl { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<!-- <PackageReference Include="Jellyfin.Controller" Version="10.6.*" />
|
|
||||||
<PackageReference Include="Jellyfin.Model" Version="10.6.*" /> -->
|
|
||||||
<ProjectReference Include="..\..\..\..\temp-jellyfin-src\MediaBrowser.Common\MediaBrowser.Common.csproj" />
|
|
||||||
<ProjectReference Include="..\..\..\..\temp-jellyfin-src\MediaBrowser.Controller\MediaBrowser.Controller.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Configuration\configPage.html" />
|
<None Remove="Configuration\configPage.html" />
|
||||||
<EmbeddedResource Include="Configuration\configPage.html" />
|
<EmbeddedResource Include="Configuration\configPage.html" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Jellyfin.Controller" Version="10.7.0" />
|
||||||
|
<PackageReference Include="Jellyfin.Model" Version="10.7.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
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 System.Web;
|
using System.Web;
|
||||||
using Jellyfin.Plugin.Kinopoisk.ApiModel;
|
using Jellyfin.Plugin.Kinopoisk.ApiModel;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Json;
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.Kinopoisk
|
namespace Jellyfin.Plugin.Kinopoisk
|
||||||
@@ -14,15 +15,14 @@ namespace Jellyfin.Plugin.Kinopoisk
|
|||||||
public class KinopoiskApiProxy
|
public class KinopoiskApiProxy
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IHttpClient _httpClient;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
|
||||||
private readonly string _apiToken;
|
private readonly string _apiToken;
|
||||||
|
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
|
||||||
|
|
||||||
public KinopoiskApiProxy(ILogger logger, IHttpClient httpClient, IJsonSerializer jsonSerializer)
|
public KinopoiskApiProxy(ILogger logger, IHttpClientFactory httpClientFactory)
|
||||||
{
|
{
|
||||||
this._logger = logger;
|
this._logger = logger;
|
||||||
this._httpClient = httpClient;
|
this._httpClientFactory = httpClientFactory;
|
||||||
this._jsonSerializer = jsonSerializer;
|
|
||||||
this._apiToken = Plugin.Instance.Configuration.ApiToken;
|
this._apiToken = Plugin.Instance.Configuration.ApiToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,21 +37,7 @@ namespace Jellyfin.Plugin.Kinopoisk
|
|||||||
@params["page"] = Convert.ToString(page);
|
@params["page"] = Convert.ToString(page);
|
||||||
uriBuilder.Query = @params.ToString();
|
uriBuilder.Query = @params.ToString();
|
||||||
|
|
||||||
var requestOptions = new HttpRequestOptions
|
return await GetAsync<SearchResult>(uriBuilder.Uri.AbsoluteUri, cancellationToken.Value);
|
||||||
{
|
|
||||||
Url = uriBuilder.Uri.AbsoluteUri,
|
|
||||||
CancellationToken = cancellationToken.Value,
|
|
||||||
BufferContent = true,
|
|
||||||
EnableDefaultUserAgent = true,
|
|
||||||
AcceptHeader = "application/json"
|
|
||||||
};
|
|
||||||
requestOptions.RequestHeaders.Add("X-API-KEY", _apiToken);
|
|
||||||
using(var response = await _httpClient.SendAsync(requestOptions, HttpMethod.Get).ConfigureAwait(false))
|
|
||||||
// todo: status code!
|
|
||||||
using(var jsonStream = response.Content)
|
|
||||||
{
|
|
||||||
return await _jsonSerializer.DeserializeFromStreamAsync<SearchResult>(jsonStream).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<FilmDetails> GetSingleFilm(int filmId, CancellationToken? cancellationToken = null)
|
public async Task<FilmDetails> GetSingleFilm(int filmId, CancellationToken? cancellationToken = null)
|
||||||
@@ -59,23 +45,9 @@ namespace Jellyfin.Plugin.Kinopoisk
|
|||||||
if (!cancellationToken.HasValue)
|
if (!cancellationToken.HasValue)
|
||||||
cancellationToken = CancellationToken.None;
|
cancellationToken = CancellationToken.None;
|
||||||
|
|
||||||
var uri = new Uri($"https://kinopoiskapiunofficial.tech/api/v2.1/films/{filmId}?append_to_response=EXTERNAL_ID&append_to_response=RATING");
|
string uri = $"https://kinopoiskapiunofficial.tech/api/v2.1/films/{filmId}?append_to_response=EXTERNAL_ID&append_to_response=RATING";
|
||||||
|
|
||||||
var requestOptions = new HttpRequestOptions
|
return await GetAsync<FilmDetails>(uri, cancellationToken.Value);
|
||||||
{
|
|
||||||
Url = uri.AbsoluteUri,
|
|
||||||
CancellationToken = cancellationToken.Value,
|
|
||||||
BufferContent = true,
|
|
||||||
EnableDefaultUserAgent = true,
|
|
||||||
AcceptHeader = "application/json"
|
|
||||||
};
|
|
||||||
requestOptions.RequestHeaders.Add("X-API-KEY", _apiToken);
|
|
||||||
using(var response = await _httpClient.SendAsync(requestOptions, HttpMethod.Get).ConfigureAwait(false))
|
|
||||||
// todo: status code!
|
|
||||||
using(var jsonStream = response.Content)
|
|
||||||
{
|
|
||||||
return await _jsonSerializer.DeserializeFromStreamAsync<FilmDetails>(jsonStream).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<FilmDetails> GetSingleFilmImages(int filmId, CancellationToken? cancellationToken = null)
|
public async Task<FilmDetails> GetSingleFilmImages(int filmId, CancellationToken? cancellationToken = null)
|
||||||
@@ -83,23 +55,9 @@ namespace Jellyfin.Plugin.Kinopoisk
|
|||||||
if (!cancellationToken.HasValue)
|
if (!cancellationToken.HasValue)
|
||||||
cancellationToken = CancellationToken.None;
|
cancellationToken = CancellationToken.None;
|
||||||
|
|
||||||
var uri = new Uri($"https://kinopoiskapiunofficial.tech/api/v2.1/films/{filmId}?append_to_response=POSTERS");
|
string uri = $"https://kinopoiskapiunofficial.tech/api/v2.1/films/{filmId}?append_to_response=POSTERS";
|
||||||
|
|
||||||
var requestOptions = new HttpRequestOptions
|
return await GetAsync<FilmDetails>(uri, cancellationToken.Value);
|
||||||
{
|
|
||||||
Url = uri.AbsoluteUri,
|
|
||||||
CancellationToken = cancellationToken.Value,
|
|
||||||
BufferContent = true,
|
|
||||||
EnableDefaultUserAgent = true,
|
|
||||||
AcceptHeader = "application/json"
|
|
||||||
};
|
|
||||||
requestOptions.RequestHeaders.Add("X-API-KEY", _apiToken);
|
|
||||||
using(var response = await _httpClient.SendAsync(requestOptions, HttpMethod.Get).ConfigureAwait(false))
|
|
||||||
// todo: status code!
|
|
||||||
using(var jsonStream = response.Content)
|
|
||||||
{
|
|
||||||
return await _jsonSerializer.DeserializeFromStreamAsync<FilmDetails>(jsonStream).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<StaffItem>> GetStaff(int filmId, CancellationToken? cancellationToken = null)
|
public async Task<IEnumerable<StaffItem>> GetStaff(int filmId, CancellationToken? cancellationToken = null)
|
||||||
@@ -107,23 +65,29 @@ namespace Jellyfin.Plugin.Kinopoisk
|
|||||||
if (!cancellationToken.HasValue)
|
if (!cancellationToken.HasValue)
|
||||||
cancellationToken = CancellationToken.None;
|
cancellationToken = CancellationToken.None;
|
||||||
|
|
||||||
var uri = new Uri($"https://kinopoiskapiunofficial.tech/api/v1/staff?filmId={filmId}");
|
string uri = $"https://kinopoiskapiunofficial.tech/api/v1/staff?filmId={filmId}";
|
||||||
|
|
||||||
var requestOptions = new HttpRequestOptions
|
return await GetAsync<IEnumerable<StaffItem>>(uri, cancellationToken.Value);
|
||||||
{
|
|
||||||
Url = uri.AbsoluteUri,
|
|
||||||
CancellationToken = cancellationToken.Value,
|
|
||||||
BufferContent = true,
|
|
||||||
EnableDefaultUserAgent = true,
|
|
||||||
AcceptHeader = "application/json"
|
|
||||||
};
|
|
||||||
requestOptions.RequestHeaders.Add("X-API-KEY", _apiToken);
|
|
||||||
using(var response = await _httpClient.SendAsync(requestOptions, HttpMethod.Get).ConfigureAwait(false))
|
|
||||||
// todo: status code!
|
|
||||||
using(var jsonStream = response.Content)
|
|
||||||
{
|
|
||||||
return await _jsonSerializer.DeserializeFromStreamAsync<IEnumerable<StaffItem>>(jsonStream).ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<T> GetAsync<T>(string url, CancellationToken cancellationToken) where T: class
|
||||||
|
{
|
||||||
|
using var options = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
|
options.Headers.Add("Accept", "application/json");
|
||||||
|
options.Headers.Add("X-API-KEY", _apiToken);
|
||||||
|
|
||||||
|
var client = _httpClientFactory.CreateClient();
|
||||||
|
using var response = await client.SendAsync(options, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (response.StatusCode != HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
|
_logger.LogError($"Received non-success result status code {response.StatusCode} from Kinopoisk API, response content is:\n{content}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var jsonStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
return await JsonSerializer.DeserializeAsync<T>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Net;
|
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.Movies;
|
using MediaBrowser.Controller.Entities.Movies;
|
||||||
using MediaBrowser.Controller.Entities.TV;
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.Kinopoisk
|
namespace Jellyfin.Plugin.Kinopoisk
|
||||||
@@ -17,35 +16,26 @@ namespace Jellyfin.Plugin.Kinopoisk
|
|||||||
public class KinopoiskImageProvider : IRemoteImageProvider
|
public class KinopoiskImageProvider : IRemoteImageProvider
|
||||||
{
|
{
|
||||||
private readonly ILogger<KinopoiskImageProvider> _logger;
|
private readonly ILogger<KinopoiskImageProvider> _logger;
|
||||||
private readonly IHttpClient _httpClient;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
|
||||||
private readonly KinopoiskApiProxy _apiProxy;
|
private readonly KinopoiskApiProxy _apiProxy;
|
||||||
|
|
||||||
public string Name => Utils.ProviderName;
|
public string Name => Utils.ProviderName;
|
||||||
|
|
||||||
public KinopoiskImageProvider(ILogger<KinopoiskImageProvider> logger,
|
public KinopoiskImageProvider(ILogger<KinopoiskImageProvider> logger, IHttpClientFactory httpClientFactory)
|
||||||
IHttpClient httpClient,
|
|
||||||
IJsonSerializer jsonSerializer)
|
|
||||||
{
|
{
|
||||||
if (logger is null)
|
if (logger is null)
|
||||||
{
|
{
|
||||||
throw new System.ArgumentNullException(nameof(logger));
|
throw new System.ArgumentNullException(nameof(logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpClient is null)
|
if (httpClientFactory is null)
|
||||||
{
|
{
|
||||||
throw new System.ArgumentNullException(nameof(httpClient));
|
throw new System.ArgumentNullException(nameof(httpClientFactory));
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonSerializer is null)
|
|
||||||
{
|
|
||||||
throw new System.ArgumentNullException(nameof(jsonSerializer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._logger = logger;
|
this._logger = logger;
|
||||||
this._httpClient = httpClient;
|
this._httpClientFactory = httpClientFactory;
|
||||||
this._jsonSerializer = jsonSerializer;
|
this._apiProxy = new KinopoiskApiProxy(logger, httpClientFactory);
|
||||||
this._apiProxy = new KinopoiskApiProxy(logger, httpClient, jsonSerializer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Supports(BaseItem item)
|
public bool Supports(BaseItem item)
|
||||||
@@ -58,13 +48,11 @@ namespace Jellyfin.Plugin.Kinopoisk
|
|||||||
ImageType.Backdrop
|
ImageType.Backdrop
|
||||||
};
|
};
|
||||||
|
|
||||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
public async Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return _httpClient.GetResponse(new HttpRequestOptions
|
var client = _httpClientFactory.CreateClient();
|
||||||
{
|
|
||||||
CancellationToken = cancellationToken,
|
return await client.GetAsync(url, cancellationToken);
|
||||||
Url = url
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||||
|
|||||||
@@ -1,25 +1,14 @@
|
|||||||
using System;
|
using System.Net.Http;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Jellyfin.Plugin.Kinopoisk.ApiModel;
|
using Jellyfin.Plugin.Kinopoisk.ApiModel;
|
||||||
using MediaBrowser.Common.Net;
|
|
||||||
using MediaBrowser.Controller.Entities.Movies;
|
using MediaBrowser.Controller.Entities.Movies;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
|
||||||
using MediaBrowser.Model.Providers;
|
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.Kinopoisk
|
namespace Jellyfin.Plugin.Kinopoisk
|
||||||
{
|
{
|
||||||
public class KinopoiskMovieProvider : KinopoiskVideoBaseProvider<Movie, MovieInfo>
|
public class KinopoiskMovieProvider : KinopoiskVideoBaseProvider<Movie, MovieInfo>
|
||||||
{
|
{
|
||||||
public KinopoiskMovieProvider(ILogger<KinopoiskMovieProvider> logger,
|
public KinopoiskMovieProvider(ILogger<KinopoiskMovieProvider> logger, IHttpClientFactory httpClientFactory) : base(logger, httpClientFactory)
|
||||||
IHttpClient httpClient,
|
|
||||||
IJsonSerializer jsonSerializer)
|
|
||||||
: base(logger, httpClient, jsonSerializer)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,15 @@
|
|||||||
using System;
|
using System.Net.Http;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Jellyfin.Plugin.Kinopoisk.ApiModel;
|
using Jellyfin.Plugin.Kinopoisk.ApiModel;
|
||||||
using MediaBrowser.Common.Net;
|
|
||||||
using MediaBrowser.Controller.Entities.TV;
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
|
||||||
using MediaBrowser.Model.Providers;
|
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.Kinopoisk
|
namespace Jellyfin.Plugin.Kinopoisk
|
||||||
{
|
{
|
||||||
public class KinopoiskSeriesProvider : KinopoiskVideoBaseProvider<Series, SeriesInfo>
|
public class KinopoiskSeriesProvider : KinopoiskVideoBaseProvider<Series, SeriesInfo>
|
||||||
{
|
{
|
||||||
public KinopoiskSeriesProvider(ILogger<KinopoiskSeriesProvider> logger,
|
public KinopoiskSeriesProvider(ILogger<KinopoiskSeriesProvider> logger, IHttpClientFactory httpClientFactory) : base(logger, httpClientFactory)
|
||||||
IHttpClient httpClient,
|
|
||||||
IJsonSerializer jsonSerializer)
|
|
||||||
: base(logger, httpClient, jsonSerializer)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Series ConvertResponseToItem(FilmDetails apiResponse)
|
protected override Series ConvertResponseToItem(FilmDetails apiResponse)
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Plugin.Kinopoisk.ApiModel;
|
using Jellyfin.Plugin.Kinopoisk.ApiModel;
|
||||||
using MediaBrowser.Common.Net;
|
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.Kinopoisk
|
namespace Jellyfin.Plugin.Kinopoisk
|
||||||
@@ -17,46 +16,35 @@ namespace Jellyfin.Plugin.Kinopoisk
|
|||||||
where TLookupInfoType : ItemLookupInfo, new()
|
where TLookupInfoType : ItemLookupInfo, new()
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IHttpClient _httpClient;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
|
||||||
private readonly KinopoiskApiProxy _apiProxy;
|
private readonly KinopoiskApiProxy _apiProxy;
|
||||||
|
|
||||||
public string Name => Utils.ProviderName;
|
public string Name => Utils.ProviderName;
|
||||||
|
|
||||||
public KinopoiskVideoBaseProvider(ILogger logger,
|
public KinopoiskVideoBaseProvider(ILogger logger, IHttpClientFactory httpClientFactory)
|
||||||
IHttpClient httpClient,
|
|
||||||
IJsonSerializer jsonSerializer)
|
|
||||||
{
|
{
|
||||||
if (logger is null)
|
if (logger is null)
|
||||||
{
|
{
|
||||||
throw new System.ArgumentNullException(nameof(logger));
|
throw new System.ArgumentNullException(nameof(logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpClient is null)
|
if (httpClientFactory is null)
|
||||||
{
|
{
|
||||||
throw new System.ArgumentNullException(nameof(httpClient));
|
throw new System.ArgumentNullException(nameof(httpClientFactory));
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonSerializer is null)
|
|
||||||
{
|
|
||||||
throw new System.ArgumentNullException(nameof(jsonSerializer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._logger = logger;
|
this._logger = logger;
|
||||||
this._httpClient = httpClient;
|
this._httpClientFactory = httpClientFactory;
|
||||||
this._jsonSerializer = jsonSerializer;
|
this._apiProxy = new KinopoiskApiProxy(logger, httpClientFactory);
|
||||||
this._apiProxy = new KinopoiskApiProxy(logger, httpClient, jsonSerializer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract TItemType ConvertResponseToItem(FilmDetails apiResponse);
|
protected abstract TItemType ConvertResponseToItem(FilmDetails apiResponse);
|
||||||
|
|
||||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
public async Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return _httpClient.GetResponse(new HttpRequestOptions
|
var client = _httpClientFactory.CreateClient();
|
||||||
{
|
|
||||||
CancellationToken = cancellationToken,
|
return await client.GetAsync(url, cancellationToken);
|
||||||
Url = url
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<MetadataResult<TItemType>> GetMetadata(TLookupInfoType info, CancellationToken cancellationToken)
|
public async Task<MetadataResult<TItemType>> GetMetadata(TLookupInfoType info, CancellationToken cancellationToken)
|
||||||
|
|||||||
Reference in new issue
Block a user