From 7475722ecf1f36951ae92fafaa188135d33bbed2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 22 Jul 2016 18:10:39 -0400 Subject: [PATCH 1/4] switch to ExcludeArtistIds --- MediaBrowser.Api/Library/LibraryService.cs | 2 +- MediaBrowser.Api/SimilarItemsHelper.cs | 8 ++++---- MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs | 2 +- MediaBrowser.Api/UserLibrary/ItemsService.cs | 6 +++--- .../Entities/InternalItemsQuery.cs | 4 ++-- .../Persistence/SqliteItemRepository.cs | 14 +++++++++----- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index e5a40ba2f..14a771db0 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -351,7 +351,7 @@ namespace MediaBrowser.Api.Library Id = request.Id, Limit = request.Limit, UserId = request.UserId, - ExcludeArtistNames = request.ExcludeArtistNames + ExcludeArtistIds = request.ExcludeArtistIds }); } if (item is MusicArtist) diff --git a/MediaBrowser.Api/SimilarItemsHelper.cs b/MediaBrowser.Api/SimilarItemsHelper.cs index eea2814a6..a1e47bd8f 100644 --- a/MediaBrowser.Api/SimilarItemsHelper.cs +++ b/MediaBrowser.Api/SimilarItemsHelper.cs @@ -26,7 +26,7 @@ namespace MediaBrowser.Api [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 string ExcludeArtistIds { get; set; } } public class BaseGetSimilarItems : IReturn, IHasItemFields @@ -72,10 +72,10 @@ namespace MediaBrowser.Api Recursive = true }; - // ExcludeArtistNames - if (!string.IsNullOrEmpty(request.ExcludeArtistNames)) + // ExcludeArtistIds + if (!string.IsNullOrEmpty(request.ExcludeArtistIds)) { - query.ExcludeArtistNames = request.ExcludeArtistNames.Split('|'); + query.ExcludeArtistIds = request.ExcludeArtistIds.Split('|'); } var inputItems = libraryManager.GetItemList(query); diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index 60bcc91b0..3e9a541c0 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -266,7 +266,7 @@ 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; } + public string ExcludeArtistIds { 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 4db1ed9f4..b4d88a7f8 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -368,10 +368,10 @@ namespace MediaBrowser.Api.UserLibrary query.ArtistNames = request.Artists.Split('|'); } - // ExcludeArtistNames - if (!string.IsNullOrEmpty(request.ExcludeArtistNames)) + // ExcludeArtistIds + if (!string.IsNullOrEmpty(request.ExcludeArtistIds)) { - query.ExcludeArtistNames = request.ExcludeArtistNames.Split('|'); + query.ExcludeArtistIds = request.ExcludeArtistIds.Split('|'); } // Albums diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index bf2a50202..69cab5ec5 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -138,7 +138,7 @@ namespace MediaBrowser.Controller.Entities public string[] AlbumNames { get; set; } public string[] ArtistNames { get; set; } - public string[] ExcludeArtistNames { get; set; } + public string[] ExcludeArtistIds { get; set; } public string AncestorWithPresentationUniqueKey { get; set; } public bool GroupByPresentationUniqueKey { get; set; } @@ -154,7 +154,7 @@ namespace MediaBrowser.Controller.Entities AlbumNames = new string[] { }; ArtistNames = new string[] { }; - ExcludeArtistNames = new string[] { }; + ExcludeArtistIds = 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 4f8f31a75..7f556cfb0 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -2883,15 +2883,19 @@ namespace MediaBrowser.Server.Implementations.Persistence whereClauses.Add(clause); } - if (query.ExcludeArtistNames.Length > 0) + if (query.ExcludeArtistIds.Length > 0) { var clauses = new List(); var index = 0; - foreach (var artist in query.ExcludeArtistNames) + foreach (var artistId in query.ExcludeArtistIds) { - 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 artistItem = RetrieveItem(new Guid(artistId)); + if (artistItem != null) + { + 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 = artistItem.Name.RemoveDiacritics(); + index++; + } } var clause = "(" + string.Join(" AND ", clauses.ToArray()) + ")"; whereClauses.Add(clause); From bd4c99b01a609d6d96a195a29627d41093a6437b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 23 Jul 2016 01:03:16 -0400 Subject: [PATCH 2/4] update cache file cleanup --- Emby.Drawing/ImageProcessor.cs | 4 ++-- MediaBrowser.Api/Playback/StreamState.cs | 4 ++++ .../ScheduledTasks/Tasks/DeleteCacheFileTask.cs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 3288229a2..80ebbb719 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -246,7 +246,7 @@ namespace Emby.Drawing var newHeight = Convert.ToInt32(newSize.Height); _fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); - var tmpPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")); + var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(cacheFilePath)); _fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath)); await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); @@ -433,7 +433,7 @@ namespace Emby.Drawing try { _fileSystem.CreateDirectory(Path.GetDirectoryName(croppedImagePath)); - var tmpPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")); + var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(croppedImagePath)); _fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath)); await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index d0d0337c2..da6be97b6 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -80,6 +80,10 @@ namespace MediaBrowser.Api.Playback { return 10; } + if (userAgent.IndexOf("cfnetwork", StringComparison.OrdinalIgnoreCase) != -1) + { + return 10; + } return 6; } diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs index b4cc5d753..0a2b9222a 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs @@ -71,7 +71,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks progress.Report(90); - minDateModified = DateTime.UtcNow.AddDays(-2); + minDateModified = DateTime.UtcNow.AddDays(-1); try { From e853b35fd8ff7f7a2830577d077db319bd17241d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 23 Jul 2016 01:16:26 -0400 Subject: [PATCH 3/4] improve guest add flow --- MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 723c4f936..c44b6bf65 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -125,6 +125,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest From 2aeee846f421ec3a0e943d0cdcdedcdb250904ce Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 23 Jul 2016 01:44:46 -0400 Subject: [PATCH 4/4] source music genre images from library content --- .../Photos/BaseDynamicImageProvider.cs | 3 +- .../Playlists/PlaylistImageProvider.cs | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs index ea2460719..abf0f3425 100644 --- a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs @@ -13,6 +13,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using CommonIO; +using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Configuration; namespace MediaBrowser.Server.Implementations.Photos @@ -247,7 +248,7 @@ namespace MediaBrowser.Server.Implementations.Photos { return await CreateSquareCollage(item, itemsWithImages, outputPath).ConfigureAwait(false); } - if (item is Playlist) + if (item is Playlist || item is MusicGenre) { return await CreateSquareCollage(item, itemsWithImages, outputPath).ConfigureAwait(false); } diff --git a/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs b/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs index bdb73ea38..5b234d0c6 100644 --- a/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs @@ -12,6 +12,8 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using CommonIO; +using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Querying; namespace MediaBrowser.Server.Implementations.Playlists { @@ -65,4 +67,36 @@ namespace MediaBrowser.Server.Implementations.Playlists return Task.FromResult(GetFinalItems(items)); } } + + public class MusicGenreImageProvider : BaseDynamicImageProvider + { + private readonly ILibraryManager _libraryManager; + + public MusicGenreImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager) : base(fileSystem, providerManager, applicationPaths, imageProcessor) + { + _libraryManager = libraryManager; + } + + protected override Task> GetItemsWithImages(IHasImages item) + { + var items = _libraryManager.GetItemList(new InternalItemsQuery + { + Genres = new[] { item.Name }, + IncludeItemTypes = new[] { typeof(MusicAlbum).Name, typeof(MusicVideo).Name, typeof(Audio).Name }, + SortBy = new[] { ItemSortBy.Random }, + Limit = 4, + Recursive = true, + ImageTypes = new[] { ImageType.Primary } + + }).ToList(); + + return Task.FromResult(GetFinalItems(items)); + } + + //protected override Task CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) + //{ + // return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary); + //} + } + }