diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/FileOrganization')
| -rw-r--r-- | MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs | 34 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs | 10 |
2 files changed, 28 insertions, 16 deletions
diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs index e45df3f4a..2109f8d59 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -116,7 +116,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization premiereDate, options, overwriteExisting, - false, + false, result, cancellationToken).ConfigureAwait(false); } @@ -202,7 +202,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization null, options, true, - request.RememberCorrection, + request.RememberCorrection, result, cancellationToken).ConfigureAwait(false); @@ -219,7 +219,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization DateTime? premiereDate, AutoOrganizeOptions options, bool overwriteExisting, - bool rememberCorrection, + bool rememberCorrection, FileOrganizationResult result, CancellationToken cancellationToken) { @@ -242,7 +242,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization premiereDate, options, overwriteExisting, - rememberCorrection, + rememberCorrection, result, cancellationToken); } @@ -255,7 +255,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization DateTime? premiereDate, AutoOrganizeOptions options, bool overwriteExisting, - bool rememberCorrection, + bool rememberCorrection, FileOrganizationResult result, CancellationToken cancellationToken) { @@ -304,7 +304,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization if (otherDuplicatePaths.Count > 0) { - var msg = string.Format("File '{0}' already exists as '{1}', stopping organization", sourcePath, otherDuplicatePaths); + var msg = string.Format("File '{0}' already exists as these:'{1}'. Stopping organization", sourcePath, string.Join("', '", otherDuplicatePaths)); _logger.Info(msg); result.Status = FileSortingStatus.SkippedExisting; result.StatusMessage = msg; @@ -356,6 +356,11 @@ namespace MediaBrowser.Server.Implementations.FileOrganization private void SaveSmartMatchString(string matchString, Series series, AutoOrganizeOptions options) { + if (string.IsNullOrEmpty(matchString) || matchString.Length < 3) + { + return; + } + SmartMatchInfo info = options.SmartMatchInfos.FirstOrDefault(i => string.Equals(i.ItemName, series.Name, StringComparison.OrdinalIgnoreCase)); if (info == null) @@ -536,7 +541,11 @@ namespace MediaBrowser.Server.Implementations.FileOrganization result.ExtractedName = nameWithoutYear; result.ExtractedYear = yearInName; - var series = _libraryManager.RootFolder.GetRecursiveChildren(i => i is Series) + var series = _libraryManager.GetItemList(new Controller.Entities.InternalItemsQuery + { + IncludeItemTypes = new[] { typeof(Series).Name }, + Recursive = true + }) .Cast<Series>() .Select(i => NameUtils.GetMatchScore(nameWithoutYear, yearInName, i)) .Where(i => i.Item2 > 0) @@ -550,10 +559,13 @@ namespace MediaBrowser.Server.Implementations.FileOrganization if (info != null) { - series = _libraryManager.RootFolder - .GetRecursiveChildren(i => i is Series) - .Cast<Series>() - .FirstOrDefault(i => string.Equals(i.Name, info.ItemName, StringComparison.OrdinalIgnoreCase)); + series = _libraryManager.GetItemList(new Controller.Entities.InternalItemsQuery + { + IncludeItemTypes = new[] { typeof(Series).Name }, + Recursive = true, + Name = info.ItemName + + }).Cast<Series>().FirstOrDefault(); } } diff --git a/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs b/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs index 0e8a60612..60d515e12 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs @@ -95,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization return _repo.Delete(resultId); } - private AutoOrganizeOptions GetAutoOrganizeptions() + private AutoOrganizeOptions GetAutoOrganizeOptions() { return _config.GetAutoOrganizeOptions(); } @@ -112,7 +112,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization var organizer = new EpisodeFileOrganizer(this, _config, _fileSystem, _logger, _libraryManager, _libraryMonitor, _providerManager); - await organizer.OrganizeEpisodeFile(result.OriginalPath, GetAutoOrganizeptions(), true, CancellationToken.None) + await organizer.OrganizeEpisodeFile(result.OriginalPath, GetAutoOrganizeOptions(), true, CancellationToken.None) .ConfigureAwait(false); } @@ -126,7 +126,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization var organizer = new EpisodeFileOrganizer(this, _config, _fileSystem, _logger, _libraryManager, _libraryMonitor, _providerManager); - await organizer.OrganizeWithCorrection(request, GetAutoOrganizeptions(), CancellationToken.None).ConfigureAwait(false); + await organizer.OrganizeWithCorrection(request, GetAutoOrganizeOptions(), CancellationToken.None).ConfigureAwait(false); } public QueryResult<SmartMatchInfo> GetSmartMatchInfos(FileOrganizationResultQuery query) @@ -136,7 +136,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization throw new ArgumentNullException("query"); } - var options = GetAutoOrganizeptions(); + var options = GetAutoOrganizeOptions(); var items = options.SmartMatchInfos.Skip(query.StartIndex ?? 0).Take(query.Limit ?? Int32.MaxValue).ToArray(); @@ -159,7 +159,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization throw new ArgumentNullException("matchString"); } - var options = GetAutoOrganizeptions(); + var options = GetAutoOrganizeOptions(); SmartMatchInfo info = options.SmartMatchInfos.FirstOrDefault(i => string.Equals(i.ItemName, itemName)); |
