From 19414912ad6b225c7e85b218a7a69b681f5026e1 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 27 Aug 2017 16:32:41 -0400 Subject: [PATCH] Cleanup Disk Scan Service (#69) * Cleanup Disk Scan Service * Fix Encoding, Change mp4 to flac --- .../FileSystem/FileSystemModule.cs | 2 +- .../Music/ArtistBulkImportModule.cs | 4 +- .../DiskScanServiceTests/ScanFixture.cs | 110 +++++++++--------- .../DownloadedEpisodesImportServiceFixture.cs | 8 +- .../NzbDrone.Core.Test.csproj | 2 +- ...ilesFixture.cs => GetAudioFilesFixture.cs} | 29 ++--- .../Clients/Blackhole/ScanWatchFolder.cs | 4 +- .../Extras/ExistingExtraFileService.cs | 22 ++-- .../MediaFiles/DiskScanService.cs | 45 +------ .../DownloadedEpisodesImportService.cs | 6 +- 10 files changed, 101 insertions(+), 131 deletions(-) rename src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/{GetVideoFilesFixture.cs => GetAudioFilesFixture.cs} (81%) diff --git a/src/NzbDrone.Api/FileSystem/FileSystemModule.cs b/src/NzbDrone.Api/FileSystem/FileSystemModule.cs index 67c2be7bd..392c3c0c5 100644 --- a/src/NzbDrone.Api/FileSystem/FileSystemModule.cs +++ b/src/NzbDrone.Api/FileSystem/FileSystemModule.cs @@ -66,7 +66,7 @@ namespace NzbDrone.Api.FileSystem return new string[0].AsResponse(); } - return _diskScanService.GetVideoFiles(path).Select(f => new { + return _diskScanService.GetAudioFiles(path).Select(f => new { Path = f, RelativePath = path.GetRelativePath(f), Name = Path.GetFileName(f) diff --git a/src/NzbDrone.Api/Music/ArtistBulkImportModule.cs b/src/NzbDrone.Api/Music/ArtistBulkImportModule.cs index d7678f72b..530a4b281 100644 --- a/src/NzbDrone.Api/Music/ArtistBulkImportModule.cs +++ b/src/NzbDrone.Api/Music/ArtistBulkImportModule.cs @@ -80,7 +80,7 @@ namespace NzbDrone.Api.Music return mappedArtist; } - var files = _diskScanService.GetMusicFiles(page.Path); + var files = _diskScanService.GetAudioFiles(page.Path); // Check for music files in directory if (files.Count() == 0) @@ -149,4 +149,4 @@ namespace NzbDrone.Api.Music } } } -} +} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs index 2a8dd88bc..0ff3abfe5 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs @@ -9,7 +9,6 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.EpisodeImport; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; using NzbDrone.Core.Music; using NzbDrone.Test.Common; @@ -60,7 +59,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests } } - private void GivenSeriesFolder() + private void GivenArtistFolder() { GivenRootFolder(_artist.Path); } @@ -87,7 +86,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests } [Test] - public void should_not_scan_if_series_root_folder_is_empty() + public void should_not_scan_if_artist_root_folder_is_empty() { GivenRootFolder(); @@ -106,7 +105,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests } [Test] - public void should_create_if_series_folder_does_not_exist_but_create_folder_enabled() + public void should_create_if_artist_folder_does_not_exist_but_create_folder_enabled() { GivenRootFolder(_otherArtistFolder); @@ -121,7 +120,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests } [Test] - public void should_not_create_if_series_folder_does_not_exist_and_create_folder_disabled() + public void should_not_create_if_artist_folder_does_not_exist_and_create_folder_disabled() { GivenRootFolder(_otherArtistFolder); @@ -136,7 +135,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests } [Test] - public void should_clean_but_not_import_if_series_folder_does_not_exist() + public void should_clean_but_not_import_if_artist_folder_does_not_exist() { GivenRootFolder(_otherArtistFolder); @@ -153,7 +152,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests } [Test] - public void should_clean_but_not_import_if_series_folder_does_not_exist_and_create_folder_enabled() + public void should_clean_but_not_import_if_artist_folder_does_not_exist_and_create_folder_enabled() { GivenRootFolder(_otherArtistFolder); @@ -171,14 +170,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests } [Test] - public void should_find_files_at_root_of_series_folder() + public void should_find_files_at_root_of_artist_folder() { - GivenSeriesFolder(); + GivenArtistFolder(); GivenFiles(new List { - Path.Combine(_artist.Path, "file1.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "s01e01.mkv").AsOsAgnostic() + Path.Combine(_artist.Path, "file1.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "s01e01.flac").AsOsAgnostic() }); Subject.Scan(_artist); @@ -190,15 +189,15 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests [Test] public void should_not_scan_extras_subfolder() { - GivenSeriesFolder(); + GivenArtistFolder(); GivenFiles(new List { - Path.Combine(_artist.Path, "EXTRAS", "file1.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Extras", "file2.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "EXTRAs", "file3.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "ExTrAs", "file4.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_artist.Path, "EXTRAS", "file1.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Extras", "file2.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "EXTRAs", "file3.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "ExTrAs", "file4.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", "s01e01.flac").AsOsAgnostic() }); Subject.Scan(_artist); @@ -213,13 +212,13 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests [Test] public void should_not_scan_AppleDouble_subfolder() { - GivenSeriesFolder(); + GivenArtistFolder(); GivenFiles(new List { - Path.Combine(_artist.Path, ".AppleDouble", "file1.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, ".appledouble", "file2.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_artist.Path, ".AppleDouble", "file1.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, ".appledouble", "file2.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", "s01e01.flac").AsOsAgnostic() }); Subject.Scan(_artist); @@ -229,20 +228,20 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests } [Test] - public void should_scan_extras_series_and_subfolders() + public void should_scan_extras_artist_and_subfolders() { - _artist.Path = @"C:\Test\TV\Extras".AsOsAgnostic(); + _artist.Path = @"C:\Test\Music\Extras".AsOsAgnostic(); - GivenSeriesFolder(); + GivenArtistFolder(); GivenFiles(new List { - Path.Combine(_artist.Path, "Extras", "file1.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, ".AppleDouble", "file2.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", "s01e02.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 2", "s02e01.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 2", "s02e02.mkv").AsOsAgnostic(), + Path.Combine(_artist.Path, "Extras", "file1.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, ".AppleDouble", "file2.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", "s01e01.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", "s01e02.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 2", "s02e01.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 2", "s02e02.flac").AsOsAgnostic(), }); Subject.Scan(_artist); @@ -254,14 +253,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests [Test] public void should_not_scan_subfolders_that_start_with_period() { - GivenSeriesFolder(); + GivenArtistFolder(); GivenFiles(new List { - Path.Combine(_artist.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, ".@__THUMB", "file2.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, ".hidden", "file2.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_artist.Path, ".@__thumb", "file1.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, ".@__THUMB", "file2.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, ".hidden", "file2.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", "s01e01.flac").AsOsAgnostic() }); Subject.Scan(_artist); @@ -273,15 +272,15 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests [Test] public void should_not_scan_subfolder_of_season_folder_that_starts_with_a_period() { - GivenSeriesFolder(); + GivenArtistFolder(); GivenFiles(new List { - Path.Combine(_artist.Path, "Season 1", ".@__thumb", "file1.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", ".@__THUMB", "file2.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", ".hidden", "file2.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", ".AppleDouble", "s01e01.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_artist.Path, "Season 1", ".@__thumb", "file1.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", ".@__THUMB", "file2.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", ".hidden", "file2.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", ".AppleDouble", "s01e01.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", "s01e01.flac").AsOsAgnostic() }); Subject.Scan(_artist); @@ -293,12 +292,12 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests [Test] public void should_not_scan_Synology_eaDir() { - GivenSeriesFolder(); + GivenArtistFolder(); GivenFiles(new List { - Path.Combine(_artist.Path, "@eaDir", "file1.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_artist.Path, "@eaDir", "file1.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", "s01e01.flac").AsOsAgnostic() }); Subject.Scan(_artist); @@ -310,12 +309,12 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests [Test] public void should_not_scan_thumb_folder() { - GivenSeriesFolder(); + GivenArtistFolder(); GivenFiles(new List { - Path.Combine(_artist.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_artist.Path, ".@__thumb", "file1.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", "s01e01.flac").AsOsAgnostic() }); Subject.Scan(_artist); @@ -327,14 +326,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests [Test] public void should_scan_dotHack_folder() { - _artist.Path = @"C:\Test\TV\.hack".AsOsAgnostic(); + _artist.Path = @"C:\Test\Music\.hack".AsOsAgnostic(); - GivenSeriesFolder(); + GivenArtistFolder(); GivenFiles(new List { - Path.Combine(_artist.Path, "Season 1", "file1.mkv").AsOsAgnostic(), - Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic() + Path.Combine(_artist.Path, "Season 1", "file1.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "Season 1", "s01e01.flac").AsOsAgnostic() }); Subject.Scan(_artist); @@ -346,12 +345,13 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests [Test] public void should_exclude_osx_metadata_files() { - GivenSeriesFolder(); + GivenArtistFolder(); GivenFiles(new List { - Path.Combine(_artist.Path, "._24 The Status Quo Combustion.mp4").AsOsAgnostic(), - Path.Combine(_artist.Path, "24 The Status Quo Combustion.mkv").AsOsAgnostic() + Path.Combine(_artist.Path, ".DS_STORE").AsOsAgnostic(), + Path.Combine(_artist.Path, "._24 The Status Quo Combustion.flac").AsOsAgnostic(), + Path.Combine(_artist.Path, "24 The Status Quo Combustion.flac").AsOsAgnostic() }); Subject.Scan(_artist); @@ -360,4 +360,4 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _artist), Times.Once()); } } -} +} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/MediaFiles/DownloadedEpisodesImportServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DownloadedEpisodesImportServiceFixture.cs index 943fbc6a5..f8c06c8ce 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DownloadedEpisodesImportServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DownloadedEpisodesImportServiceFixture.cs @@ -29,7 +29,7 @@ namespace NzbDrone.Core.Test.MediaFiles [SetUp] public void Setup() { - Mocker.GetMock().Setup(c => c.GetVideoFiles(It.IsAny(), It.IsAny())) + Mocker.GetMock().Setup(c => c.GetAudioFiles(It.IsAny(), It.IsAny())) .Returns(_videoFiles); Mocker.GetMock().Setup(c => c.GetDirectories(It.IsAny())) @@ -95,13 +95,13 @@ namespace NzbDrone.Core.Test.MediaFiles .Returns(true); Mocker.GetMock() - .Setup(c => c.GetVideoFiles(It.IsAny(), It.IsAny())) + .Setup(c => c.GetAudioFiles(It.IsAny(), It.IsAny())) .Returns(new string[0]); Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory)); Mocker.GetMock() - .Verify(v => v.GetVideoFiles(It.IsAny(), true), Times.Never()); + .Verify(v => v.GetAudioFiles(It.IsAny(), true), Times.Never()); ExceptionVerification.ExpectedWarns(1); } @@ -376,4 +376,4 @@ namespace NzbDrone.Core.Test.MediaFiles Times.Once()); } } -} +} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 7f6ddd559..f6aef2b27 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -351,7 +351,7 @@ - + diff --git a/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs b/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetAudioFilesFixture.cs similarity index 81% rename from src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs rename to src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetAudioFilesFixture.cs index 397314def..6a1aa73c1 100644 --- a/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs +++ b/src/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetAudioFilesFixture.cs @@ -8,12 +8,12 @@ using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { - public class GetVideoFilesFixture : CoreTest + public class GetAudioFilesFixture : CoreTest { private string[] _fileNames; @@ -22,10 +22,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { _fileNames = new[] { - @"30 Rock1.mkv", - @"30 Rock2.avi", - @"30 Rock3.MP4", - @"30 Rock4.wMv", + @"30 Rock1.mp3", + @"30 Rock2.flac", + @"30 Rock3.ogg", + @"30 Rock4.m4a", + @"30 Rock.avi", @"movie.exe", @"movie" }; @@ -49,7 +50,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { var path = @"C:\Test\"; - Subject.GetVideoFiles(path); + Subject.GetAudioFiles(path); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Once()); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Never()); @@ -60,7 +61,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { var path = @"C:\Test\"; - Subject.GetVideoFiles(path, true); + Subject.GetAudioFiles(path, true); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Once()); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Never()); @@ -71,19 +72,19 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests { var path = @"C:\Test\"; - Subject.GetVideoFiles(path, false); + Subject.GetAudioFiles(path, false); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Never()); Mocker.GetMock().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Once()); } [Test] - public void should_return_video_files_only() + public void should_return_audio_files_only() { var path = @"C:\Test\"; GivenFiles(GetFiles(path)); - Subject.GetVideoFiles(path).Should().HaveCount(4); + Subject.GetAudioFiles(path).Should().HaveCount(4); } [TestCase("Extras")] @@ -99,13 +100,13 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests var specialFiles = GetFiles(path, subFolder).ToList(); var allFiles = files.Concat(specialFiles); - var series = Builder.CreateNew() + var artist = Builder.CreateNew() .With(s => s.Path = path) .Build(); - var filteredFiles = Subject.FilterFiles(series, allFiles); + var filteredFiles = Subject.FilterFiles(artist, allFiles); filteredFiles.Should().NotContain(specialFiles); filteredFiles.Count.Should().BeGreaterThan(0); } } -} +} \ No newline at end of file diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/ScanWatchFolder.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/ScanWatchFolder.cs index d6e80e3fd..be868d51c 100644 --- a/src/NzbDrone.Core/Download/Clients/Blackhole/ScanWatchFolder.cs +++ b/src/NzbDrone.Core/Download/Clients/Blackhole/ScanWatchFolder.cs @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole yield return newWatchItem; } - foreach (var videoFile in _diskScanService.GetVideoFiles(watchFolder, false)) + foreach (var videoFile in _diskScanService.GetAudioFiles(watchFolder, false)) { var title = FileNameBuilder.CleanFileName(Path.GetFileName(videoFile)); @@ -193,4 +193,4 @@ namespace NzbDrone.Core.Download.Clients.Blackhole return HashConverter.GetHash(data.ToString()).ToHexString(); } } -} +} \ No newline at end of file diff --git a/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs b/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs index f2646d67e..8e7716e6a 100644 --- a/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs +++ b/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Extras { - public class ExistingExtraFileService : IHandle + public class ExistingExtraFileService : IHandle { private readonly IDiskProvider _diskProvider; private readonly IDiskScanService _diskScanService; @@ -28,32 +28,34 @@ namespace NzbDrone.Core.Extras _logger = logger; } - public void Handle(SeriesScannedEvent message) + public void Handle(ArtistScannedEvent message) { - var series = message.Series; + var artist = message.Artist; var extraFiles = new List(); - if (!_diskProvider.FolderExists(series.Path)) + if (!_diskProvider.FolderExists(artist.Path)) { return; } - _logger.Debug("Looking for existing extra files in {0}", series.Path); + _logger.Debug("Looking for existing extra files in {0}", artist.Path); - var filesOnDisk = _diskScanService.GetNonVideoFiles(series.Path); - var possibleExtraFiles = _diskScanService.FilterFiles(series, filesOnDisk); + var filesOnDisk = _diskScanService.GetNonAudioFiles(artist.Path); + var possibleExtraFiles = _diskScanService.FilterFiles(artist, filesOnDisk); var filteredFiles = possibleExtraFiles; var importedFiles = new List(); foreach (var existingExtraFileImporter in _existingExtraFileImporters) { - var imported = existingExtraFileImporter.ProcessFiles(series, filteredFiles, importedFiles); + // TODO Implement existingExtraFileImporter for Audio Files - importedFiles.AddRange(imported.Select(f => Path.Combine(series.Path, f.RelativePath))); + //var imported = existingExtraFileImporter.ProcessFiles(artist, filteredFiles, importedFiles); + + //importedFiles.AddRange(imported.Select(f => Path.Combine(artist.Path, f.RelativePath))); } _logger.Info("Found {0} extra files", extraFiles.Count); } } -} +} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs index b59a175f9..e2e53c301 100644 --- a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -15,7 +15,6 @@ using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; using NzbDrone.Core.Music; using NzbDrone.Core.Music.Events; using NzbDrone.Core.MediaFiles.TrackImport; @@ -25,10 +24,9 @@ namespace NzbDrone.Core.MediaFiles public interface IDiskScanService { void Scan(Artist artist); - string[] GetVideoFiles(string path, bool allDirectories = true); - string[] GetMusicFiles(string path, bool allDirectories = true); - string[] GetNonVideoFiles(string path, bool allDirectories = true); - List FilterFiles(Series series, IEnumerable files); + string[] GetAudioFiles(string path, bool allDirectories = true); + string[] GetNonAudioFiles(string path, bool allDirectories = true); + List FilterFiles(Artist artist, IEnumerable files); } public class DiskScanService : @@ -40,7 +38,6 @@ namespace NzbDrone.Core.MediaFiles private readonly IMakeImportDecision _importDecisionMaker; private readonly IImportApprovedTracks _importApprovedTracks; private readonly IConfigService _configService; - private readonly ISeriesService _seriesService; private readonly IArtistService _artistService; private readonly IMediaFileTableCleanupService _mediaFileTableCleanupService; private readonly IEventAggregator _eventAggregator; @@ -50,7 +47,6 @@ namespace NzbDrone.Core.MediaFiles IMakeImportDecision importDecisionMaker, IImportApprovedTracks importApprovedTracks, IConfigService configService, - ISeriesService seriesService, IArtistService artistService, IMediaFileTableCleanupService mediaFileTableCleanupService, IEventAggregator eventAggregator, @@ -60,7 +56,6 @@ namespace NzbDrone.Core.MediaFiles _importDecisionMaker = importDecisionMaker; _importApprovedTracks = importApprovedTracks; _configService = configService; - _seriesService = seriesService; _artistService = artistService; _mediaFileTableCleanupService = mediaFileTableCleanupService; _eventAggregator = eventAggregator; @@ -108,7 +103,7 @@ namespace NzbDrone.Core.MediaFiles } var musicFilesStopwatch = Stopwatch.StartNew(); - var mediaFileList = FilterFiles(artist, GetMusicFiles(artist.Path)).ToList(); + var mediaFileList = FilterFiles(artist, GetAudioFiles(artist.Path)).ToList(); musicFilesStopwatch.Stop(); _logger.Trace("Finished getting track files for: {0} [{1}]", artist, musicFilesStopwatch.Elapsed); @@ -129,34 +124,13 @@ namespace NzbDrone.Core.MediaFiles _mediaFileTableCleanupService.Clean(artist, mediaFileList); } - //private void CompletedScanning(Series series) - //{ - // _logger.Info("Completed scanning disk for {0}", series.Title); - // _eventAggregator.PublishEvent(new SeriesScannedEvent(series)); - //} - private void CompletedScanning(Artist artist) { _logger.Info("Completed scanning disk for {0}", artist.Name); _eventAggregator.PublishEvent(new ArtistScannedEvent(artist)); } - public string[] GetVideoFiles(string path, bool allDirectories = true) - { - _logger.Debug("Scanning '{0}' for video files", path); - - var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; - var filesOnDisk = _diskProvider.GetFiles(path, searchOption).ToList(); - - var mediaFileList = filesOnDisk.Where(file => MediaFileExtensions.Extensions.Contains(Path.GetExtension(file).ToLower())) - .ToList(); - - _logger.Trace("{0} files were found in {1}", filesOnDisk.Count, path); - _logger.Debug("{0} video files were found in {1}", mediaFileList.Count, path); - return mediaFileList.ToArray(); - } - - public string[] GetMusicFiles(string path, bool allDirectories = true) + public string[] GetAudioFiles(string path, bool allDirectories = true) { _logger.Debug("Scanning '{0}' for music files", path); @@ -171,7 +145,7 @@ namespace NzbDrone.Core.MediaFiles return mediaFileList.ToArray(); } - public string[] GetNonVideoFiles(string path, bool allDirectories = true) + public string[] GetNonAudioFiles(string path, bool allDirectories = true) { _logger.Debug("Scanning '{0}' for non-music files", path); @@ -186,13 +160,6 @@ namespace NzbDrone.Core.MediaFiles return mediaFileList.ToArray(); } - public List FilterFiles(Series series, IEnumerable files) - { - return files.Where(file => !ExcludedSubFoldersRegex.IsMatch(series.Path.GetRelativePath(file))) - .Where(file => !ExcludedFilesRegex.IsMatch(Path.GetFileName(file))) - .ToList(); - } - public List FilterFiles(Artist artist, IEnumerable files) { return files.Where(file => !ExcludedSubFoldersRegex.IsMatch(artist.Path.GetRelativePath(file))) diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs index d5caf8fd2..d48d5c596 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs @@ -60,7 +60,7 @@ namespace NzbDrone.Core.MediaFiles results.AddRange(folderResults); } - foreach (var videoFile in _diskScanService.GetNonVideoFiles(directoryInfo.FullName, false)) + foreach (var videoFile in _diskScanService.GetNonAudioFiles(directoryInfo.FullName, false)) { var fileResults = ProcessFile(new FileInfo(videoFile), ImportMode.Auto, null); results.AddRange(fileResults); @@ -101,7 +101,7 @@ namespace NzbDrone.Core.MediaFiles public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Series series) { - var videoFiles = _diskScanService.GetNonVideoFiles(directoryInfo.FullName); + var videoFiles = _diskScanService.GetNonAudioFiles(directoryInfo.FullName); var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f) == ".rar"); foreach (var videoFile in videoFiles) @@ -268,4 +268,4 @@ namespace NzbDrone.Core.MediaFiles //return new ImportResult(new ImportDecision(localEpisode, new Rejection("Unknown Series")), message); } } -} +} \ No newline at end of file