1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

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>
This commit is contained in:
Doug Krahmer 2020-06-23 18:41:16 -07:00 committed by GitHub
parent 8687dbda1d
commit 3a7b1741d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 11 deletions

View File

@ -61,6 +61,36 @@ public void should_return_false_for_strm()
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()
{ {

View File

@ -10,7 +10,7 @@ public static class MediaFileExtensions
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 @@ static MediaFileExtensions()
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;

View File

@ -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 @@ public DetectSampleResult IsSample(Movie movie, string path, bool isSpecial)
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)) if (extension.Equals(".strm", StringComparison.InvariantCultureIgnoreCase))
{ {
_logger.Debug("Skipping sample check for .strm file"); _logger.Debug("Skipping sample check for .strm file");
return DetectSampleResult.NotSample; 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