mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-16 07:19:51 +02:00
Fixed: Actually make SimpleReleaseTitle work
This commit is contained in:
parent
789e47dfff
commit
5761ce640b
@ -1,5 +1,7 @@
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
@ -119,6 +121,14 @@ public void should_parse_edition(string postTitle, string edition)
|
||||
parsed.Edition.Should().Be(edition);
|
||||
}
|
||||
|
||||
[TestCase("The.Italian.Job.2008.720p.BluRay.X264-AMIABLE")]
|
||||
public void should_not_parse_wrong_language_in_title(string postTitle)
|
||||
{
|
||||
var parsed = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
parsed.Languages.Count().Should().Be(1);
|
||||
parsed.Languages.First().Should().Be(Language.English);
|
||||
}
|
||||
|
||||
[TestCase("123", "tt0000123")]
|
||||
[TestCase("1234567", "tt1234567")]
|
||||
[TestCase("tt1234567", "tt1234567")]
|
||||
|
@ -177,7 +177,7 @@ private ManualImportItem ProcessFile(string rootFolder, string baseFolder, strin
|
||||
var localMovie = new LocalMovie();
|
||||
localMovie.Path = file;
|
||||
localMovie.Quality = QualityParser.ParseQuality(file);
|
||||
localMovie.Languages = LanguageParser.EnhanceLanguages(file, LanguageParser.ParseLanguages(file));
|
||||
localMovie.Languages = LanguageParser.ParseLanguages(file);
|
||||
localMovie.Size = _diskProvider.GetFileSize(file);
|
||||
|
||||
return MapItem(new ImportDecision(localMovie, new Rejection("Unknown Movie")), rootFolder, downloadId, null);
|
||||
|
@ -181,11 +181,6 @@ public static List<Language> ParseLanguages(string title)
|
||||
languages.Add(Language.Czech);
|
||||
}
|
||||
|
||||
return languages.DistinctBy(l => (int)l).ToList();
|
||||
}
|
||||
|
||||
public static List<Language> EnhanceLanguages(string title, List<Language> languages)
|
||||
{
|
||||
if (title.ToLower().Contains("multi"))
|
||||
{
|
||||
//Let's add english language to multi release as a safe guard.
|
||||
@ -200,7 +195,7 @@ public static List<Language> EnhanceLanguages(string title, List<Language> langu
|
||||
languages.Add(Language.English);
|
||||
}
|
||||
|
||||
return languages;
|
||||
return languages.DistinctBy(l => (int)l).ToList();
|
||||
}
|
||||
|
||||
public static Language ParseSubtitleLanguage(string fileName)
|
||||
|
@ -241,12 +241,14 @@ public static ParsedMovieInfo ParseMovieTitle(string title, bool isLenient, bool
|
||||
//TODO: Add tests for this!
|
||||
var simpleReleaseTitle = SimpleReleaseTitleRegex.Replace(title, string.Empty);
|
||||
|
||||
if (result.MovieTitle.IsNotNullOrWhiteSpace())
|
||||
var simpleTitleReplaceString = match[0].Groups["title"].Success ? match[0].Groups["title"].Value : result.MovieTitle;
|
||||
|
||||
if (simpleTitleReplaceString.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
simpleReleaseTitle = simpleReleaseTitle.Replace(result.MovieTitle, result.MovieTitle.Contains(".") ? "A.Movie" : "A Movie");
|
||||
simpleReleaseTitle = simpleReleaseTitle.Replace(simpleTitleReplaceString, simpleTitleReplaceString.Contains(".") ? "A.Movie" : "A Movie");
|
||||
}
|
||||
|
||||
result.Languages = LanguageParser.EnhanceLanguages(simpleReleaseTitle, LanguageParser.ParseLanguages(releaseTitle));
|
||||
result.Languages = LanguageParser.ParseLanguages(simpleReleaseTitle);
|
||||
Logger.Debug("Languages parsed: {0}", string.Join(", ", result.Languages));
|
||||
|
||||
result.Quality = QualityParser.ParseQuality(title);
|
||||
@ -472,7 +474,7 @@ private static ParsedMovieInfo ParseMovieMatchCollection(MatchCollection matchCo
|
||||
return null;
|
||||
}
|
||||
|
||||
var movieName = matchCollection[0].Groups["title"].Value./*Replace('.', ' ').*/Replace('_', ' ');
|
||||
var movieName = matchCollection[0].Groups["title"].Value.Replace('_', ' ');
|
||||
movieName = RequestInfoRegex.Replace(movieName, "").Trim(' ');
|
||||
|
||||
var parts = movieName.Split('.');
|
||||
|
Loading…
Reference in New Issue
Block a user