New: Parsing of poorly named absolute number-only files in batches
Closes #5488
This commit is contained in:
parent
f22998aef3
commit
17b9e4722a
|
@ -1,7 +1,9 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ParserTests
|
||||
{
|
||||
|
@ -201,5 +203,17 @@ namespace NzbDrone.Core.Test.ParserTests
|
|||
result.SpecialAbsoluteEpisodeNumbers.Should().BeEquivalentTo(new[] { (decimal)specialEpisodeNumber });
|
||||
result.FullSeason.Should().BeFalse();
|
||||
}
|
||||
|
||||
[TestCase("Series Title 921-928 [English Dub][1080p][onepiecedubb]", "921.mkv", "Series Title", 921)]
|
||||
public void should_handle_ambiguously_named_anime_files_in_batch_release(string releaseName, string filename, string title, int absoluteEpisodeNumber)
|
||||
{
|
||||
var result = Parser.Parser.ParsePath(Path.Combine(@"C:\Test".AsOsAgnostic(), releaseName, filename));
|
||||
result.Should().NotBeNull();
|
||||
result.AbsoluteEpisodeNumbers.Single().Should().Be(absoluteEpisodeNumber);
|
||||
result.SeasonNumber.Should().Be(0);
|
||||
result.EpisodeNumbers.Should().BeEmpty();
|
||||
result.SeriesTitle.Should().Be(title);
|
||||
result.FullSeason.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -516,6 +516,31 @@ namespace NzbDrone.Core.Parser
|
|||
|
||||
var result = ParseTitle(fileInfo.Name);
|
||||
|
||||
if (result == null && int.TryParse(Path.GetFileNameWithoutExtension(fileInfo.Name), out var number))
|
||||
{
|
||||
Logger.Debug("Attempting to parse episode info using directory and file names. {0}", fileInfo.Directory.Name);
|
||||
result = ParseTitle(fileInfo.Directory.Name);
|
||||
|
||||
if (result != null && result.AbsoluteEpisodeNumbers.Contains(number))
|
||||
{
|
||||
result.AbsoluteEpisodeNumbers = new[] { number };
|
||||
}
|
||||
else if (result != null && result.EpisodeNumbers.Contains(number))
|
||||
{
|
||||
result.EpisodeNumbers = new[] { number };
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
Logger.Debug("Attempting to parse episode info using combined directory and file names. {0}", fileInfo.Directory.Name);
|
||||
result = ParseTitle(fileInfo.Directory.Name + " " + fileInfo.Name);
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
Logger.Debug("Attempting to parse episode info using directory and file names. {0}", fileInfo.Directory.Name);
|
||||
|
|
Loading…
Reference in New Issue