From 6b0aae85ee60bcb07fa58dad6efcee37b4588c66 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 29 May 2011 20:56:49 -0700 Subject: [PATCH] GetMediaFile should be alot easier on disk. --- NzbDrone.Core/Providers/MediaFileProvider.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/NzbDrone.Core/Providers/MediaFileProvider.cs b/NzbDrone.Core/Providers/MediaFileProvider.cs index 9405ba8b5..8f0532435 100644 --- a/NzbDrone.Core/Providers/MediaFileProvider.cs +++ b/NzbDrone.Core/Providers/MediaFileProvider.cs @@ -12,7 +12,7 @@ namespace NzbDrone.Core.Providers public class MediaFileProvider { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private static readonly string[] MediaExtentions = new[] { "*.mkv", "*.avi", "*.wmv", "*.mp4" }; + private static readonly string[] MediaExtentions = new[] { ".mkv", ".avi", ".wmv", ".mp4" }; private readonly DiskProvider _diskProvider; private readonly EpisodeProvider _episodeProvider; private readonly SeriesProvider _seriesProvider; @@ -72,7 +72,7 @@ public virtual EpisodeFile ImportFile(Series series, string filePath) if (!_repository.Exists(e => e.Path == Parser.NormalizePath(filePath))) { var parseResult = Parser.ParseEpisodeInfo(filePath); - + if (parseResult == null) return null; @@ -199,14 +199,11 @@ private List GetMediaFileList(string path) { Logger.Debug("Scanning '{0}' for episodes", path); - var mediaFileList = new List(); + var filesOnDisk = _diskProvider.GetFiles(path, "*.*", SearchOption.AllDirectories); - foreach (var ext in MediaExtentions) - { - mediaFileList.AddRange(_diskProvider.GetFiles(path, ext, SearchOption.AllDirectories)); - } + var mediaFileList = filesOnDisk.Where(c => MediaExtentions.Contains(Path.GetExtension(c).ToLower())).ToList(); - Logger.Trace("{0} media files were found in {1}", mediaFileList.Count, path); + Logger.Debug("{0} media files were found in {1}", mediaFileList.Count, path); return mediaFileList; } }