diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-02-06 22:24:18 -0500 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2016-02-06 22:24:18 -0500 |
| commit | b398b4eaabad357027dbcf2a210edcada8a984fd (patch) | |
| tree | 9dad1e9409b6c1eb0f4110d4795ee276546aba6d /MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs | |
| parent | bc6c0bd0b7ec6f57651c21726f66f9cf7a69cba3 (diff) | |
| parent | c02635c2569b0dfe2144c337cc0f8591e55c528c (diff) | |
Merge pull request #1432 from softworkz/SeriesDetectionV2
Supersedes #1192: Auto-Organize - Added feature to remember/persist series matching in manual organization dialog
Diffstat (limited to 'MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs b/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs index 839a85adb..3dd6a9be0 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs @@ -11,6 +11,7 @@ using MediaBrowser.Model.Logging; using MediaBrowser.Model.Querying; using System; using System.IO; +using System.Linq; using System.Threading; using System.Threading.Tasks; using CommonIO; @@ -96,9 +97,9 @@ namespace MediaBrowser.Server.Implementations.FileOrganization return _repo.Delete(resultId); } - private TvFileOrganizationOptions GetTvOptions() + private AutoOrganizeOptions GetAutoOrganizeptions() { - return _config.GetAutoOrganizeOptions().TvOptions; + return _config.GetAutoOrganizeOptions(); } public async Task PerformOrganization(string resultId) @@ -113,7 +114,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization var organizer = new EpisodeFileOrganizer(this, _config, _fileSystem, _logger, _libraryManager, _libraryMonitor, _providerManager); - await organizer.OrganizeEpisodeFile(result.OriginalPath, GetTvOptions(), true, CancellationToken.None) + await organizer.OrganizeEpisodeFile(result.OriginalPath, GetAutoOrganizeptions(), true, CancellationToken.None) .ConfigureAwait(false); } @@ -127,7 +128,55 @@ namespace MediaBrowser.Server.Implementations.FileOrganization var organizer = new EpisodeFileOrganizer(this, _config, _fileSystem, _logger, _libraryManager, _libraryMonitor, _providerManager); - await organizer.OrganizeWithCorrection(request, GetTvOptions(), CancellationToken.None).ConfigureAwait(false); + await organizer.OrganizeWithCorrection(request, GetAutoOrganizeptions(), CancellationToken.None).ConfigureAwait(false); + } + + public QueryResult<SmartMatchInfo> GetSmartMatchInfos(FileOrganizationResultQuery query) + { + if (query == null) + { + throw new ArgumentNullException("query"); + } + + var options = GetAutoOrganizeptions(); + + var items = options.SmartMatchInfos.Skip(query.StartIndex ?? 0).Take(query.Limit ?? Int32.MaxValue); + + return new QueryResult<SmartMatchInfo>() + { + Items = items.ToArray(), + TotalRecordCount = items.Count() + }; + } + + public void DeleteSmartMatchEntry(string IdString, string matchString) + { + Guid Id; + + if (!Guid.TryParse(IdString, out Id)) + { + throw new ArgumentNullException("Id"); + } + + if (string.IsNullOrEmpty(matchString)) + { + throw new ArgumentNullException("matchString"); + } + + var options = GetAutoOrganizeptions(); + + SmartMatchInfo info = options.SmartMatchInfos.Find(i => i.Id == Id); + + if (info != null && info.MatchStrings.Contains(matchString)) + { + info.MatchStrings.Remove(matchString); + if (info.MatchStrings.Count == 0) + { + options.SmartMatchInfos.Remove(info); + } + + _config.SaveAutoOrganizeOptions(options); + } } } } |
