The Free Software Media System - Server Backend & API
Add AutoCollection option
Petrus.Z0a0ddb0eafa6
diff --git a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.csindex e692455db1..3deaf7fe78 100644--- a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs+++ b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs@@ -10,6 +10,7 @@ using MediaBrowser.Controller.Library;using MediaBrowser.Model.Querying;using Jellyfin.Data.Enums;using Microsoft.Extensions.Logging;+using System.Diagnostics;namespace Emby.Server.Implementations.Library.Validators{@@ -101,18 +102,23 @@ namespace Emby.Server.Implementations.Library.Validators// won't automatically create collection if only one movie in itif (movieList.Count >= 2){- boxSet = await _collectionManager.CreateCollectionAsync(new CollectionCreationOptions- {- Name = collectionName,- IsLocked = true- });+ var movieIds = FliterMoviesByOption(movieList);+ if (movieIds.Count >= 2) {+ // at least 2 movies have AutoCollection option enable+ boxSet = await _collectionManager.CreateCollectionAsync(new CollectionCreationOptions+ {+ Name = collectionName,+ IsLocked = true+ });- await _collectionManager.AddToCollectionAsync(boxSet.Id, movieList.Select(m => m.Id));+ await _collectionManager.AddToCollectionAsync(boxSet.Id, movieIds);+ }}}else{- await _collectionManager.AddToCollectionAsync(boxSet.Id, movieList.Select(m => m.Id));+ var movieIds = FliterMoviesByOption(movieList);+ await _collectionManager.AddToCollectionAsync(boxSet.Id, movieIds);}numComplete++;@@ -130,5 +136,17 @@ namespace Emby.Server.Implementations.Library.Validatorsprogress.Report(100);}++ private List<Guid> FliterMoviesByOption(List<Movie> movieList) {+ List<Guid> movieIds = new List<Guid>();+ foreach (var movie in movieList)+ {+ if (_libraryManager.GetLibraryOptions(movie).AutoCollection)+ {+ movieIds.Add(movie.Id);+ }+ }+ return movieIds;+ }}-}+}\ No newline at end of filediff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.csindex aae5359b1d..0a676de9a2 100644--- a/MediaBrowser.Model/Configuration/LibraryOptions.cs+++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs@@ -16,6 +16,7 @@ namespace MediaBrowser.Model.ConfigurationSkipSubtitlesIfAudioTrackMatches = true;RequirePerfectSubtitleMatch = true;+ AutoCollection = true;EnablePhotos = true;SaveSubtitlesWithMedia = true;EnableRealtimeMonitor = true;@@ -80,6 +81,7 @@ namespace MediaBrowser.Model.Configurationpublic bool RequirePerfectSubtitleMatch { get; set; }public bool SaveSubtitlesWithMedia { get; set; }+ public bool AutoCollection { get; set; }public TypeOptions[] TypeOptions { get; set; }