From b6c75e7e1b87830ec198823443a0879ddfe95259 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 21 Jul 2020 21:53:31 -0400 Subject: [PATCH] Fixed: Skip Flat Extra Files (Plex Naming) on Import Fixes #4630 --- .../DiskScanServiceTests/ScanFixture.cs | 18 ++++++++++++++++++ .../MediaFiles/DiskScanService.cs | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs index 4c7de1160..8728ae950 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs @@ -382,6 +382,24 @@ public void should_find_files_at_root_of_movie_folder() .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 2), _movie), Times.Once()); } + [Test] + public void should_exclude_inline_extra_files() + { + GivenMovieFolder(); + + GivenFiles(new List + { + Path.Combine(_movie.Path, "Avatar (2009).mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "Deleted Scenes-deleted.mkv").AsOsAgnostic(), + Path.Combine(_movie.Path, "The World of Pandora-other.mkv").AsOsAgnostic() + }); + + Subject.Scan(_movie); + + Mocker.GetMock() + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _movie), Times.Once()); + } + [Test] public void should_exclude_osx_metadata_files() { diff --git a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs index 6d0892df0..18dee9e40 100644 --- a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -64,6 +64,7 @@ public DiskScanService(IDiskProvider diskProvider, private static readonly Regex ExcludedExtrasSubFolderRegex = new Regex(@"(?:\\|\/|^)(?:extras|extrafanart|behind the scenes|deleted scenes|featurettes|interviews|scenes|sample[s]?|shorts|trailers)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(?:\\|\/|^)(?:@eadir|\.@__thumb|plex versions|\.[^\\/]+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex ExcludedExtraFilesRegex = new Regex(@"(-(trailer|other|behindthescenes|deleted|featurette|interview|scene|short)\.[^.]+$)", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex ExcludedFilesRegex = new Regex(@"^\._|^Thumbs\.db$", RegexOptions.Compiled | RegexOptions.IgnoreCase); public void Scan(Movie movie) @@ -179,7 +180,9 @@ public List FilterFiles(string basePath, IEnumerable files, bool if (filterExtras) { - filteredFiles = filteredFiles.Where(file => !ExcludedExtrasSubFolderRegex.IsMatch(basePath.GetRelativePath(file))).ToList(); + filteredFiles = filteredFiles.Where(file => !ExcludedExtrasSubFolderRegex.IsMatch(basePath.GetRelativePath(file))) + .Where(file => !ExcludedExtraFilesRegex.IsMatch(Path.GetFileName(file))) + .ToList(); } return filteredFiles;