From be2e3c5c2e14f8a65f695fbcc57829da5978dd3e Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 17 Aug 2013 21:28:34 -0700 Subject: [PATCH] synced know file extentions with XBMC's list http://wiki.xbmc.org/?title=advancedsettings.xml#.3Cvideoextensions.3E --- .../GetVideoFilesFixture.cs | 7 +++--- NzbDrone.Core/MediaFiles/DiskScanService.cs | 23 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs index 5a22f7ee5..b73e09984 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs @@ -21,9 +21,10 @@ public void Setup() { @"C:\Test\30 Rock1.mkv", @"C:\Test\30 Rock2.avi", - @"C:\Test\30 Rock3.mp4", - @"C:\Test\30 Rock4.wmv", - @"C:\Test\movie.exe" + @"C:\Test\30 Rock3.MP4", + @"C:\Test\30 Rock4.wMv", + @"C:\Test\movie.exe", + @"C:\Test\movie" }; Mocker.GetMock() diff --git a/NzbDrone.Core/MediaFiles/DiskScanService.cs b/NzbDrone.Core/MediaFiles/DiskScanService.cs index babfd27c8..e266b0fc5 100644 --- a/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -20,22 +20,31 @@ public class DiskScanService : IDiskScanService, IHandle { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private static readonly HashSet MediaExtensions = new HashSet { ".mkv", ".avi", ".wmv", ".mp4", ".mpg", ".mpeg", ".xvid", ".flv", ".mov", ".rm", ".rmvb", ".divx", ".dvr-ms", ".ts", ".ogm", ".m4v", ".strm", ".iso", "m2ts" }; + private readonly HashSet _mediaExtensions; + + private const string EXTENSIONS = + ".m4v .3gp .nsv .ts .ty .strm .rm .rmvb .m3u .ifo .mov .qt .divx .xvid .bivx .vob .nrg .img" + + ".iso .pva .wmv .asf .asx .ogm .m2v .avi .bin .dat .dvr-ms .mpg .mpeg .mp4 .mkv .avc .vp3 " + + ".svq3 .nuv .viv .dv .fli .flv .wpl"; + private readonly IDiskProvider _diskProvider; private readonly IMakeImportDecision _importDecisionMaker; private readonly IImportApprovedEpisodes _importApprovedEpisodes; private readonly IMessageAggregator _messageAggregator; + private readonly Logger _logger; public DiskScanService(IDiskProvider diskProvider, IMakeImportDecision importDecisionMaker, IImportApprovedEpisodes importApprovedEpisodes, - IMessageAggregator messageAggregator) + IMessageAggregator messageAggregator, Logger logger) { _diskProvider = diskProvider; _importDecisionMaker = importDecisionMaker; _importApprovedEpisodes = importApprovedEpisodes; _messageAggregator = messageAggregator; + _logger = logger; + + _mediaExtensions = new HashSet(EXTENSIONS.Split(' ')); } private void Scan(Series series) @@ -44,7 +53,7 @@ private void Scan(Series series) if (!_diskProvider.FolderExists(series.Path)) { - Logger.Debug("Series folder doesn't exist: {0}", series.Path); + _logger.Debug("Series folder doesn't exist: {0}", series.Path); return; } @@ -56,14 +65,14 @@ private void Scan(Series series) public string[] GetVideoFiles(string path, bool allDirectories = true) { - Logger.Debug("Scanning '{0}' for video files", path); + _logger.Debug("Scanning '{0}' for video files", path); var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; var filesOnDisk = _diskProvider.GetFiles(path, searchOption); - var mediaFileList = filesOnDisk.Where(c => MediaExtensions.Contains(Path.GetExtension(c).ToLower())).ToList(); + var mediaFileList = filesOnDisk.Where(c => _mediaExtensions.Contains(Path.GetExtension(c).ToLower())).ToList(); - Logger.Trace("{0} video files were found in {1}", mediaFileList.Count, path); + _logger.Trace("{0} video files were found in {1}", mediaFileList.Count, path); return mediaFileList.ToArray(); }