fixes #709 - Add option to show all languages in image interface
This commit is contained in:
parent
e048a9214d
commit
f64f55c894
|
@ -40,6 +40,9 @@ namespace MediaBrowser.Api.Images
|
||||||
|
|
||||||
[ApiMember(Name = "ProviderName", Description = "Optional. The image provider to use", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "ProviderName", Description = "Optional. The image provider to use", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string ProviderName { get; set; }
|
public string ProviderName { get; set; }
|
||||||
|
|
||||||
|
[ApiMember(Name = "IncludeAllLanguages", Description = "Optional.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||||
|
public bool IncludeAllLanguages { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/Items/{Id}/RemoteImages", "GET")]
|
[Route("/Items/{Id}/RemoteImages", "GET")]
|
||||||
|
@ -217,7 +220,14 @@ namespace MediaBrowser.Api.Images
|
||||||
|
|
||||||
private RemoteImageResult GetRemoteImageResult(BaseItem item, BaseRemoteImageRequest request)
|
private RemoteImageResult GetRemoteImageResult(BaseItem item, BaseRemoteImageRequest request)
|
||||||
{
|
{
|
||||||
var images = _providerManager.GetAvailableRemoteImages(item, CancellationToken.None, request.ProviderName, request.Type).Result;
|
var images = _providerManager.GetAvailableRemoteImages(item, new RemoteImageQuery
|
||||||
|
{
|
||||||
|
ProviderName = request.ProviderName,
|
||||||
|
IncludeAllLanguages = request.IncludeAllLanguages,
|
||||||
|
IncludeDisabledProviders = true,
|
||||||
|
ImageType = request.Type
|
||||||
|
|
||||||
|
}, CancellationToken.None).Result;
|
||||||
|
|
||||||
var imagesList = images.ToList();
|
var imagesList = images.ToList();
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,8 @@ namespace MediaBrowser.Controller.LiveTv
|
||||||
|
|
||||||
public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
|
public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
DateLastSaved = DateTime.UtcNow;
|
||||||
|
|
||||||
// Avoid library manager and keep out of in-memory cache
|
// Avoid library manager and keep out of in-memory cache
|
||||||
// Not great that this class has to know about that, but we'll improve that later.
|
// Not great that this class has to know about that, but we'll improve that later.
|
||||||
return ItemRepository.SaveItem(this, cancellationToken);
|
return ItemRepository.SaveItem(this, cancellationToken);
|
||||||
|
|
|
@ -62,11 +62,10 @@ namespace MediaBrowser.Controller.Providers
|
||||||
/// Gets the available remote images.
|
/// Gets the available remote images.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="query">The query.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <param name="providerName">Name of the provider.</param>
|
|
||||||
/// <param name="type">The type.</param>
|
|
||||||
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
|
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
|
||||||
Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(IHasImages item, CancellationToken cancellationToken, string providerName = null, ImageType? type = null);
|
Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(IHasImages item, RemoteImageQuery query, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the image providers.
|
/// Gets the image providers.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Providers
|
namespace MediaBrowser.Model.Providers
|
||||||
{
|
{
|
||||||
|
@ -25,4 +26,15 @@ namespace MediaBrowser.Model.Providers
|
||||||
/// <value>The providers.</value>
|
/// <value>The providers.</value>
|
||||||
public List<string> Providers { get; set; }
|
public List<string> Providers { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class RemoteImageQuery
|
||||||
|
{
|
||||||
|
public string ProviderName { get; set; }
|
||||||
|
|
||||||
|
public ImageType? ImageType { get; set; }
|
||||||
|
|
||||||
|
public bool IncludeDisabledProviders { get; set; }
|
||||||
|
|
||||||
|
public bool IncludeAllLanguages { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,14 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
_logger.Debug("Running {0} for {1}", provider.GetType().Name, item.Path ?? item.Name);
|
_logger.Debug("Running {0} for {1}", provider.GetType().Name, item.Path ?? item.Name);
|
||||||
|
|
||||||
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, provider.Name).ConfigureAwait(false);
|
var images = await _providerManager.GetAvailableRemoteImages(item, new RemoteImageQuery
|
||||||
|
{
|
||||||
|
ProviderName = provider.Name,
|
||||||
|
IncludeAllLanguages = false,
|
||||||
|
IncludeDisabledProviders = false,
|
||||||
|
|
||||||
|
}, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var list = images.ToList();
|
var list = images.ToList();
|
||||||
|
|
||||||
foreach (var type in _singularImages)
|
foreach (var type in _singularImages)
|
||||||
|
|
|
@ -205,26 +205,31 @@ namespace MediaBrowser.Providers.Manager
|
||||||
/// Gets the available remote images.
|
/// Gets the available remote images.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="query">The query.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <param name="providerName">Name of the provider.</param>
|
|
||||||
/// <param name="type">The type.</param>
|
|
||||||
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
|
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
|
||||||
public async Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(IHasImages item, CancellationToken cancellationToken, string providerName = null, ImageType? type = null)
|
public async Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(IHasImages item, RemoteImageQuery query, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var providers = GetRemoteImageProviders(item, true);
|
var providers = GetRemoteImageProviders(item, query.IncludeDisabledProviders);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(providerName))
|
if (!string.IsNullOrEmpty(query.ProviderName))
|
||||||
{
|
{
|
||||||
|
var providerName = query.ProviderName;
|
||||||
|
|
||||||
providers = providers.Where(i => string.Equals(i.Name, providerName, StringComparison.OrdinalIgnoreCase));
|
providers = providers.Where(i => string.Equals(i.Name, providerName, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
var preferredLanguage = item.GetPreferredMetadataLanguage();
|
var preferredLanguage = item.GetPreferredMetadataLanguage();
|
||||||
|
|
||||||
var tasks = providers.Select(i => GetImages(item, cancellationToken, i, preferredLanguage, type));
|
var language = query.IncludeAllLanguages ? null : preferredLanguage;
|
||||||
|
|
||||||
|
var tasks = providers.Select(i => GetImages(item, cancellationToken, i, language, query.ImageType));
|
||||||
|
|
||||||
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||||
|
|
||||||
return results.SelectMany(i => i);
|
var images = results.SelectMany(i => i);
|
||||||
|
|
||||||
|
return images;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -244,12 +249,15 @@ namespace MediaBrowser.Providers.Manager
|
||||||
{
|
{
|
||||||
var result = await i.GetImages(item, type.Value, cancellationToken).ConfigureAwait(false);
|
var result = await i.GetImages(item, type.Value, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
return FilterImages(result, preferredLanguage);
|
return string.IsNullOrEmpty(preferredLanguage) ? result :
|
||||||
|
FilterImages(result, preferredLanguage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var result = await i.GetAllImages(item, cancellationToken).ConfigureAwait(false);
|
var result = await i.GetAllImages(item, cancellationToken).ConfigureAwait(false);
|
||||||
return FilterImages(result, preferredLanguage);
|
|
||||||
|
return string.IsNullOrEmpty(preferredLanguage) ? result :
|
||||||
|
FilterImages(result, preferredLanguage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>{156EA256-AD2D-4D2F-B116-2ED4B9EFD869}</ProjectGuid>
|
<ProjectGuid>{68468A75-9778-4F9B-98EE-17B223B0314B}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>MediaBrowser.ServerApplication</RootNamespace>
|
<RootNamespace>MediaBrowser.ServerApplication</RootNamespace>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user