aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Library
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library')
-rw-r--r--MediaBrowser.Server.Implementations/Library/LibraryManager.cs187
-rw-r--r--MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs28
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs6
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs31
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs6
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs11
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs3
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs4
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs6
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs7
-rw-r--r--MediaBrowser.Server.Implementations/Library/SearchEngine.cs20
-rw-r--r--MediaBrowser.Server.Implementations/Library/UserDataManager.cs1
-rw-r--r--MediaBrowser.Server.Implementations/Library/UserViewManager.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs7
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs40
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs7
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs47
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs7
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs47
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs7
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs49
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs41
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs7
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs27
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs1
27 files changed, 267 insertions, 336 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index 712ea4ef3..cc3a7e41f 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -364,7 +364,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (item.IsFolder)
{
- if (!(item is ICollectionFolder) && !(item is UserView) && !(item is Channel))
+ if (!(item is ICollectionFolder) && !(item is UserView) && !(item is Channel) && !(item is AggregateFolder))
{
if (item.SourceType != SourceType.Library)
{
@@ -556,7 +556,12 @@ namespace MediaBrowser.Server.Implementations.Library
return ResolvePath(fileInfo, new DirectoryService(_logger, _fileSystem), null, parent);
}
- private BaseItem ResolvePath(FileSystemMetadata fileInfo, IDirectoryService directoryService, IItemResolver[] resolvers, Folder parent = null, string collectionType = null)
+ private BaseItem ResolvePath(FileSystemMetadata fileInfo,
+ IDirectoryService directoryService,
+ IItemResolver[] resolvers,
+ Folder parent = null,
+ string collectionType = null,
+ LibraryOptions libraryOptions = null)
{
if (fileInfo == null)
{
@@ -575,7 +580,8 @@ namespace MediaBrowser.Server.Implementations.Library
Parent = parent,
Path = fullPath,
FileInfo = fileInfo,
- CollectionType = collectionType
+ CollectionType = collectionType,
+ LibraryOptions = libraryOptions
};
// Return null if ignore rules deem that we should do so
@@ -653,12 +659,17 @@ namespace MediaBrowser.Server.Implementations.Library
return !args.ContainsFileSystemEntryByName(".ignore");
}
- public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, string collectionType)
+ public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, LibraryOptions libraryOptions, string collectionType)
{
- return ResolvePaths(files, directoryService, parent, collectionType, EntityResolvers);
+ return ResolvePaths(files, directoryService, parent, libraryOptions, collectionType, EntityResolvers);
}
- public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, string collectionType, IItemResolver[] resolvers)
+ public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files,
+ IDirectoryService directoryService,
+ Folder parent,
+ LibraryOptions libraryOptions,
+ string collectionType,
+ IItemResolver[] resolvers)
{
var fileList = files.Where(i => !IgnoreFile(i, parent)).ToList();
@@ -679,22 +690,27 @@ namespace MediaBrowser.Server.Implementations.Library
{
ResolverHelper.SetInitialItemValues(item, parent, _fileSystem, this, directoryService);
}
- items.AddRange(ResolveFileList(result.ExtraFiles, directoryService, parent, collectionType, resolvers));
+ items.AddRange(ResolveFileList(result.ExtraFiles, directoryService, parent, collectionType, resolvers, libraryOptions));
return items;
}
}
}
- return ResolveFileList(fileList, directoryService, parent, collectionType, resolvers);
+ return ResolveFileList(fileList, directoryService, parent, collectionType, resolvers, libraryOptions);
}
- private IEnumerable<BaseItem> ResolveFileList(IEnumerable<FileSystemMetadata> fileList, IDirectoryService directoryService, Folder parent, string collectionType, IItemResolver[] resolvers)
+ private IEnumerable<BaseItem> ResolveFileList(IEnumerable<FileSystemMetadata> fileList,
+ IDirectoryService directoryService,
+ Folder parent,
+ string collectionType,
+ IItemResolver[] resolvers,
+ LibraryOptions libraryOptions)
{
return fileList.Select(f =>
{
try
{
- return ResolvePath(f, directoryService, resolvers, parent, collectionType);
+ return ResolvePath(f, directoryService, resolvers, parent, collectionType, libraryOptions);
}
catch (Exception ex)
{
@@ -813,7 +829,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{Person}.</returns>
public Person GetPerson(string name)
{
- return GetItemByName<Person>(ConfigurationManager.ApplicationPaths.PeoplePath, name);
+ return CreateItemByName<Person>(Person.GetPath(name), name);
}
/// <summary>
@@ -823,7 +839,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{Studio}.</returns>
public Studio GetStudio(string name)
{
- return GetItemByName<Studio>(ConfigurationManager.ApplicationPaths.StudioPath, name);
+ return CreateItemByName<Studio>(Studio.GetPath(name), name);
}
/// <summary>
@@ -833,7 +849,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{Genre}.</returns>
public Genre GetGenre(string name)
{
- return GetItemByName<Genre>(ConfigurationManager.ApplicationPaths.GenrePath, name);
+ return CreateItemByName<Genre>(Genre.GetPath(name), name);
}
/// <summary>
@@ -843,7 +859,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{MusicGenre}.</returns>
public MusicGenre GetMusicGenre(string name)
{
- return GetItemByName<MusicGenre>(ConfigurationManager.ApplicationPaths.MusicGenrePath, name);
+ return CreateItemByName<MusicGenre>(MusicGenre.GetPath(name), name);
}
/// <summary>
@@ -853,15 +869,10 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{GameGenre}.</returns>
public GameGenre GetGameGenre(string name)
{
- return GetItemByName<GameGenre>(ConfigurationManager.ApplicationPaths.GameGenrePath, name);
+ return CreateItemByName<GameGenre>(GameGenre.GetPath(name), name);
}
/// <summary>
- /// The us culture
- /// </summary>
- private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
-
- /// <summary>
/// Gets a Year
/// </summary>
/// <param name="value">The value.</param>
@@ -874,19 +885,9 @@ namespace MediaBrowser.Server.Implementations.Library
throw new ArgumentOutOfRangeException("Years less than or equal to 0 are invalid.");
}
- return GetItemByName<Year>(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture));
- }
+ var name = value.ToString(CultureInfo.InvariantCulture);
- /// <summary>
- /// Gets the artists path.
- /// </summary>
- /// <value>The artists path.</value>
- public string ArtistsPath
- {
- get
- {
- return Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath, "artists");
- }
+ return CreateItemByName<Year>(Year.GetPath(name), name);
}
/// <summary>
@@ -896,48 +897,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{Genre}.</returns>
public MusicArtist GetArtist(string name)
{
- return GetItemByName<MusicArtist>(ArtistsPath, name);
- }
-
- private T GetItemByName<T>(string path, string name)
- where T : BaseItem, new()
- {
- if (string.IsNullOrWhiteSpace(path))
- {
- throw new ArgumentNullException("path");
- }
-
- if (string.IsNullOrWhiteSpace(name))
- {
- throw new ArgumentNullException("name");
- }
-
- // Trim the period at the end because windows will have a hard time with that
- var validFilename = _fileSystem.GetValidFilename(name)
- .Trim()
- .TrimEnd('.');
-
- string subFolderPrefix = null;
-
- var type = typeof(T);
-
- if (type == typeof(Person))
- {
- var subFolderIndex = 0;
-
- while (!char.IsLetterOrDigit(validFilename[subFolderIndex]))
- {
- subFolderIndex++;
- }
-
- subFolderPrefix = validFilename.Substring(subFolderIndex, 1);
- }
-
- var fullPath = string.IsNullOrEmpty(subFolderPrefix) ?
- Path.Combine(path, validFilename) :
- Path.Combine(path, subFolderPrefix, validFilename);
-
- return CreateItemByName<T>(fullPath, name);
+ return CreateItemByName<MusicArtist>(MusicArtist.GetPath(name), name);
}
private T CreateItemByName<T>(string path, string name)
@@ -1207,7 +1167,7 @@ namespace MediaBrowser.Server.Implementations.Library
.Select(dir => GetVirtualFolderInfo(dir, topLibraryFolders));
}
- private VirtualFolderInfo GetVirtualFolderInfo(string dir, List<BaseItem> collectionFolders)
+ private VirtualFolderInfo GetVirtualFolderInfo(string dir, List<BaseItem> allCollectionFolders)
{
var info = new VirtualFolderInfo
{
@@ -1221,7 +1181,7 @@ namespace MediaBrowser.Server.Implementations.Library
CollectionType = GetCollectionType(dir)
};
- var libraryFolder = collectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase));
+ var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase));
if (libraryFolder != null && libraryFolder.HasImage(ImageType.Primary))
{
@@ -1233,6 +1193,12 @@ namespace MediaBrowser.Server.Implementations.Library
info.ItemId = libraryFolder.Id.ToString("N");
}
+ var collectionFolder = libraryFolder as CollectionFolder;
+ if (collectionFolder != null)
+ {
+ info.LibraryOptions = collectionFolder.GetLibraryOptions();
+ }
+
return info;
}
@@ -1385,6 +1351,17 @@ namespace MediaBrowser.Server.Implementations.Library
return ItemRepository.GetMusicGenres(query);
}
+ public QueryResult<Tuple<BaseItem, ItemCounts>> GetAllArtists(InternalItemsQuery query)
+ {
+ if (query.User != null)
+ {
+ AddUserToQuery(query, query.User);
+ }
+
+ SetTopParentOrAncestorIds(query);
+ return ItemRepository.GetAllArtists(query);
+ }
+
public QueryResult<Tuple<BaseItem, ItemCounts>> GetArtists(InternalItemsQuery query)
{
if (query.User != null)
@@ -1488,7 +1465,12 @@ namespace MediaBrowser.Server.Implementations.Library
private void AddUserToQuery(InternalItemsQuery query, User user)
{
- if (query.AncestorIds.Length == 0 && !query.ParentId.HasValue && query.ChannelIds.Length == 0 && query.TopParentIds.Length == 0 && string.IsNullOrWhiteSpace(query.AncestorWithPresentationUniqueKey))
+ if (query.AncestorIds.Length == 0 &&
+ !query.ParentId.HasValue &&
+ query.ChannelIds.Length == 0 &&
+ query.TopParentIds.Length == 0 &&
+ string.IsNullOrWhiteSpace(query.AncestorWithPresentationUniqueKey)
+ && query.ItemIds.Length == 0)
{
var userViews = _userviewManager().GetUserViews(new UserViewQuery
{
@@ -1880,6 +1862,15 @@ namespace MediaBrowser.Server.Implementations.Library
.Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path, StringComparer.OrdinalIgnoreCase));
}
+ public LibraryOptions GetLibraryOptions(BaseItem item)
+ {
+ var collectionFolder = GetCollectionFolders(item)
+ .OfType<CollectionFolder>()
+ .FirstOrDefault();
+
+ return collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions();
+ }
+
public string GetContentType(BaseItem item)
{
string configuredContentType = GetConfiguredContentType(item, false);
@@ -2231,18 +2222,28 @@ namespace MediaBrowser.Server.Implementations.Library
return item;
}
- public bool IsVideoFile(string path)
+ public bool IsVideoFile(string path, LibraryOptions libraryOptions)
{
- var resolver = new VideoResolver(GetNamingOptions(), new PatternsLogger());
+ var resolver = new VideoResolver(GetNamingOptions(libraryOptions), new PatternsLogger());
return resolver.IsVideoFile(path);
}
- public bool IsAudioFile(string path)
+ public bool IsVideoFile(string path)
{
- var parser = new AudioFileParser(GetNamingOptions());
+ return IsVideoFile(path, new LibraryOptions());
+ }
+
+ public bool IsAudioFile(string path, LibraryOptions libraryOptions)
+ {
+ var parser = new AudioFileParser(GetNamingOptions(libraryOptions));
return parser.IsAudioFile(path);
}
+ public bool IsAudioFile(string path)
+ {
+ return IsAudioFile(path, new LibraryOptions());
+ }
+
public int? GetSeasonNumberFromPath(string path)
{
return new SeasonPathParser(GetNamingOptions(), new RegexProvider()).Parse(path, true, true).SeasonNumber;
@@ -2369,19 +2370,24 @@ namespace MediaBrowser.Server.Implementations.Library
public NamingOptions GetNamingOptions()
{
+ return GetNamingOptions(new LibraryOptions());
+ }
+
+ public NamingOptions GetNamingOptions(LibraryOptions libraryOptions)
+ {
var options = new ExtendedNamingOptions();
// These cause apps to have problems
options.AudioFileExtensions.Remove(".m3u");
options.AudioFileExtensions.Remove(".wpl");
- if (!ConfigurationManager.Configuration.EnableAudioArchiveFiles)
+ if (!libraryOptions.EnableArchiveMediaFiles)
{
options.AudioFileExtensions.Remove(".rar");
options.AudioFileExtensions.Remove(".zip");
}
- if (!ConfigurationManager.Configuration.EnableVideoArchiveFiles)
+ if (!libraryOptions.EnableArchiveMediaFiles)
{
options.VideoFileExtensions.Remove(".rar");
options.VideoFileExtensions.Remove(".zip");
@@ -2432,7 +2438,7 @@ namespace MediaBrowser.Server.Implementations.Library
new GenericVideoResolver<Trailer>(this)
};
- return ResolvePaths(files, directoryService, null, null, resolvers)
+ return ResolvePaths(files, directoryService, null, new LibraryOptions(), null, resolvers)
.OfType<Trailer>()
.Select(video =>
{
@@ -2476,7 +2482,7 @@ namespace MediaBrowser.Server.Implementations.Library
files.AddRange(currentVideo.Extras.Where(i => !string.Equals(i.ExtraType, "trailer", StringComparison.OrdinalIgnoreCase)).Select(i => _fileSystem.GetFileInfo(i.Path)));
}
- return ResolvePaths(files, directoryService, null, null)
+ return ResolvePaths(files, directoryService, null, new LibraryOptions(), null)
.OfType<Video>()
.Select(video =>
{
@@ -2605,13 +2611,6 @@ namespace MediaBrowser.Server.Implementations.Library
return ItemRepository.GetPeopleNames(query);
}
- public List<PersonInfo> GetAllPeople()
- {
- return GetPeople(new InternalPeopleQuery())
- .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
- .ToList();
- }
-
public Task UpdatePeople(BaseItem item, List<PersonInfo> people)
{
if (!item.SupportsPeople)
@@ -2661,7 +2660,7 @@ namespace MediaBrowser.Server.Implementations.Library
throw new InvalidOperationException();
}
- public void AddVirtualFolder(string name, string collectionType, string[] mediaPaths, bool refreshLibrary)
+ public void AddVirtualFolder(string name, string collectionType, string[] mediaPaths, LibraryOptions options, bool refreshLibrary)
{
if (string.IsNullOrWhiteSpace(name))
{
@@ -2704,6 +2703,8 @@ namespace MediaBrowser.Server.Implementations.Library
}
}
+ CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
+
if (mediaPaths != null)
{
foreach (var path in mediaPaths)
diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs
index 4f3fe1bf3..4a533ff93 100644
--- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs
@@ -278,8 +278,7 @@ namespace MediaBrowser.Server.Implementations.Library
}
var preferredSubs = string.IsNullOrEmpty(user.Configuration.SubtitleLanguagePreference)
- ? new List<string> { }
- : new List<string> { user.Configuration.SubtitleLanguagePreference };
+ ? new List<string>() : new List<string> { user.Configuration.SubtitleLanguagePreference };
var defaultAudioIndex = source.DefaultAudioStreamIndex;
var audioLangage = defaultAudioIndex == null
@@ -446,8 +445,31 @@ namespace MediaBrowser.Server.Implementations.Library
}
}
+ private async Task CloseLiveStreamWithProvider(IMediaSourceProvider provider, string streamId, CancellationToken cancellationToken)
+ {
+ _logger.Info("Closing live stream {0} with provider {1}", streamId, provider.GetType().Name);
+
+ try
+ {
+ await provider.CloseMediaSource(streamId, cancellationToken).ConfigureAwait(false);
+ }
+ catch (NotImplementedException)
+ {
+
+ }
+ catch (Exception ex)
+ {
+ _logger.ErrorException("Error closing live stream {0}", ex, streamId);
+ }
+ }
+
public async Task CloseLiveStream(string id, CancellationToken cancellationToken)
{
+ if (string.IsNullOrWhiteSpace(id))
+ {
+ throw new ArgumentNullException("id");
+ }
+
await _liveStreamSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
try
@@ -459,7 +481,7 @@ namespace MediaBrowser.Server.Implementations.Library
{
var tuple = GetProvider(id);
- await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false);
+ await CloseLiveStreamWithProvider(tuple.Item1, tuple.Item2, cancellationToken).ConfigureAwait(false);
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
index b4cda39cd..039a17100 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
@@ -37,14 +37,16 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
if (!args.IsDirectory)
{
- if (_libraryManager.IsAudioFile(args.Path))
+ var libraryOptions = args.GetLibraryOptions();
+
+ if (_libraryManager.IsAudioFile(args.Path, libraryOptions))
{
var collectionType = args.GetCollectionType();
var isMixed = string.IsNullOrWhiteSpace(collectionType);
// For conflicting extensions, give priority to videos
- if (isMixed && _libraryManager.IsVideoFile(args.Path))
+ if (isMixed && _libraryManager.IsVideoFile(args.Path, libraryOptions))
{
return null;
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs
index 9f8293cb5..1a8295800 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs
@@ -10,6 +10,8 @@ using System;
using System.Collections.Generic;
using System.IO;
using CommonIO;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
{
@@ -72,12 +74,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
/// <summary>
/// Determine if the supplied file data points to a music album
/// </summary>
- /// <param name="path">The path.</param>
- /// <param name="directoryService">The directory service.</param>
- /// <returns><c>true</c> if [is music album] [the specified data]; otherwise, <c>false</c>.</returns>
- public bool IsMusicAlbum(string path, IDirectoryService directoryService)
+ public bool IsMusicAlbum(string path, IDirectoryService directoryService, LibraryOptions libraryOptions)
{
- return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService, _logger, _fileSystem, _libraryManager);
+ return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService, _logger, _fileSystem, libraryOptions, _libraryManager);
}
/// <summary>
@@ -91,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
if (args.IsDirectory)
{
//if (args.Parent is MusicArtist) return true; //saves us from testing children twice
- if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService, _logger, _fileSystem, _libraryManager)) return true;
+ if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService, _logger, _fileSystem, args.GetLibraryOptions(), _libraryManager)) return true;
}
return false;
@@ -100,18 +99,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
/// <summary>
/// Determine if the supplied list contains what we should consider music
/// </summary>
- /// <param name="list">The list.</param>
- /// <param name="allowSubfolders">if set to <c>true</c> [allow subfolders].</param>
- /// <param name="directoryService">The directory service.</param>
- /// <param name="logger">The logger.</param>
- /// <param name="fileSystem">The file system.</param>
- /// <param name="libraryManager">The library manager.</param>
- /// <returns><c>true</c> if the specified list contains music; otherwise, <c>false</c>.</returns>
private bool ContainsMusic(IEnumerable<FileSystemMetadata> list,
bool allowSubfolders,
IDirectoryService directoryService,
ILogger logger,
IFileSystem fileSystem,
+ LibraryOptions libraryOptions,
ILibraryManager libraryManager)
{
var discSubfolderCount = 0;
@@ -124,11 +117,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
if (allowSubfolders)
{
var path = fileSystemInfo.FullName;
- var isMultiDisc = IsMultiDiscFolder(path);
+ var isMultiDisc = IsMultiDiscFolder(path, libraryOptions);
if (isMultiDisc)
{
- var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
+ var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryOptions, libraryManager);
if (hasMusic)
{
@@ -138,7 +131,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
}
else
{
- var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
+ var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryOptions, libraryManager);
if (hasMusic)
{
@@ -151,7 +144,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
var fullName = fileSystemInfo.FullName;
- if (libraryManager.IsAudioFile(fullName))
+ if (libraryManager.IsAudioFile(fullName, libraryOptions))
{
return true;
}
@@ -165,9 +158,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
return discSubfolderCount > 0;
}
- private bool IsMultiDiscFolder(string path)
+ private bool IsMultiDiscFolder(string path, LibraryOptions libraryOptions)
{
- var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
+ var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions(libraryOptions);
var parser = new AlbumParser(namingOptions, new PatternsLogger());
var result = parser.ParseMultiPart(path);
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
index e3c991e7e..e819af06f 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
@@ -72,7 +72,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
var albumResolver = new MusicAlbumResolver(_logger, _fileSystem, _libraryManager);
// If we contain an album assume we are an artist folder
- return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => albumResolver.IsMusicAlbum(i.FullName, directoryService)) ? new MusicArtist() : null;
+ return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => albumResolver.IsMusicAlbum(i.FullName, directoryService, args.GetLibraryOptions())) ? new MusicArtist() : null;
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
index 703a33856..d0042a990 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
@@ -133,7 +133,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
return null;
}
- if (LibraryManager.IsVideoFile(args.Path) || videoInfo.IsStub)
+ if (LibraryManager.IsVideoFile(args.Path, args.GetLibraryOptions()) || videoInfo.IsStub)
{
var path = args.Path;
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index 37d1e163f..ee9533d2a 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -48,6 +48,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
string collectionType,
IDirectoryService directoryService)
{
+ if (parent != null && parent.Path != null && parent.Path.IndexOf("disney", StringComparison.OrdinalIgnoreCase) != -1)
+ {
+ var b = true;
+ var a = b;
+ }
+
var result = ResolveMultipleInternal(parent, files, collectionType, directoryService);
if (result != null)
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs
index 9dd30edde..3f9475480 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs
@@ -6,6 +6,8 @@ using System;
using System.IO;
using System.Linq;
using CommonIO;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Server.Implementations.Library.Resolvers
{
@@ -32,15 +34,16 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
// Must be an image file within a photo collection
var collectionType = args.GetCollectionType();
+
if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase) ||
- string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
+ (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && args.GetLibraryOptions().EnablePhotos))
{
if (IsImageFile(args.Path, _imageProcessor))
{
var filename = Path.GetFileNameWithoutExtension(args.Path);
// Make sure the image doesn't belong to a video file
- if (args.DirectoryService.GetFiles(Path.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(i, filename)))
+ if (args.DirectoryService.GetFiles(Path.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(args.GetLibraryOptions(), i, filename)))
{
return null;
}
@@ -56,9 +59,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
return null;
}
- private bool IsOwnedByMedia(FileSystemMetadata file, string imageFilename)
+ private bool IsOwnedByMedia(LibraryOptions libraryOptions, FileSystemMetadata file, string imageFilename)
{
- if (_libraryManager.IsVideoFile(file.FullName) && imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file.Name), StringComparison.OrdinalIgnoreCase))
+ if (_libraryManager.IsVideoFile(file.FullName, libraryOptions) && imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file.Name), StringComparison.OrdinalIgnoreCase))
{
return true;
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
index 144f788a7..7bb66ed89 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
@@ -50,7 +50,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
{
return new CollectionFolder
{
- CollectionType = GetCollectionType(args)
+ CollectionType = GetCollectionType(args),
+ PhysicalLocationsList = args.PhysicalLocations.ToList()
};
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
index 7b8832c59..6edc4a009 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
@@ -1,5 +1,4 @@
using System;
-using System.IO;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using System.Linq;
@@ -57,10 +56,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
if (series != null)
{
episode.SeriesId = series.Id;
+ episode.SeriesName = series.Name;
+ episode.SeriesSortName = series.SortName;
}
if (season != null)
{
episode.SeasonId = season.Id;
+ episode.SeasonName = season.Name;
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
index eeac1345e..fc4929748 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
@@ -43,9 +43,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
var season = new Season
{
IndexNumber = new SeasonPathParser(namingOptions, new RegexProvider()).Parse(args.Path, true, true).SeasonNumber,
- SeriesId = series.Id
+ SeriesId = series.Id,
+ SeriesSortName = series.SortName,
+ SeriesName = series.Name
};
-
+
if (season.IndexNumber.HasValue && season.IndexNumber.Value == 0)
{
season.Name = _config.Configuration.SeasonZeroDisplayName;
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
index 45ba2ddbb..aefb29f1a 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
@@ -12,6 +12,8 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using CommonIO;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
{
@@ -83,7 +85,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
{
return null;
}
- if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager, false))
+ if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager, args.GetLibraryOptions(), false))
{
return new Series
{
@@ -104,6 +106,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
IFileSystem fileSystem,
ILogger logger,
ILibraryManager libraryManager,
+ LibraryOptions libraryOptions,
bool isTvContentType)
{
foreach (var child in fileSystemChildren)
@@ -134,7 +137,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
else
{
string fullName = child.FullName;
- if (libraryManager.IsVideoFile(fullName))
+ if (libraryManager.IsVideoFile(fullName, libraryOptions))
{
if (isTvContentType)
{
diff --git a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
index cf6f070d0..a6d6b5cb8 100644
--- a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
+++ b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
@@ -166,12 +166,12 @@ namespace MediaBrowser.Server.Implementations.Library
ExcludeItemTypes = excludeItemTypes.ToArray(),
IncludeItemTypes = includeItemTypes.ToArray(),
Limit = query.Limit,
- IncludeItemsByName = true
-
+ IncludeItemsByName = true,
+ IsVirtualItem = false
});
// Add search hints based on item name
- hints.AddRange(mediaItems.Where(IncludeInSearch).Select(item =>
+ hints.AddRange(mediaItems.Select(item =>
{
var index = GetIndex(item.Name, searchTerm, terms);
@@ -187,20 +187,6 @@ namespace MediaBrowser.Server.Implementations.Library
return Task.FromResult(returnValue);
}
- private bool IncludeInSearch(BaseItem item)
- {
- var episode = item as Episode;
-
- if (episode != null)
- {
- if (episode.IsMissingEpisode)
- {
- return false;
- }
- }
- return true;
- }
-
/// <summary>
/// Gets the index.
/// </summary>
diff --git a/MediaBrowser.Server.Implementations/Library/UserDataManager.cs b/MediaBrowser.Server.Implementations/Library/UserDataManager.cs
index 715f3c522..307cf4cd2 100644
--- a/MediaBrowser.Server.Implementations/Library/UserDataManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/UserDataManager.cs
@@ -10,7 +10,6 @@ using MediaBrowser.Model.Logging;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
index 319e715c3..5fffa3d1f 100644
--- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
@@ -283,7 +283,7 @@ namespace MediaBrowser.Server.Implementations.Library
ExcludeItemTypes = excludeItemTypes,
ExcludeLocationTypes = new[] { LocationType.Virtual },
Limit = limit * 5,
- ExcludeSourceTypes = parentIds.Length == 0 ? new[] { SourceType.Channel, SourceType.LiveTV } : new SourceType[] { },
+ SourceTypes = parentIds.Length == 0 ? new[] { SourceType.Library } : new SourceType[] { },
IsPlayed = request.IsPlayed
}, parentIds);
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs
index 079867ddd..91b035a35 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs
@@ -3,6 +3,7 @@ using MediaBrowser.Model.Logging;
using System;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Persistence;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
@@ -16,15 +17,17 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// </summary>
private readonly ILibraryManager _libraryManager;
private readonly ILogger _logger;
+ private readonly IItemRepository _itemRepo;
/// <summary>
/// Initializes a new instance of the <see cref="ArtistsPostScanTask" /> class.
/// </summary>
/// <param name="libraryManager">The library manager.</param>
- public ArtistsPostScanTask(ILibraryManager libraryManager, ILogger logger)
+ public ArtistsPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{
_libraryManager = libraryManager;
_logger = logger;
+ _itemRepo = itemRepo;
}
/// <summary>
@@ -35,7 +38,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return new ArtistsValidator(_libraryManager, _logger).Run(progress, cancellationToken);
+ return new ArtistsValidator(_libraryManager, _logger, _itemRepo).Run(progress, cancellationToken);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
index 2b68f98ca..3dcdbeae9 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
@@ -6,6 +6,8 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Persistence;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
@@ -23,16 +25,18 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// The _logger
/// </summary>
private readonly ILogger _logger;
+ private readonly IItemRepository _itemRepo;
/// <summary>
/// Initializes a new instance of the <see cref="ArtistsPostScanTask" /> class.
/// </summary>
/// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param>
- public ArtistsValidator(ILibraryManager libraryManager, ILogger logger)
+ public ArtistsValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{
_libraryManager = libraryManager;
_logger = logger;
+ _itemRepo = itemRepo;
}
/// <summary>
@@ -43,36 +47,38 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- var allSongs = _libraryManager.RootFolder
- .GetRecursiveChildren(i => !i.IsFolder && i is IHasArtist)
- .Cast<IHasArtist>()
- .ToList();
-
- var allArtists = _libraryManager.GetArtists(allSongs).ToList();
+ var names = _itemRepo.GetAllArtistNames();
var numComplete = 0;
- var numArtists = allArtists.Count;
+ var count = names.Count;
- foreach (var artistItem in allArtists)
+ foreach (var name in names)
{
- cancellationToken.ThrowIfCancellationRequested();
-
try
{
- await artistItem.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ var item = _libraryManager.GetArtist(name);
+
+ await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ }
+ catch (OperationCanceledException)
+ {
+ // Don't clutter the log
+ break;
}
- catch (IOException ex)
+ catch (Exception ex)
{
- _logger.ErrorException("Error validating Artist {0}", ex, artistItem.Name);
+ _logger.ErrorException("Error refreshing {0}", ex, name);
}
- // Update progress
numComplete++;
double percent = numComplete;
- percent /= numArtists;
+ percent /= count;
+ percent *= 100;
- progress.Report(100 * percent);
+ progress.Report(percent);
}
+
+ progress.Report(100);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs
index 8be2e436f..f3891180e 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs
@@ -3,6 +3,7 @@ using MediaBrowser.Model.Logging;
using System;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Persistence;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
@@ -16,16 +17,18 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// </summary>
private readonly ILibraryManager _libraryManager;
private readonly ILogger _logger;
+ private readonly IItemRepository _itemRepo;
/// <summary>
/// Initializes a new instance of the <see cref="GameGenresPostScanTask" /> class.
/// </summary>
/// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param>
- public GameGenresPostScanTask(ILibraryManager libraryManager, ILogger logger)
+ public GameGenresPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{
_libraryManager = libraryManager;
_logger = logger;
+ _itemRepo = itemRepo;
}
/// <summary>
@@ -36,7 +39,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return new GameGenresValidator(_libraryManager, _logger).Run(progress, cancellationToken);
+ return new GameGenresValidator(_libraryManager, _logger, _itemRepo).Run(progress, cancellationToken);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
index 826154fac..b06c0b3b9 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
@@ -1,11 +1,11 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Persistence;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
@@ -20,11 +20,13 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// The _logger
/// </summary>
private readonly ILogger _logger;
+ private readonly IItemRepository _itemRepo;
- public GameGenresValidator(ILibraryManager libraryManager, ILogger logger)
+ public GameGenresValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{
_libraryManager = libraryManager;
_logger = logger;
+ _itemRepo = itemRepo;
}
/// <summary>
@@ -35,25 +37,18 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- var items = _libraryManager.RootFolder.GetRecursiveChildren(i => i is Game)
- .SelectMany(i => i.Genres)
- .DistinctNames()
- .ToList();
+ var names = _itemRepo.GetGameGenreNames();
var numComplete = 0;
- var count = items.Count;
+ var count = names.Count;
- var validIds = new List<Guid>();
-
- foreach (var name in items)
+ foreach (var name in names)
{
try
{
- var itemByName = _libraryManager.GetGameGenre(name);
-
- validIds.Add(itemByName.Id);
+ var item = _libraryManager.GetGameGenre(name);
- await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
@@ -73,28 +68,6 @@ 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/GenresPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs
index a1c34676c..ed2429769 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs
@@ -2,6 +2,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Server.Implementations.Library.Validators
@@ -13,16 +14,18 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// </summary>
private readonly ILibraryManager _libraryManager;
private readonly ILogger _logger;
+ private readonly IItemRepository _itemRepo;
/// <summary>
/// Initializes a new instance of the <see cref="ArtistsPostScanTask" /> class.
/// </summary>
/// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param>
- public GenresPostScanTask(ILibraryManager libraryManager, ILogger logger)
+ public GenresPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{
_libraryManager = libraryManager;
_logger = logger;
+ _itemRepo = itemRepo;
}
/// <summary>
@@ -33,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return new GenresValidator(_libraryManager, _logger).Run(progress, cancellationToken);
+ return new GenresValidator(_libraryManager, _logger, _itemRepo).Run(progress, cancellationToken);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
index 11d4c9f16..f35bb5136 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
@@ -1,5 +1,4 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
@@ -7,6 +6,7 @@ using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Persistence;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
@@ -16,16 +16,18 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
+ private readonly IItemRepository _itemRepo;
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
- public GenresValidator(ILibraryManager libraryManager, ILogger logger)
+ public GenresValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{
_libraryManager = libraryManager;
_logger = logger;
+ _itemRepo = itemRepo;
}
/// <summary>
@@ -36,25 +38,18 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- var items = _libraryManager.RootFolder.GetRecursiveChildren(i => !(i is IHasMusicGenres) && !(i is Game))
- .SelectMany(i => i.Genres)
- .DistinctNames()
- .ToList();
+ var names = _itemRepo.GetGenreNames();
var numComplete = 0;
- var count = items.Count;
+ var count = names.Count;
- var validIds = new List<Guid>();
-
- foreach (var name in items)
+ foreach (var name in names)
{
try
{
- var itemByName = _libraryManager.GetGenre(name);
+ var item = _libraryManager.GetGenre(name);
- validIds.Add(itemByName.Id);
-
- await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
@@ -74,28 +69,6 @@ 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/MusicGenresPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs
index dbcab0832..777532ff8 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs
@@ -3,6 +3,7 @@ using MediaBrowser.Model.Logging;
using System;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Persistence;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
@@ -16,16 +17,18 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// </summary>
private readonly ILibraryManager _libraryManager;
private readonly ILogger _logger;
+ private readonly IItemRepository _itemRepo;
/// <summary>
/// Initializes a new instance of the <see cref="ArtistsPostScanTask" /> class.
/// </summary>
/// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param>
- public MusicGenresPostScanTask(ILibraryManager libraryManager, ILogger logger)
+ public MusicGenresPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{
_libraryManager = libraryManager;
_logger = logger;
+ _itemRepo = itemRepo;
}
/// <summary>
@@ -36,7 +39,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return new MusicGenresValidator(_libraryManager, _logger).Run(progress, cancellationToken);
+ return new MusicGenresValidator(_libraryManager, _logger, _itemRepo).Run(progress, cancellationToken);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
index 0c8c56f5a..2be99f106 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
@@ -1,12 +1,12 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Audio;
+using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Persistence;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
@@ -21,11 +21,13 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// The _logger
/// </summary>
private readonly ILogger _logger;
+ private readonly IItemRepository _itemRepo;
- public MusicGenresValidator(ILibraryManager libraryManager, ILogger logger)
+ public MusicGenresValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{
_libraryManager = libraryManager;
_logger = logger;
+ _itemRepo = itemRepo;
}
/// <summary>
@@ -36,25 +38,18 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- var items = _libraryManager.RootFolder.GetRecursiveChildren(i => i is IHasMusicGenres)
- .SelectMany(i => i.Genres)
- .DistinctNames()
- .ToList();
+ var names = _itemRepo.GetMusicGenreNames();
var numComplete = 0;
- var count = items.Count;
+ var count = names.Count;
- var validIds = new List<Guid>();
-
- foreach (var name in items)
+ foreach (var name in names)
{
try
{
- var itemByName = _libraryManager.GetMusicGenre(name);
-
- validIds.Add(itemByName.Id);
+ var item = _libraryManager.GetMusicGenre(name);
- await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
@@ -74,28 +69,6 @@ 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 5c43f2e13..d90b9615b 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
@@ -89,7 +89,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var peopleOptions = _config.Configuration.PeopleMetadataOptions;
- var people = _libraryManager.GetAllPeople();
+ var people = _libraryManager.GetPeople(new InternalPeopleQuery());
var dict = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
@@ -112,8 +112,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
}
var numComplete = 0;
- var validIds = new List<Guid>();
-
+
+ _logger.Debug("Will refresh {0} people", dict.Count);
+
+ var numPeople = dict.Count;
+
foreach (var person in dict)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -122,8 +125,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
{
var item = _libraryManager.GetPerson(person.Key);
- validIds.Add(item.Id);
-
var hasMetdata = !string.IsNullOrWhiteSpace(item.Overview);
var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 30;
@@ -138,7 +139,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var options = new MetadataRefreshOptions(_fileSystem)
{
MetadataRefreshMode = person.Value ? defaultMetadataRefreshMode : MetadataRefreshMode.ValidationOnly,
- ImageRefreshMode = person.Value ? imageRefreshMode : ImageRefreshMode.ValidationOnly
+ ImageRefreshMode = person.Value ? imageRefreshMode : ImageRefreshMode.ValidationOnly,
+ ForceSave = performFullRefresh
};
await item.RefreshMetadata(options, cancellationToken).ConfigureAwait(false);
@@ -155,36 +157,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
// Update progress
numComplete++;
double percent = numComplete;
- percent /= people.Count;
+ percent /= numPeople;
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);
-
- if (item != null)
- {
- 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/StudiosPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs
index 0ff609da1..77c6d5146 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs
@@ -3,6 +3,7 @@ using MediaBrowser.Model.Logging;
using System;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Persistence;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
@@ -17,15 +18,17 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
private readonly ILibraryManager _libraryManager;
private readonly ILogger _logger;
+ private readonly IItemRepository _itemRepo;
/// <summary>
/// Initializes a new instance of the <see cref="ArtistsPostScanTask" /> class.
/// </summary>
/// <param name="libraryManager">The library manager.</param>
- public StudiosPostScanTask(ILibraryManager libraryManager, ILogger logger)
+ public StudiosPostScanTask(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{
_libraryManager = libraryManager;
_logger = logger;
+ _itemRepo = itemRepo;
}
/// <summary>
@@ -36,7 +39,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return new StudiosValidator(_libraryManager, _logger).Run(progress, cancellationToken);
+ return new StudiosValidator(_libraryManager, _logger, _itemRepo).Run(progress, cancellationToken);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
index c1803b5e4..a19b8158a 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
@@ -1,11 +1,11 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Persistence;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
@@ -16,15 +16,17 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// </summary>
private readonly ILibraryManager _libraryManager;
+ private readonly IItemRepository _itemRepo;
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
- public StudiosValidator(ILibraryManager libraryManager, ILogger logger)
+ public StudiosValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
{
_libraryManager = libraryManager;
_logger = logger;
+ _itemRepo = itemRepo;
}
/// <summary>
@@ -35,25 +37,18 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- var items = _libraryManager.RootFolder.GetRecursiveChildren(i => true)
- .SelectMany(i => i.Studios)
- .DistinctNames()
- .ToList();
+ var names = _itemRepo.GetStudioNames();
var numComplete = 0;
- var count = items.Count;
+ var count = names.Count;
- var validIds = new List<Guid>();
-
- foreach (var name in items)
+ foreach (var name in names)
{
try
{
- var itemByName = _libraryManager.GetStudio(name);
-
- validIds.Add(itemByName.Id);
+ var item = _libraryManager.GetStudio(name);
- await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs
index 7f52a4506..164b14223 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs
@@ -1,7 +1,6 @@
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;