aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Library/Validators
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/Validators')
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs10
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs29
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs29
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs30
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs42
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs30
6 files changed, 155 insertions, 15 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
index c9440bb27..68d351b44 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
@@ -48,26 +48,22 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
.Cast<IHasArtist>()
.ToList();
- var allArtists = allSongs.SelectMany(i => i.AllArtists)
- .DistinctNames()
- .ToList();
+ var allArtists = _libraryManager.GetArtists(allSongs).ToList();
var numComplete = 0;
var numArtists = allArtists.Count;
- foreach (var artist in allArtists)
+ foreach (var artistItem in allArtists)
{
cancellationToken.ThrowIfCancellationRequested();
try
{
- var artistItem = _libraryManager.GetArtist(artist);
-
await artistItem.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (IOException ex)
{
- _logger.ErrorException("Error validating Artist {0}", ex, artist);
+ _logger.ErrorException("Error validating Artist {0}", ex, artistItem.Name);
}
// Update progress
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
index fe2e6a114..b57e128d3 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Controller.Entities;
+using System.Collections.Generic;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
@@ -42,12 +43,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
+ var validIds = new List<Guid>();
+
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetGameGenre(name);
+ validIds.Add(itemByName.Id);
+
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
@@ -68,6 +73,28 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(percent);
}
+ var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
+ {
+ IncludeItemTypes = new[] { typeof(GameGenre).Name }
+ });
+
+ var invalidIds = allIds
+ .Except(validIds)
+ .ToList();
+
+ foreach (var id in invalidIds)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+
+ var item = _libraryManager.GetItemById(id);
+
+ await _libraryManager.DeleteItem(item, new DeleteOptions
+ {
+ DeleteFileLocation = false
+
+ }).ConfigureAwait(false);
+ }
+
progress.Report(100);
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
index fac5cfc35..11d4c9f16 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Controller.Entities;
+using System.Collections.Generic;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
@@ -43,12 +44,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
+ var validIds = new List<Guid>();
+
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetGenre(name);
+ validIds.Add(itemByName.Id);
+
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
@@ -69,6 +74,28 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(percent);
}
+ var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
+ {
+ IncludeItemTypes = new[] { typeof(Genre).Name }
+ });
+
+ var invalidIds = allIds
+ .Except(validIds)
+ .ToList();
+
+ foreach (var id in invalidIds)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+
+ var item = _libraryManager.GetItemById(id);
+
+ await _libraryManager.DeleteItem(item, new DeleteOptions
+ {
+ DeleteFileLocation = false
+
+ }).ConfigureAwait(false);
+ }
+
progress.Report(100);
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
index e3be75e9b..0a66b4b41 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
@@ -1,4 +1,6 @@
-using MediaBrowser.Controller.Entities.Audio;
+using System.Collections.Generic;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
@@ -42,12 +44,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
+ var validIds = new List<Guid>();
+
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetMusicGenre(name);
+ validIds.Add(itemByName.Id);
+
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
@@ -68,6 +74,28 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(percent);
}
+ var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
+ {
+ IncludeItemTypes = new[] { typeof(MusicGenre).Name }
+ });
+
+ var invalidIds = allIds
+ .Except(validIds)
+ .ToList();
+
+ foreach (var id in invalidIds)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+
+ var item = _libraryManager.GetItemById(id);
+
+ await _libraryManager.DeleteItem(item, new DeleteOptions
+ {
+ DeleteFileLocation = false
+
+ }).ConfigureAwait(false);
+ }
+
progress.Report(100);
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
index ef9dee8b5..a4c43af5d 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
@@ -92,15 +92,25 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
foreach (var person in people)
{
- bool current;
- if (!dict.TryGetValue(person.Name, out current) || !current)
+ var isMetadataEnabled = DownloadMetadata(person, peopleOptions);
+
+ bool currentValue;
+ if (dict.TryGetValue(person.Name, out currentValue))
+ {
+ if (!currentValue && isMetadataEnabled)
+ {
+ dict[person.Name] = true;
+ }
+ }
+ else
{
- dict[person.Name] = DownloadMetadata(person, peopleOptions);
+ dict[person.Name] = isMetadataEnabled;
}
}
var numComplete = 0;
-
+ var validIds = new List<Guid>();
+
foreach (var person in dict)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -109,6 +119,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
{
var item = _libraryManager.GetPerson(person.Key);
+ validIds.Add(item.Id);
+
var options = new MetadataRefreshOptions
{
MetadataRefreshMode = person.Value ? MetadataRefreshMode.Default : MetadataRefreshMode.ValidationOnly,
@@ -130,6 +142,28 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(100 * percent);
}
+ var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
+ {
+ IncludeItemTypes = new[] { typeof(Person).Name }
+ });
+
+ var invalidIds = allIds
+ .Except(validIds)
+ .ToList();
+
+ foreach (var id in invalidIds)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+
+ var item = _libraryManager.GetItemById(id);
+
+ await _libraryManager.DeleteItem(item, new DeleteOptions
+ {
+ DeleteFileLocation = false
+
+ }).ConfigureAwait(false);
+ }
+
progress.Report(100);
_logger.Info("People validation complete");
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
index 066b96853..c122d64d3 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
@@ -1,6 +1,8 @@
-using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -41,12 +43,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
+ var validIds = new List<Guid>();
+
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetStudio(name);
+ validIds.Add(itemByName.Id);
+
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
@@ -67,6 +73,28 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(percent);
}
+ var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
+ {
+ IncludeItemTypes = new[] { typeof(Studio).Name }
+ });
+
+ var invalidIds = allIds
+ .Except(validIds)
+ .ToList();
+
+ foreach (var id in invalidIds)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+
+ var item = _libraryManager.GetItemById(id);
+
+ await _libraryManager.DeleteItem(item, new DeleteOptions
+ {
+ DeleteFileLocation = false
+
+ }).ConfigureAwait(false);
+ }
+
progress.Report(100);
}
}