Merge pull request #1969 from MediaBrowser/beta

Beta
pull/1154/head
Luke 9 years ago committed by GitHub
commit 52e6ca975d

@ -350,7 +350,8 @@ namespace MediaBrowser.Api.Library
Fields = request.Fields,
Id = request.Id,
Limit = request.Limit,
UserId = request.UserId
UserId = request.UserId,
ExcludeArtistNames = request.ExcludeArtistNames
});
}
if (item is MusicArtist)

@ -25,6 +25,8 @@ namespace MediaBrowser.Api
/// <value>The id.</value>
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Id { get; set; }
public string ExcludeArtistNames { get; set; }
}
public class BaseGetSimilarItems : IReturn<ItemsResult>, IHasItemFields
@ -70,6 +72,12 @@ namespace MediaBrowser.Api
Recursive = true
};
// ExcludeArtistNames
if (!string.IsNullOrEmpty(request.ExcludeArtistNames))
{
query.ExcludeArtistNames = request.ExcludeArtistNames.Split('|');
}
var inputItems = libraryManager.GetItemList(query);
var items = GetSimilaritems(item, libraryManager, inputItems, getSimilarityScore)

@ -266,6 +266,8 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "Artists", Description = "Optional. If specified, results will be filtered based on artist. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Artists { get; set; }
public string ExcludeArtistNames { get; set; }
[ApiMember(Name = "ArtistIds", Description = "Optional. If specified, results will be filtered based on artist. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string ArtistIds { get; set; }

@ -368,6 +368,12 @@ namespace MediaBrowser.Api.UserLibrary
query.ArtistNames = request.Artists.Split('|');
}
// ExcludeArtistNames
if (!string.IsNullOrEmpty(request.ExcludeArtistNames))
{
query.ExcludeArtistNames = request.ExcludeArtistNames.Split('|');
}
// Albums
if (!string.IsNullOrEmpty(request.Albums))
{

@ -138,6 +138,7 @@ namespace MediaBrowser.Controller.Entities
public string[] AlbumNames { get; set; }
public string[] ArtistNames { get; set; }
public string[] ExcludeArtistNames { get; set; }
public string AncestorWithPresentationUniqueKey { get; set; }
public bool GroupByPresentationUniqueKey { get; set; }
@ -153,6 +154,7 @@ namespace MediaBrowser.Controller.Entities
AlbumNames = new string[] { };
ArtistNames = new string[] { };
ExcludeArtistNames = new string[] { };
ExcludeProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
BlockUnratedItems = new UnratedItem[] { };

@ -116,7 +116,6 @@
<Compile Include="Movies\MovieDbSearch.cs" />
<Compile Include="Movies\MovieMetadataService.cs" />
<Compile Include="Movies\TmdbSettings.cs" />
<Compile Include="MusicGenres\MusicGenreImageProvider.cs" />
<Compile Include="GameGenres\GameGenreImageProvider.cs" />
<Compile Include="Genres\GenreImageProvider.cs" />
<Compile Include="ImagesByName\ImageUtils.cs" />

@ -1,145 +0,0 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;
using MediaBrowser.Providers.Genres;
using MediaBrowser.Providers.ImagesByName;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
namespace MediaBrowser.Providers.MusicGenres
{
public class MusicGenreImageProvider : IRemoteImageProvider
{
private readonly IServerConfigurationManager _config;
private readonly IHttpClient _httpClient;
private readonly IFileSystem _fileSystem;
private readonly SemaphoreSlim _listResourcePool = new SemaphoreSlim(1, 1);
public MusicGenreImageProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem)
{
_config = config;
_httpClient = httpClient;
_fileSystem = fileSystem;
}
public string Name
{
get { return ProviderName; }
}
public static string ProviderName
{
get { return "Media Browser Designs"; }
}
public bool Supports(IHasImages item)
{
return item is MusicGenre;
}
public IEnumerable<ImageType> GetSupportedImages(IHasImages item)
{
return new List<ImageType>
{
ImageType.Primary,
ImageType.Thumb
};
}
public Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
return GetImages(item, true, true, cancellationToken);
}
private async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, bool posters, bool thumbs, CancellationToken cancellationToken)
{
var list = new List<RemoteImageInfo>();
if (posters)
{
var posterPath = Path.Combine(_config.ApplicationPaths.CachePath, "imagesbyname", "remotemusicgenreposters.txt");
await EnsurePosterList(posterPath, cancellationToken).ConfigureAwait(false);
list.Add(GetImage(item, posterPath, ImageType.Primary, "folder"));
}
cancellationToken.ThrowIfCancellationRequested();
if (thumbs)
{
var thumbsPath = Path.Combine(_config.ApplicationPaths.CachePath, "imagesbyname", "remotemusicgenrethumbs.txt");
await EnsureThumbsList(thumbsPath, cancellationToken).ConfigureAwait(false);
list.Add(GetImage(item, thumbsPath, ImageType.Thumb, "thumb"));
}
return list.Where(i => i != null);
}
private RemoteImageInfo GetImage(IHasImages item, string filename, ImageType type, string remoteFilename)
{
var list = ImageUtils.GetAvailableImages(filename);
var match = ImageUtils.FindMatch(item, list);
if (!string.IsNullOrEmpty(match))
{
var url = GetUrl(match, remoteFilename);
return new RemoteImageInfo
{
ProviderName = Name,
Type = type,
Url = url
};
}
return null;
}
private string GetUrl(string image, string filename)
{
return string.Format("https://raw.github.com/MediaBrowser/MediaBrowser.Resources/master/images/imagesbyname/musicgenres/{0}/{1}.jpg", image, filename);
}
private Task EnsureThumbsList(string file, CancellationToken cancellationToken)
{
const string url = "https://raw.github.com/MediaBrowser/MediaBrowser.Resources/master/images/imagesbyname/musicgenrethumbs.txt";
return ImageUtils.EnsureList(url, file, _httpClient, _fileSystem, _listResourcePool, cancellationToken);
}
private Task EnsurePosterList(string file, CancellationToken cancellationToken)
{
const string url = "https://raw.github.com/MediaBrowser/MediaBrowser.Resources/master/images/imagesbyname/musicgenreposters.txt";
return ImageUtils.EnsureList(url, file, _httpClient, _fileSystem, _listResourcePool, cancellationToken);
}
public int Order
{
get { return 0; }
}
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
{
return _httpClient.GetResponse(new HttpRequestOptions
{
CancellationToken = cancellationToken,
Url = url,
ResourcePool = GenreImageProvider.ImageDownloadResourcePool
});
}
}
}

@ -2883,6 +2883,20 @@ namespace MediaBrowser.Server.Implementations.Persistence
whereClauses.Add(clause);
}
if (query.ExcludeArtistNames.Length > 0)
{
var clauses = new List<string>();
var index = 0;
foreach (var artist in query.ExcludeArtistNames)
{
clauses.Add("@ExcludeArtistName" + index + " not in (select CleanValue from itemvalues where ItemId=Guid and Type <= 1)");
cmd.Parameters.Add(cmd, "@ExcludeArtistName" + index, DbType.String).Value = artist.RemoveDiacritics();
index++;
}
var clause = "(" + string.Join(" AND ", clauses.ToArray()) + ")";
whereClauses.Add(clause);
}
if (query.GenreIds.Length > 0)
{
// Todo: improve without having to do this

Loading…
Cancel
Save