Fixed: Skip sample check for DVD image files (iso, img, m2ts) (#4531)

* Add support for video files with non-lowercase extensions.

* Fix file scan ignoring DVD image files (iso, img, vob, m2ts)
Always allow DVD and Bluray file types without analysis, instead of detecting as 0 runtime.

* Use extensions to detect DVD image files instead of Quality enum
Add unit tests

Co-authored-by: Doug Krahmer <doug.git@remhark.com>
pull/2/head
Doug Krahmer 4 years ago committed by GitHub
parent 8687dbda1d
commit 3a7b1741d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -61,6 +61,36 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport
Mocker.GetMock<IVideoFileInfoReader>().Verify(c => c.GetRunTime(It.IsAny<string>()), Times.Never()); Mocker.GetMock<IVideoFileInfoReader>().Verify(c => c.GetRunTime(It.IsAny<string>()), Times.Never());
} }
[Test]
public void should_return_false_for_iso()
{
_localMovie.Path = @"C:\Test\some movie (2000).iso";
ShouldBeNotSample();
Mocker.GetMock<IVideoFileInfoReader>().Verify(c => c.GetRunTime(It.IsAny<string>()), Times.Never());
}
[Test]
public void should_return_false_for_img()
{
_localMovie.Path = @"C:\Test\some movie (2000).img";
ShouldBeNotSample();
Mocker.GetMock<IVideoFileInfoReader>().Verify(c => c.GetRunTime(It.IsAny<string>()), Times.Never());
}
[Test]
public void should_return_false_for_m2ts()
{
_localMovie.Path = @"C:\Test\some movie (2000).m2ts";
ShouldBeNotSample();
Mocker.GetMock<IVideoFileInfoReader>().Verify(c => c.GetRunTime(It.IsAny<string>()), Times.Never());
}
[Test] [Test]
public void should_use_runtime() public void should_use_runtime()
{ {

@ -10,7 +10,7 @@ namespace NzbDrone.Core.MediaFiles
static MediaFileExtensions() static MediaFileExtensions()
{ {
_fileExtensions = new Dictionary<string, Quality> _fileExtensions = new Dictionary<string, Quality>(StringComparer.OrdinalIgnoreCase)
{ {
//Unknown //Unknown
{ ".webm", Quality.Unknown }, { ".webm", Quality.Unknown },
@ -75,9 +75,9 @@ namespace NzbDrone.Core.MediaFiles
public static Quality GetQualityForExtension(string extension) public static Quality GetQualityForExtension(string extension)
{ {
if (_fileExtensions.ContainsKey(extension)) if (_fileExtensions.TryGetValue(extension, out var quality))
{ {
return _fileExtensions[extension]; return quality;
} }
return Quality.Unknown; return Quality.Unknown;

@ -1,8 +1,10 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using NLog; using NLog;
using NzbDrone.Core.MediaFiles.MediaInfo; using NzbDrone.Core.MediaFiles.MediaInfo;
using NzbDrone.Core.Movies; using NzbDrone.Core.Movies;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Core.MediaFiles.MovieImport namespace NzbDrone.Core.MediaFiles.MovieImport
{ {
@ -32,16 +34,25 @@ namespace NzbDrone.Core.MediaFiles.MovieImport
var extension = Path.GetExtension(path); var extension = Path.GetExtension(path);
if (extension != null && extension.Equals(".flv", StringComparison.InvariantCultureIgnoreCase)) if (extension != null)
{ {
_logger.Debug("Skipping sample check for .flv file"); if (extension.Equals(".flv", StringComparison.InvariantCultureIgnoreCase))
return DetectSampleResult.NotSample; {
} _logger.Debug("Skipping sample check for .flv file");
return DetectSampleResult.NotSample;
if (extension != null && extension.Equals(".strm", StringComparison.InvariantCultureIgnoreCase)) }
{
_logger.Debug("Skipping sample check for .strm file"); if (extension.Equals(".strm", StringComparison.InvariantCultureIgnoreCase))
return DetectSampleResult.NotSample; {
_logger.Debug("Skipping sample check for .strm file");
return DetectSampleResult.NotSample;
}
if (new string[] { ".iso", ".img", ".m2ts" }.Contains(extension, StringComparer.OrdinalIgnoreCase))
{
_logger.Debug($"Skipping sample check for DVD/BR image file '{path}'");
return DetectSampleResult.NotSample;
}
} }
// TODO: Use MediaInfo from the import process, no need to re-process the file again here // TODO: Use MediaInfo from the import process, no need to re-process the file again here

Loading…
Cancel
Save