From c5e7c23a2e540694ed6d8d5e1c4788e796877ad9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 22 Jul 2016 01:54:09 -0400 Subject: [PATCH 1/3] restore version --- SharedVersion.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index a452789cf..d996b5e97 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -//[assembly: AssemblyVersion("3.1.*")] -[assembly: AssemblyVersion("3.0.5986")] +[assembly: AssemblyVersion("3.1.*")] +//[assembly: AssemblyVersion("3.0.5986")] From d286a86e191337b3dc57c914b35431d8aabc2823 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 22 Jul 2016 13:30:39 -0400 Subject: [PATCH 2/3] switch to unified notifications --- .../MediaBrowser.Providers.csproj | 1 - .../MusicGenres/MusicGenreImageProvider.cs | 145 ------------------ 2 files changed, 146 deletions(-) delete mode 100644 MediaBrowser.Providers/MusicGenres/MusicGenreImageProvider.cs diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj index 99d8b15b6..8b3d1fb7e 100644 --- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj +++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj @@ -116,7 +116,6 @@ - diff --git a/MediaBrowser.Providers/MusicGenres/MusicGenreImageProvider.cs b/MediaBrowser.Providers/MusicGenres/MusicGenreImageProvider.cs deleted file mode 100644 index 43495aaea..000000000 --- a/MediaBrowser.Providers/MusicGenres/MusicGenreImageProvider.cs +++ /dev/null @@ -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 GetSupportedImages(IHasImages item) - { - return new List - { - ImageType.Primary, - ImageType.Thumb - }; - } - - public Task> GetImages(IHasImages item, CancellationToken cancellationToken) - { - return GetImages(item, true, true, cancellationToken); - } - - private async Task> GetImages(IHasImages item, bool posters, bool thumbs, CancellationToken cancellationToken) - { - var list = new List(); - - 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 GetImageResponse(string url, CancellationToken cancellationToken) - { - return _httpClient.GetResponse(new HttpRequestOptions - { - CancellationToken = cancellationToken, - Url = url, - ResourcePool = GenreImageProvider.ImageDownloadResourcePool - }); - } - } -} From df5cfc0c2580c5bab0a588279c97dec9145736d4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 22 Jul 2016 13:54:43 -0400 Subject: [PATCH 3/3] update more from/similar --- MediaBrowser.Api/Library/LibraryService.cs | 3 ++- MediaBrowser.Api/SimilarItemsHelper.cs | 8 ++++++++ MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs | 2 ++ MediaBrowser.Api/UserLibrary/ItemsService.cs | 6 ++++++ .../Entities/InternalItemsQuery.cs | 2 ++ .../Persistence/SqliteItemRepository.cs | 14 ++++++++++++++ 6 files changed, 34 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 1949dea12..e5a40ba2f 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -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) diff --git a/MediaBrowser.Api/SimilarItemsHelper.cs b/MediaBrowser.Api/SimilarItemsHelper.cs index c98a91a55..eea2814a6 100644 --- a/MediaBrowser.Api/SimilarItemsHelper.cs +++ b/MediaBrowser.Api/SimilarItemsHelper.cs @@ -25,6 +25,8 @@ namespace MediaBrowser.Api /// The id. [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, 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) diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index 5a66f872f..60bcc91b0 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -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; } diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 74b33fbb7..4db1ed9f4 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -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)) { diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 5faf85b2a..bf2a50202 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -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(StringComparer.OrdinalIgnoreCase); BlockUnratedItems = new UnratedItem[] { }; diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index a33e4f3e4..4f8f31a75 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -2883,6 +2883,20 @@ namespace MediaBrowser.Server.Implementations.Persistence whereClauses.Add(clause); } + if (query.ExcludeArtistNames.Length > 0) + { + var clauses = new List(); + 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