mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
New: Removed the whole lenient parsing and lenient mapping functionality
This commit is contained in:
parent
5f5391db47
commit
51de8f16fb
@ -14,7 +14,6 @@ public class IndexerConfigResource : RestResource
|
||||
public int AvailabilityDelay { get; set; }
|
||||
public bool AllowHardcodedSubs { get; set; }
|
||||
public string WhitelistedHardcodedSubs { get; set; }
|
||||
public ParsingLeniencyType ParsingLeniency { get; set; }
|
||||
}
|
||||
|
||||
public static class IndexerConfigResourceMapper
|
||||
@ -31,7 +30,6 @@ public static IndexerConfigResource ToResource(IConfigService model)
|
||||
AvailabilityDelay = model.AvailabilityDelay,
|
||||
AllowHardcodedSubs = model.AllowHardcodedSubs,
|
||||
WhitelistedHardcodedSubs = model.WhitelistedHardcodedSubs,
|
||||
ParsingLeniency = model.ParsingLeniency,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ protected void ParseMovieTitle()
|
||||
Mocker.GetMock<IParsingService>().Setup(c => c.ParseMovieInfo(It.IsAny<string>(), It.IsAny<System.Collections.Generic.List<object>>()))
|
||||
.Returns<string, System.Collections.Generic.List<object>>((title, helpers) =>
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(title, false);
|
||||
var result = Parser.Parser.ParseMovieTitle(title);
|
||||
if (result != null)
|
||||
{
|
||||
result.Quality = QualityParser.ParseQuality(title);
|
||||
|
@ -64,7 +64,7 @@ public void should_remove_accents_from_title()
|
||||
[TestCase("www.Torrenting.org - Revenge.2008.720p.X264-DIMENSION", "Revenge")]
|
||||
public void should_parse_movie_title(string postTitle, string title)
|
||||
{
|
||||
Parser.Parser.ParseMovieTitle(postTitle, true).MovieTitle.Should().Be(title);
|
||||
Parser.Parser.ParseMovieTitle(postTitle).MovieTitle.Should().Be(title);
|
||||
}
|
||||
|
||||
[TestCase("Avatar.Aufbruch.nach.Pandora.Extended.2009.German.DTS.720p.BluRay.x264-SoW", "Avatar Aufbruch nach Pandora", "Extended", 2009)]
|
||||
@ -80,43 +80,22 @@ public void should_parse_movie_title(string postTitle, string title)
|
||||
[TestCase("Life.Partners.2014.German.DL.PAL.DVDR-ETM", "Life Partners", "", 2014)]
|
||||
[TestCase("Joe.Dreck.2.EXTENDED.EDITION.2015.German.DL.PAL.DVDR-ETM", "Joe Dreck 2", "EXTENDED EDITION", 2015)]
|
||||
[TestCase("Rango.EXTENDED.2011.HDRip.AC3.German.XviD-POE", "Rango", "EXTENDED", 2011)]
|
||||
[TestCase("Suicide.Squad.2016.EXTENDED.German.DL.AC3.BDRip.x264-hqc", "Suicide Squad", "EXTENDED", 2016)] //edition after year
|
||||
public void should_parse_german_movie(string postTitle, string title, string edition, int year)
|
||||
{
|
||||
ParsedMovieInfo movie = Parser.Parser.ParseMovieTitle(postTitle, false);
|
||||
using (new AssertionScope())
|
||||
{
|
||||
movie.MovieTitle.Should().Be(title);
|
||||
movie.Edition.Should().Be(edition);
|
||||
movie.Year.Should().Be(year);
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase("Avatar.Aufbruch.nach.Pandora.Extended.2009.German.DTS.720p.BluRay.x264-SoW", "Avatar Aufbruch nach Pandora", "Extended", 2009)]
|
||||
[TestCase("Drop.Zone.1994.German.AC3D.DL.720p.BluRay.x264-KLASSiGERHD", "Drop Zone", "", 1994)]
|
||||
[TestCase("Kick.Ass.2.2013.German.DTS.DL.720p.BluRay.x264-Pate", "Kick Ass 2", "", 2013)]
|
||||
[TestCase("Paradise.Hills.2019.German.DL.AC3.Dubbed.1080p.BluRay.x264-muhHD", "Paradise Hills", "", 2019)]
|
||||
[TestCase("96.Hours.Taken.3.EXTENDED.2014.German.DL.1080p.BluRay.x264-ENCOUNTERS", "96 Hours Taken 3", "EXTENDED", 2014)]
|
||||
[TestCase("World.War.Z.EXTENDED.CUT.2013.German.DL.1080p.BluRay.x264-HQX", "World War Z", "EXTENDED CUT", 2013)]
|
||||
[TestCase("Sin.City.2005.RECUT.EXTENDED.German.DL.1080p.BluRay.x264-DETAiLS", "Sin City", "RECUT EXTENDED", 2005)]
|
||||
[TestCase("Die.Klasse.von.1999.1990.German.720p.HDTV.x264-NORETAiL", "Die Klasse von 1999", "", 1990)] //year in the title
|
||||
[TestCase("2.Tage.in.L.A.1996.GERMAN.DL.720p.WEB.H264-SOV", "2 Tage in L.A.", "", 1996)]
|
||||
[TestCase("8.2019.GERMAN.720p.BluRay.x264-UNiVERSUM", "8", "", 2019)]
|
||||
[TestCase("Life.Partners.2014.German.DL.PAL.DVDR-ETM", "Life Partners", "", 2014)]
|
||||
[TestCase("Joe.Dreck.2.EXTENDED.EDITION.2015.German.DL.PAL.DVDR-ETM", "Joe Dreck 2", "EXTENDED EDITION", 2015)]
|
||||
[TestCase("Rango.EXTENDED.2011.HDRip.AC3.German.XviD-POE", "Rango", "EXTENDED", 2011)]
|
||||
//Special cases (see comment to the right)
|
||||
[TestCase("Suicide.Squad.2016.EXTENDED.German.DL.AC3.BDRip.x264-hqc", "Suicide Squad", "EXTENDED", 2016)] //edition after year
|
||||
|
||||
[TestCase("Knight.and.Day.2010.Extended.Cut.German.DTS.DL.720p.BluRay.x264-HDS", "Knight and Day", "Extended Cut", 2010)] //edition after year
|
||||
[TestCase("Der.Soldat.James.German.Bluray.FuckYou.Pso.Why.cant.you.follow.scene.rules.1998", "Der Soldat James", "", 1998)] //year at the end
|
||||
[TestCase("Der.Hobbit.Eine.Unerwartete.Reise.Extended.German.720p.BluRay.x264-EXQUiSiTE", "Der Hobbit Eine Unerwartete Reise", "Extended", 0)] //no year
|
||||
[TestCase("Wolverine.Weg.des.Kriegers.EXTENDED.German.720p.BluRay.x264-EXQUiSiTE", "Wolverine Weg des Kriegers", "EXTENDED", 0)] //no year
|
||||
[TestCase("Die.Unfassbaren.Now.You.See.Me.EXTENDED.German.DTS.720p.BluRay.x264-RHD", "Die Unfassbaren Now You See Me", "EXTENDED", 0)] //no year
|
||||
[TestCase("Der.Soldat.James.German.Bluray.FuckYou.Pso.Why.cant.you.follow.scene.rules.1998", "Der Soldat James", "", 1998)]
|
||||
[TestCase("Die Unfassbaren Now You See Me EXTENDED German DTS 720p BluRay x264-RHD", "Die Unfassbaren Now You See Me", "EXTENDED", 0)] //no year & without dots
|
||||
[TestCase("Passengers.German.DL.AC3.Dubbed..BluRay.x264-PsO", "Passengers", "", 0)] //no year
|
||||
[TestCase("Das.A.Team.Der.Film.Extended.Cut.German.720p.BluRay.x264-ANCIENT", "Das A Team Der Film", "Extended Cut", 0)] //no year
|
||||
[TestCase("Cars.2.German.DL.720p.BluRay.x264-EmpireHD", "Cars 2", "", 0)] //no year
|
||||
[TestCase("Der.Film.deines.Lebens.German.2011.PAL.DVDR-ETM", "Der Film deines Lebens", "", 2011)] //year at wrong position
|
||||
public void should_parse_german_movie_lenient(string postTitle, string title, string edition, int year)
|
||||
public void should_parse_german_movie(string postTitle, string title, string edition, int year)
|
||||
{
|
||||
ParsedMovieInfo movie = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
ParsedMovieInfo movie = Parser.Parser.ParseMovieTitle(postTitle);
|
||||
using (new AssertionScope())
|
||||
{
|
||||
movie.MovieTitle.Should().Be(title);
|
||||
@ -128,7 +107,7 @@ public void should_parse_german_movie_lenient(string postTitle, string title, st
|
||||
[TestCase("(1995) Ghost in the Shell", "Ghost in the Shell")]
|
||||
public void should_parse_movie_folder_name(string postTitle, string title)
|
||||
{
|
||||
Parser.Parser.ParseMovieTitle(postTitle, true, true).MovieTitle.Should().Be(title);
|
||||
Parser.Parser.ParseMovieTitle(postTitle, true).MovieTitle.Should().Be(title);
|
||||
}
|
||||
|
||||
[TestCase("1941.1979.EXTENDED.720p.BluRay.X264-AMIABLE", 1979)]
|
||||
@ -137,7 +116,7 @@ public void should_parse_movie_folder_name(string postTitle, string title)
|
||||
[TestCase("Leaving Jeruselem by Railway (1897) [DVD].mp4", 1897)]
|
||||
public void should_parse_movie_year(string postTitle, int year)
|
||||
{
|
||||
Parser.Parser.ParseMovieTitle(postTitle, false).Year.Should().Be(year);
|
||||
Parser.Parser.ParseMovieTitle(postTitle).Year.Should().Be(year);
|
||||
}
|
||||
|
||||
[TestCase("Prometheus 2012 Directors Cut", "Directors Cut")]
|
||||
@ -180,7 +159,7 @@ public void should_parse_movie_year(string postTitle, int year)
|
||||
[TestCase("Loving.Pablo.2018.TS.FRENCH.MD.x264-DROGUERiE", "")]
|
||||
public void should_parse_edition(string postTitle, string edition)
|
||||
{
|
||||
var parsed = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
var parsed = Parser.Parser.ParseMovieTitle(postTitle);
|
||||
parsed.Edition.Should().Be(edition);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public void should_use_parsed_series_title()
|
||||
Subject.GetMovie(title);
|
||||
|
||||
Mocker.GetMock<IMovieService>()
|
||||
.Verify(s => s.FindByTitle(Parser.Parser.ParseMovieTitle(title, false, false).MovieTitle), Times.Once());
|
||||
.Verify(s => s.FindByTitle(Parser.Parser.ParseMovieTitle(title, false).MovieTitle), Times.Once());
|
||||
}
|
||||
|
||||
/*[Test]
|
||||
|
@ -190,12 +190,6 @@ public string WhitelistedHardcodedSubs
|
||||
set { SetValue("WhitelistedHardcodedSubs", value); }
|
||||
}
|
||||
|
||||
public ParsingLeniencyType ParsingLeniency
|
||||
{
|
||||
get { return GetValueEnum<ParsingLeniencyType>("ParsingLeniency", ParsingLeniencyType.Strict); }
|
||||
set { SetValue("ParsingLeniency", value); }
|
||||
}
|
||||
|
||||
public bool RemoveCompletedDownloads
|
||||
{
|
||||
get { return GetValueBoolean("RemoveCompletedDownloads", false); }
|
||||
|
@ -61,7 +61,6 @@ public interface IConfigService
|
||||
|
||||
bool AllowHardcodedSubs { get; set; }
|
||||
string WhitelistedHardcodedSubs { get; set; }
|
||||
ParsingLeniencyType ParsingLeniency { get; set; }
|
||||
|
||||
int NetImportSyncInterval { get; set; }
|
||||
string ListSyncLevel { get; set; }
|
||||
|
@ -27,7 +27,7 @@ private void SetSortTitles(IDbConnection conn, IDbTransaction tran)
|
||||
var id = seriesReader.GetInt32(0);
|
||||
var relativePath = seriesReader.GetString(1);
|
||||
|
||||
var result = Parser.Parser.ParseMovieTitle(relativePath, false);
|
||||
var result = Parser.Parser.ParseMovieTitle(relativePath);
|
||||
|
||||
var edition = "";
|
||||
|
||||
|
@ -89,12 +89,7 @@ private IEnumerable<DownloadDecision> GetDecisions(List<ReleaseInfo> reports, Se
|
||||
Quality = new QualityModel(),
|
||||
};
|
||||
|
||||
if (_configService.ParsingLeniency == ParsingLeniencyType.MappingLenient)
|
||||
{
|
||||
result = _parsingService.Map(parsedMovieInfo, report.ImdbId.ToString(), searchCriteria);
|
||||
}
|
||||
|
||||
if (result == null || result.MappingResultType != MappingResultType.SuccessLenientMapping)
|
||||
if (result == null)
|
||||
{
|
||||
result = new MappingResult { MappingResultType = MappingResultType.NotParsable };
|
||||
result.Movie = null; //To ensure we have a remote movie, else null exception on next line!
|
||||
@ -113,7 +108,7 @@ private IEnumerable<DownloadDecision> GetDecisions(List<ReleaseInfo> reports, Se
|
||||
remoteMovie.Release = report;
|
||||
remoteMovie.MappingResult = result.MappingResultType;
|
||||
|
||||
if (result.MappingResultType != MappingResultType.Success && result.MappingResultType != MappingResultType.SuccessLenientMapping)
|
||||
if (result.MappingResultType != MappingResultType.Success)
|
||||
{
|
||||
var rejection = result.ToRejection();
|
||||
decision = new DownloadDecision(remoteMovie, rejection);
|
||||
|
@ -27,13 +27,13 @@ public DownloadDecisionPriorizationService(IConfigService configService, IDelayP
|
||||
|
||||
public List<DownloadDecision> PrioritizeDecisionsForMovies(List<DownloadDecision> decisions)
|
||||
{
|
||||
return decisions.Where(c => c.RemoteMovie.MappingResult == MappingResultType.Success || c.RemoteMovie.MappingResult == MappingResultType.SuccessLenientMapping)
|
||||
return decisions.Where(c => c.RemoteMovie.MappingResult == MappingResultType.Success)
|
||||
.GroupBy(c => c.RemoteMovie.Movie.Id, (movieId, downloadDecisions) =>
|
||||
{
|
||||
return downloadDecisions.OrderByDescending(decision => decision, new DownloadDecisionComparer(_configService, _delayProfileService, _qualityDefinitionService));
|
||||
})
|
||||
.SelectMany(c => c)
|
||||
.Union(decisions.Where(c => c.RemoteMovie.MappingResult != MappingResultType.Success || c.RemoteMovie.MappingResult != MappingResultType.SuccessLenientMapping))
|
||||
.Union(decisions.Where(c => c.RemoteMovie.MappingResult != MappingResultType.Success))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public override MetadataFile FindMetadataFile(Movie movie, string path)
|
||||
RelativePath = movie.Path.GetRelativePath(path)
|
||||
};
|
||||
|
||||
var parseResult = Parser.Parser.ParseMovieTitle(filename, false);
|
||||
var parseResult = Parser.Parser.ParseMovieTitle(filename);
|
||||
|
||||
if (parseResult != null)
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ public override MetadataFile FindMetadataFile(Movie movie, string path)
|
||||
return metadata;
|
||||
}
|
||||
|
||||
var parseResult = Parser.Parser.ParseMovieTitle(filename, false);
|
||||
var parseResult = Parser.Parser.ParseMovieTitle(filename);
|
||||
|
||||
if (parseResult != null)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ public override MetadataFile FindMetadataFile(Movie movie, string path)
|
||||
return metadata;
|
||||
}
|
||||
|
||||
var parseResult = Parser.Parser.ParseMovieTitle(filename, false);
|
||||
var parseResult = Parser.Parser.ParseMovieTitle(filename);
|
||||
|
||||
if (parseResult != null &&
|
||||
Path.GetExtension(filename).Equals(".nfo", StringComparison.OrdinalIgnoreCase) &&
|
||||
|
@ -123,7 +123,7 @@ public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Movie movie)
|
||||
foreach (var videoFile in videoFiles)
|
||||
{
|
||||
var movieParseResult =
|
||||
Parser.Parser.ParseMovieTitle(Path.GetFileName(videoFile), _config.ParsingLeniency > 0);
|
||||
Parser.Parser.ParseMovieTitle(Path.GetFileName(videoFile));
|
||||
|
||||
if (movieParseResult == null)
|
||||
{
|
||||
|
@ -214,7 +214,7 @@ private string GetSceneName(DownloadClientItem downloadClientItem, LocalMovie lo
|
||||
{
|
||||
var title = Parser.Parser.RemoveFileExtension(downloadClientItem.Title);
|
||||
|
||||
var parsedTitle = Parser.Parser.ParseMovieTitle(title, false);
|
||||
var parsedTitle = Parser.Parser.ParseMovieTitle(title);
|
||||
|
||||
if (parsedTitle != null)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie mo
|
||||
|
||||
if (downloadClientItem != null)
|
||||
{
|
||||
downloadClientItemInfo = Parser.Parser.ParseMovieTitle(downloadClientItem.Title, false);
|
||||
downloadClientItemInfo = Parser.Parser.ParseMovieTitle(downloadClientItem.Title);
|
||||
downloadClientItemInfo = _parsingService.EnhanceMovieInfo(downloadClientItemInfo);
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ private ImportDecision GetDecision(LocalMovie localMovie, DownloadClientItem dow
|
||||
{
|
||||
ImportDecision decision = null;
|
||||
|
||||
var fileMovieInfo = Parser.Parser.ParseMoviePath(localMovie.Path, false);
|
||||
var fileMovieInfo = Parser.Parser.ParseMoviePath(localMovie.Path);
|
||||
|
||||
if (fileMovieInfo != null)
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ private List<ManualImportItem> ProcessFolder(string rootFolder, string baseFolde
|
||||
return processedFiles.Concat(processedFolders).Where(i => i != null).ToList();
|
||||
}
|
||||
|
||||
var folderInfo = Parser.Parser.ParseMovieTitle(directoryInfo.Name, false);
|
||||
var folderInfo = Parser.Parser.ParseMovieTitle(directoryInfo.Name);
|
||||
var movieFiles = _diskScanService.GetVideoFiles(baseFolder).ToList();
|
||||
var decisions = _importDecisionMaker.GetImportDecisions(movieFiles, movie, downloadClientItem, folderInfo, SceneSource(movie, baseFolder), filterExistingFiles);
|
||||
|
||||
@ -164,7 +164,7 @@ private ManualImportItem ProcessFile(string rootFolder, string baseFolder, strin
|
||||
|
||||
if (movie == null)
|
||||
{
|
||||
var relativeParseInfo = Parser.Parser.ParseMoviePath(relativeFile, false);
|
||||
var relativeParseInfo = Parser.Parser.ParseMoviePath(relativeFile);
|
||||
|
||||
if (relativeParseInfo != null)
|
||||
{
|
||||
@ -241,7 +241,7 @@ public void Execute(ManualImportCommand message)
|
||||
|
||||
var file = message.Files[i];
|
||||
var movie = _movieService.GetMovie(file.MovieId);
|
||||
var fileMovieInfo = Parser.Parser.ParseMoviePath(file.Path, false) ?? new ParsedMovieInfo();
|
||||
var fileMovieInfo = Parser.Parser.ParseMoviePath(file.Path) ?? new ParsedMovieInfo();
|
||||
var existingFile = movie.Path.IsParentPath(file.Path);
|
||||
TrackedDownload trackedDownload = null;
|
||||
|
||||
@ -264,7 +264,7 @@ public void Execute(ManualImportCommand message)
|
||||
|
||||
if (file.FolderName.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
localMovie.FolderMovieInfo = Parser.Parser.ParseMovieTitle(file.FolderName, false);
|
||||
localMovie.FolderMovieInfo = Parser.Parser.ParseMovieTitle(file.FolderName);
|
||||
}
|
||||
|
||||
localMovie = _aggregationService.Augment(localMovie, false);
|
||||
|
@ -290,7 +290,7 @@ public List<Movie> SearchForNewMovie(string title)
|
||||
|
||||
lowerTitle = lowerTitle.Replace(".", "");
|
||||
|
||||
var parserResult = Parser.Parser.ParseMovieTitle(title, true, true);
|
||||
var parserResult = Parser.Parser.ParseMovieTitle(title, true);
|
||||
|
||||
var yearTerm = "";
|
||||
|
||||
|
@ -142,7 +142,7 @@ protected virtual Movie ProcessItem(XElement item, Movie releaseInfo)
|
||||
}
|
||||
|
||||
releaseInfo.Title = title;
|
||||
var result = Parser.Parser.ParseMovieTitle(title, false); //Depreciated anyways
|
||||
var result = Parser.Parser.ParseMovieTitle(title); //Depreciated anyways
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ public class FileNameValidationService : IFilenameValidationService
|
||||
public ValidationFailure ValidateMovieFilename(SampleResult sampleResult)
|
||||
{
|
||||
var validationFailure = new ValidationFailure("MovieFormat", ERROR_MESSAGE);
|
||||
var parsedMovieInfo = Parser.Parser.ParseMovieTitle(sampleResult.FileName, false); //We are not lenient when testing naming schemes
|
||||
var parsedMovieInfo = Parser.Parser.ParseMovieTitle(sampleResult.FileName);
|
||||
|
||||
if (parsedMovieInfo == null)
|
||||
{
|
||||
|
@ -22,6 +22,9 @@ public static class Parser
|
||||
|
||||
private static readonly Regex[] ReportMovieTitleRegex = new[]
|
||||
{
|
||||
//Some german or french tracker formats (missing year, ...) (Only applies to german and French/TrueFrench releases) - see ParserFixture for examples and tests
|
||||
new Regex(@"^(?<title>(?![(\[]).+?)((\W|_))(" + ReportEditionRegex + @".{1,3})?(?:(?<!(19|20)\d{2}.*?)(German|French|TrueFrench))(.+?)(?=((19|20)\d{2}|$))(?<year>(19|20)\d{2}(?!p|i|\d+|\]|\W\d+))?(\W+|_|$)(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
|
||||
//Special, Despecialized, etc. Edition Movies, e.g: Mission.Impossible.3.Special.Edition.2011
|
||||
new Regex(@"^(?<title>(?![(\[]).+?)?(?:(?:[-_\W](?<![)\[!]))*" + ReportEditionRegex + @".{1,3}(?<year>(1(8|9)|20)\d{2}(?!p|i|\d+|\]|\W\d+)))+(\W+|_|$)(?!\\)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
@ -49,16 +52,6 @@ public static class Parser
|
||||
new Regex(@"^(?:(?:[-_\W](?<![)!]))*(?<year>(19|20)\d{2}(?!p|i|\d+|\W\d+)))+(\W+|_|$)(?<title>.+?)?$")
|
||||
};
|
||||
|
||||
private static readonly Regex[] ReportMovieTitleLenientRegexBefore = new[]
|
||||
{
|
||||
//Some german or french tracker formats
|
||||
new Regex(@"^(?<title>(?![(\[]).+?)((\W|_))(" + ReportEditionRegex + @".{1,3})?(?:(?<!(19|20)\d{2}.*?)(German|French|TrueFrench))(.+?)(?=((19|20)\d{2}|$))(?<year>(19|20)\d{2}(?!p|i|\d+|\]|\W\d+))?(\W+|_|$)(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
};
|
||||
|
||||
private static readonly Regex[] ReportMovieTitleLenientRegexAfter = new Regex[]
|
||||
{
|
||||
};
|
||||
|
||||
private static readonly Regex[] RejectHashedReleasesRegex = new Regex[]
|
||||
{
|
||||
// Generic match for md5 and mixed-case hashes.
|
||||
@ -147,28 +140,28 @@ public static class Parser
|
||||
{ "ü", "ue" },
|
||||
};
|
||||
|
||||
public static ParsedMovieInfo ParseMoviePath(string path, bool isLenient)
|
||||
public static ParsedMovieInfo ParseMoviePath(string path)
|
||||
{
|
||||
var fileInfo = new FileInfo(path);
|
||||
|
||||
var result = ParseMovieTitle(fileInfo.Name, isLenient, true);
|
||||
var result = ParseMovieTitle(fileInfo.Name, true);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
Logger.Debug("Attempting to parse movie info using directory and file names. {0}", fileInfo.Directory.Name);
|
||||
result = ParseMovieTitle(fileInfo.Directory.Name + " " + fileInfo.Name, isLenient);
|
||||
result = ParseMovieTitle(fileInfo.Directory.Name + " " + fileInfo.Name);
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
Logger.Debug("Attempting to parse movie info using directory name. {0}", fileInfo.Directory.Name);
|
||||
result = ParseMovieTitle(fileInfo.Directory.Name + fileInfo.Extension, isLenient);
|
||||
result = ParseMovieTitle(fileInfo.Directory.Name + fileInfo.Extension);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ParsedMovieInfo ParseMovieTitle(string title, bool isLenient, bool isDir = false)
|
||||
public static ParsedMovieInfo ParseMovieTitle(string title, bool isDir = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -218,13 +211,6 @@ public static ParsedMovieInfo ParseMovieTitle(string title, bool isLenient, bool
|
||||
allRegexes.AddRange(ReportMovieTitleFolderRegex);
|
||||
}
|
||||
|
||||
if (isLenient)
|
||||
{
|
||||
allRegexes.InsertRange(0, ReportMovieTitleLenientRegexBefore);
|
||||
|
||||
allRegexes.AddRange(ReportMovieTitleLenientRegexAfter);
|
||||
}
|
||||
|
||||
foreach (var regex in allRegexes)
|
||||
{
|
||||
var match = regex.Matches(simpleTitle);
|
||||
|
@ -1,9 +0,0 @@
|
||||
namespace NzbDrone.Core.Parser
|
||||
{
|
||||
public enum ParsingLeniencyType
|
||||
{
|
||||
Strict = 0,
|
||||
ParsingLenient = 1,
|
||||
MappingLenient = 2,
|
||||
}
|
||||
}
|
@ -51,7 +51,7 @@ public ParsingService(IMovieService movieService,
|
||||
|
||||
public ParsedMovieInfo ParseMovieInfo(string title, List<object> helpers)
|
||||
{
|
||||
var result = Parser.ParseMovieTitle(title, _config.ParsingLeniency > 0);
|
||||
var result = Parser.ParseMovieTitle(title);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -88,7 +88,7 @@ private ParsedMovieInfo AugmentMovieInfo(ParsedMovieInfo minimalInfo, List<objec
|
||||
|
||||
public ParsedMovieInfo ParseMinimalMovieInfo(string file, bool isDir = false)
|
||||
{
|
||||
return Parser.ParseMovieTitle(file, _config.ParsingLeniency > 0, isDir);
|
||||
return Parser.ParseMovieTitle(file, isDir);
|
||||
}
|
||||
|
||||
public ParsedMovieInfo ParseMinimalPathMovieInfo(string path)
|
||||
@ -114,7 +114,7 @@ public ParsedMovieInfo ParseMinimalPathMovieInfo(string path)
|
||||
|
||||
public Movie GetMovie(string title)
|
||||
{
|
||||
var parsedMovieInfo = Parser.ParseMovieTitle(title, _config.ParsingLeniency > 0);
|
||||
var parsedMovieInfo = Parser.ParseMovieTitle(title);
|
||||
|
||||
if (parsedMovieInfo == null)
|
||||
{
|
||||
@ -220,16 +220,6 @@ private bool TryGetMovieByTitleAndOrYear(ParsedMovieInfo parsedMovieInfo, out Ma
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_config.ParsingLeniency == ParsingLeniencyType.MappingLenient)
|
||||
{
|
||||
movieByTitleAndOrYear = _movieService.FindByTitleInexact(parsedMovieInfo.MovieTitle, parsedMovieInfo.Year);
|
||||
if (isNotNull(movieByTitleAndOrYear))
|
||||
{
|
||||
result = new MappingResult { Movie = movieByTitleAndOrYear, MappingResultType = MappingResultType.SuccessLenientMapping };
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
result = new MappingResult { Movie = movieByTitleAndOrYear, MappingResultType = MappingResultType.TitleNotFound };
|
||||
return false;
|
||||
}
|
||||
@ -241,16 +231,6 @@ private bool TryGetMovieByTitleAndOrYear(ParsedMovieInfo parsedMovieInfo, out Ma
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_config.ParsingLeniency == ParsingLeniencyType.MappingLenient)
|
||||
{
|
||||
movieByTitleAndOrYear = _movieService.FindByTitleInexact(parsedMovieInfo.MovieTitle, null);
|
||||
if (isNotNull(movieByTitleAndOrYear))
|
||||
{
|
||||
result = new MappingResult { Movie = movieByTitleAndOrYear, MappingResultType = MappingResultType.SuccessLenientMapping };
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
result = new MappingResult { Movie = movieByTitleAndOrYear, MappingResultType = MappingResultType.TitleNotFound };
|
||||
return false;
|
||||
}
|
||||
@ -307,29 +287,6 @@ private bool TryGetMovieBySearchCriteria(ParsedMovieInfo parsedMovieInfo, Search
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_config.ParsingLeniency == ParsingLeniencyType.MappingLenient)
|
||||
{
|
||||
if (searchCriteria.Movie.CleanTitle.Contains(cleanTitle) ||
|
||||
cleanTitle.Contains(searchCriteria.Movie.CleanTitle))
|
||||
{
|
||||
possibleMovie = searchCriteria.Movie;
|
||||
if ((parsedMovieInfo.Year > 1800 && parsedMovieInfo.Year == possibleMovie.Year) || possibleMovie.SecondaryYear == parsedMovieInfo.Year)
|
||||
{
|
||||
result = new MappingResult { Movie = possibleMovie, MappingResultType = MappingResultType.SuccessLenientMapping };
|
||||
return true;
|
||||
}
|
||||
|
||||
if (parsedMovieInfo.Year < 1800)
|
||||
{
|
||||
result = new MappingResult { Movie = possibleMovie, MappingResultType = MappingResultType.SuccessLenientMapping };
|
||||
return true;
|
||||
}
|
||||
|
||||
result = new MappingResult { Movie = possibleMovie, MappingResultType = MappingResultType.WrongYear };
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
result = new MappingResult { Movie = searchCriteria.Movie, MappingResultType = MappingResultType.WrongTitle };
|
||||
|
||||
return false;
|
||||
@ -346,8 +303,6 @@ public string Message
|
||||
{
|
||||
case MappingResultType.Success:
|
||||
return $"Successfully mapped release name {ReleaseName} to movie {Movie}";
|
||||
case MappingResultType.SuccessLenientMapping:
|
||||
return $"Successfully mapped parts of the release name {ReleaseName} to movie {Movie}";
|
||||
case MappingResultType.NotParsable:
|
||||
return $"Failed to find movie title in release name {ReleaseName}";
|
||||
case MappingResultType.TitleNotFound:
|
||||
@ -400,7 +355,6 @@ public Rejection ToRejection()
|
||||
switch (MappingResultType)
|
||||
{
|
||||
case MappingResultType.Success:
|
||||
case MappingResultType.SuccessLenientMapping:
|
||||
return null;
|
||||
default:
|
||||
return new Rejection(Message);
|
||||
@ -412,7 +366,6 @@ public enum MappingResultType
|
||||
{
|
||||
Unknown = -1,
|
||||
Success = 0,
|
||||
SuccessLenientMapping = 1,
|
||||
WrongYear = 2,
|
||||
WrongTitle = 3,
|
||||
TitleNotFound = 4,
|
||||
|
@ -16,7 +16,7 @@ public static bool IsSceneTitle(string title)
|
||||
return false;
|
||||
}
|
||||
|
||||
var parsedTitle = Parser.ParseMovieTitle(title, false); //We are not lenient when it comes to scene checking!
|
||||
var parsedTitle = Parser.ParseMovieTitle(title);
|
||||
|
||||
if (parsedTitle == null ||
|
||||
parsedTitle.ReleaseGroup == null ||
|
||||
|
@ -14,7 +14,6 @@ public class IndexerConfigResource : RestResource
|
||||
public int AvailabilityDelay { get; set; }
|
||||
public bool AllowHardcodedSubs { get; set; }
|
||||
public string WhitelistedHardcodedSubs { get; set; }
|
||||
public ParsingLeniencyType ParsingLeniency { get; set; }
|
||||
}
|
||||
|
||||
public static class IndexerConfigResourceMapper
|
||||
@ -31,7 +30,6 @@ public static IndexerConfigResource ToResource(IConfigService model)
|
||||
AvailabilityDelay = model.AvailabilityDelay,
|
||||
AllowHardcodedSubs = model.AllowHardcodedSubs,
|
||||
WhitelistedHardcodedSubs = model.WhitelistedHardcodedSubs,
|
||||
ParsingLeniency = model.ParsingLeniency,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user