aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
diff options
context:
space:
mode:
authorPetrus.Z <silencly07@gmail.com>2021-11-17 14:02:07 +0800
committerPetrus.Z <silencly07@gmail.com>2021-11-17 14:02:07 +0800
commit0a0ddb0eafa669256f0493d1bc2abdf32290302a (patch)
treeafc402e129eff67fb2efbe395a842c2a6481be9b /Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
parent1924d0740d2846aae401686e45d55e8c8358e23b (diff)
Add AutoCollection option
it can determine whether auto create/add movies to collection Signed-off-by: Petrus.Z <silencly07@gmail.com>
Diffstat (limited to 'Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs')
-rw-r--r--Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs34
1 files changed, 26 insertions, 8 deletions
diff --git a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
index e692455db..3deaf7fe7 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 it
if (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.Validators
progress.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 file