using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;
namespace Jellyfin.Plugin.Artwork.Providers
{
///
/// Studio artwork provider.
///
public class StudioArtworkProvider : IRemoteImageProvider
{
private readonly IHttpClientFactory _httpClientFactory;
private readonly IRepositoryCache _repositoryCache;
///
/// Initializes a new instance of the class.
///
/// Instance of the interface.
/// Instance of the interface.
public StudioArtworkProvider(
IHttpClientFactory httpClientFactory,
IRepositoryCache repositoryCache)
{
_httpClientFactory = httpClientFactory;
_repositoryCache = repositoryCache;
}
///
public string Name
=> "Studio Artwork Provider";
///
public bool Supports(BaseItem item)
=> item is Studio;
///
public IEnumerable GetSupportedImages(BaseItem item)
=> ArtworkProviderHelper.GetSupportedImages;
///
public Task> GetImages(BaseItem item, CancellationToken cancellationToken)
=> _repositoryCache.GetImageInfos("studios", typeof(Studio), item);
///
public Task GetImageResponse(string url, CancellationToken cancellationToken)
=> _httpClientFactory
.CreateClient(NamedClient.Default)
.GetAsync(new Uri(url), cancellationToken);
}
}