mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 09:21:57 +00:00
parent
ef8ba37d0e
commit
6d0019ad00
4 changed files with 40 additions and 2 deletions
|
@ -120,6 +120,15 @@ public void should_parse_movie_year(string postTitle, int year)
|
|||
Parser.Parser.ParseMovieTitle(postTitle).Year.Should().Be(year);
|
||||
}
|
||||
|
||||
[TestCase("Ghostbusters (2016) {tmdbid-43074}", 43074)]
|
||||
[TestCase("Ghostbusters (2016) [tmdb-43074]", 43074)]
|
||||
[TestCase("Ghostbusters (2016) {tmdb-43074}", 43074)]
|
||||
[TestCase("Ghostbusters (2016) {tmdb-2020}", 2020)]
|
||||
public void should_parse_tmdb_id(string postTitle, int tmdbId)
|
||||
{
|
||||
Parser.Parser.ParseMovieTitle(postTitle).TmdbId.Should().Be(tmdbId);
|
||||
}
|
||||
|
||||
[TestCase("Prometheus 2012 Directors Cut", "Directors Cut")]
|
||||
[TestCase("Star Wars Episode IV - A New Hope 1999 (Despecialized).mkv", "Despecialized")]
|
||||
[TestCase("Prometheus.2012.(Special.Edition.Remastered).[Bluray-1080p].mkv", "Special Edition Remastered")]
|
||||
|
|
|
@ -336,6 +336,19 @@ public List<Movie> SearchForNewMovie(string title)
|
|||
return new List<Movie>();
|
||||
}
|
||||
}
|
||||
|
||||
if (parserResult.TmdbId > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var movieLookup = GetMovieInfo(parserResult.TmdbId).Item1;
|
||||
return movieLookup == null ? new List<Movie>() : new List<Movie> { _movieService.FindByTmdbId(movieLookup.TmdbId) ?? movieLookup };
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return new List<Movie>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parserTitle = StripTrailingTheFromTitle(parserTitle);
|
||||
|
|
|
@ -18,6 +18,7 @@ public class ParsedMovieInfo
|
|||
public string Edition { get; set; }
|
||||
public int Year { get; set; }
|
||||
public string ImdbId { get; set; }
|
||||
public int TmdbId { get; set; }
|
||||
[JsonIgnore]
|
||||
public Dictionary<string, object> ExtraInfo { get; set; } = new Dictionary<string, object>();
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ public static class Parser
|
|||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex ReportImdbId = new Regex(@"(?<imdbid>tt\d{7,8})", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
private static readonly Regex ReportTmdbId = new Regex(@"tmdb(id)?-(?<tmdbid>\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
private static readonly RegexReplace SimpleTitleRegex = new RegexReplace(@"\s*(?:480[ip]|576[ip]|720[ip]|1080[ip]|2160[ip]|[xh][\W_]?26[45]|DD\W?5\W1|[<>?*:|]|848x480|1280x720|1920x1080|(8|10)b(it)?)",
|
||||
string.Empty,
|
||||
|
@ -274,6 +275,7 @@ public static ParsedMovieInfo ParseMovieTitle(string title, bool isDir = false)
|
|||
result.SimpleReleaseTitle = simpleReleaseTitle;
|
||||
|
||||
result.ImdbId = ParseImdbId(simpleReleaseTitle);
|
||||
result.TmdbId = ParseTmdbId(simpleReleaseTitle);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -315,6 +317,20 @@ public static string ParseImdbId(string title)
|
|||
return "";
|
||||
}
|
||||
|
||||
public static int ParseTmdbId(string title)
|
||||
{
|
||||
var match = ReportTmdbId.Match(title);
|
||||
if (match.Success)
|
||||
{
|
||||
if (match.Groups["tmdbid"].Value != null)
|
||||
{
|
||||
return int.TryParse(match.Groups["tmdbid"].Value, out var tmdbId) ? tmdbId : 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static string ParseEdition(string languageTitle)
|
||||
{
|
||||
var editionMatch = ReportEditionRegex.Match(languageTitle);
|
||||
|
@ -522,8 +538,7 @@ private static ParsedMovieInfo ParseMovieMatchCollection(MatchCollection matchCo
|
|||
|
||||
movieName = movieName.Trim(' ');
|
||||
|
||||
int airYear;
|
||||
int.TryParse(matchCollection[0].Groups["year"].Value, out airYear);
|
||||
int.TryParse(matchCollection[0].Groups["year"].Value, out var airYear);
|
||||
|
||||
ParsedMovieInfo result;
|
||||
|
||||
|
|
Loading…
Reference in a new issue