|
|
@ -2,7 +2,7 @@ using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
|
|
using NzbDrone.Core.Movies;
|
|
|
|
using NzbDrone.Core.Movies;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
@ -13,7 +13,7 @@ namespace NzbDrone.Core.Parser
|
|
|
|
public interface IParsingService
|
|
|
|
public interface IParsingService
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Movie GetMovie(string title);
|
|
|
|
Movie GetMovie(string title);
|
|
|
|
RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchCriteriaBase searchCriteria = null);
|
|
|
|
RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, string imdbId, int tmdbId, SearchCriteriaBase searchCriteria = null);
|
|
|
|
RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, int movieId);
|
|
|
|
RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, int movieId);
|
|
|
|
ParsedMovieInfo ParseMinimalPathMovieInfo(string path);
|
|
|
|
ParsedMovieInfo ParseMinimalPathMovieInfo(string path);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -67,7 +67,9 @@ namespace NzbDrone.Core.Parser
|
|
|
|
return _movieService.FindByTitle(title);
|
|
|
|
return _movieService.FindByTitle(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (TryGetMovieByTitleAndOrYear(parsedMovieInfo, out var result))
|
|
|
|
var result = TryGetMovieByTitleAndOrYear(parsedMovieInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return result.Movie;
|
|
|
|
return result.Movie;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -75,9 +77,9 @@ namespace NzbDrone.Core.Parser
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchCriteriaBase searchCriteria = null)
|
|
|
|
public RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, string imdbId, int tmdbId, SearchCriteriaBase searchCriteria = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Map(parsedMovieInfo, imdbId, null, searchCriteria);
|
|
|
|
return Map(parsedMovieInfo, imdbId, tmdbId, null, searchCriteria);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, int movieId)
|
|
|
|
public RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, int movieId)
|
|
|
@ -89,7 +91,7 @@ namespace NzbDrone.Core.Parser
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, string imdbId, Movie movie, SearchCriteriaBase searchCriteria)
|
|
|
|
public RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, string imdbId, int tmdbId, Movie movie, SearchCriteriaBase searchCriteria)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var remoteMovie = new RemoteMovie
|
|
|
|
var remoteMovie = new RemoteMovie
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -98,7 +100,7 @@ namespace NzbDrone.Core.Parser
|
|
|
|
|
|
|
|
|
|
|
|
if (movie == null)
|
|
|
|
if (movie == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var movieMatch = FindMovie(parsedMovieInfo, imdbId, searchCriteria);
|
|
|
|
var movieMatch = FindMovie(parsedMovieInfo, imdbId, tmdbId, searchCriteria);
|
|
|
|
|
|
|
|
|
|
|
|
if (movieMatch != null)
|
|
|
|
if (movieMatch != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -117,62 +119,67 @@ namespace NzbDrone.Core.Parser
|
|
|
|
return remoteMovie;
|
|
|
|
return remoteMovie;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private FindMovieResult FindMovie(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchCriteriaBase searchCriteria)
|
|
|
|
private FindMovieResult FindMovie(ParsedMovieInfo parsedMovieInfo, string imdbId, int tmdbId, SearchCriteriaBase searchCriteria)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FindMovieResult result = null;
|
|
|
|
FindMovieResult result = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(imdbId) && imdbId != "0")
|
|
|
|
if (!string.IsNullOrWhiteSpace(imdbId) && imdbId != "0")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (TryGetMovieByImDbId(parsedMovieInfo, imdbId, out result))
|
|
|
|
result = TryGetMovieByImDbId(parsedMovieInfo, imdbId);
|
|
|
|
{
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result == null && tmdbId > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result = TryGetMovieByTmdbId(parsedMovieInfo, tmdbId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (searchCriteria != null)
|
|
|
|
if (result == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (TryGetMovieBySearchCriteria(parsedMovieInfo, searchCriteria, out result))
|
|
|
|
if (searchCriteria != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return result;
|
|
|
|
result = TryGetMovieBySearchCriteria(parsedMovieInfo, imdbId, tmdbId, searchCriteria);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (TryGetMovieByTitleAndOrYear(parsedMovieInfo, out result))
|
|
|
|
result = TryGetMovieByTitleAndOrYear(parsedMovieInfo);
|
|
|
|
{
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// nothing found up to here => logging that and returning null
|
|
|
|
if (result == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
_logger.Debug($"No matching movie for titles {string.Join(", ", parsedMovieInfo.MovieTitles)} ({parsedMovieInfo.Year})");
|
|
|
|
_logger.Debug($"No matching movie for titles {string.Join(", ", parsedMovieInfo.MovieTitles)} ({parsedMovieInfo.Year})");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool TryGetMovieByImDbId(ParsedMovieInfo parsedMovieInfo, string imdbId, out FindMovieResult result)
|
|
|
|
private FindMovieResult TryGetMovieByImDbId(ParsedMovieInfo parsedMovieInfo, string imdbId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var movie = _movieService.FindByImdbId(imdbId);
|
|
|
|
var movie = _movieService.FindByImdbId(imdbId);
|
|
|
|
|
|
|
|
|
|
|
|
// Should fix practically all problems, where indexer is shite at adding correct imdbids to movies.
|
|
|
|
// Should fix practically all problems, where indexer is shite at adding correct imdbids to movies.
|
|
|
|
if (movie != null && parsedMovieInfo.Year > 1800 && (parsedMovieInfo.Year != movie.MovieMetadata.Value.Year && movie.MovieMetadata.Value.SecondaryYear != parsedMovieInfo.Year))
|
|
|
|
if (movie != null && (parsedMovieInfo.Year < 1800 || movie.MovieMetadata.Value.Year == parsedMovieInfo.Year || movie.MovieMetadata.Value.SecondaryYear == parsedMovieInfo.Year))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = new FindMovieResult(movie, MovieMatchType.Id);
|
|
|
|
return new FindMovieResult(movie, MovieMatchType.Id);
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (movie != null)
|
|
|
|
return null;
|
|
|
|
{
|
|
|
|
|
|
|
|
result = new FindMovieResult(movie, MovieMatchType.Id);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
|
|
private FindMovieResult TryGetMovieByTmdbId(ParsedMovieInfo parsedMovieInfo, int tmdbId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = new FindMovieResult(movie, MovieMatchType.Unknown);
|
|
|
|
var movie = _movieService.FindByTmdbId(tmdbId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Should fix practically all problems, where indexer is shite at adding correct imdbids to movies.
|
|
|
|
|
|
|
|
if (movie != null && (parsedMovieInfo.Year < 1800 || movie.MovieMetadata.Value.Year == parsedMovieInfo.Year || movie.MovieMetadata.Value.SecondaryYear == parsedMovieInfo.Year))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new FindMovieResult(movie, MovieMatchType.Id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return movie != null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool TryGetMovieByTitleAndOrYear(ParsedMovieInfo parsedMovieInfo, out FindMovieResult result)
|
|
|
|
private FindMovieResult TryGetMovieByTitleAndOrYear(ParsedMovieInfo parsedMovieInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var candidates = _movieService.FindByTitleCandidates(parsedMovieInfo.MovieTitles, out var otherTitles);
|
|
|
|
var candidates = _movieService.FindByTitleCandidates(parsedMovieInfo.MovieTitles, out var otherTitles);
|
|
|
|
|
|
|
|
|
|
|
@ -182,8 +189,7 @@ namespace NzbDrone.Core.Parser
|
|
|
|
movieByTitleAndOrYear = _movieService.FindByTitle(parsedMovieInfo.MovieTitles, parsedMovieInfo.Year, otherTitles, candidates);
|
|
|
|
movieByTitleAndOrYear = _movieService.FindByTitle(parsedMovieInfo.MovieTitles, parsedMovieInfo.Year, otherTitles, candidates);
|
|
|
|
if (movieByTitleAndOrYear != null)
|
|
|
|
if (movieByTitleAndOrYear != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = new FindMovieResult(movieByTitleAndOrYear, MovieMatchType.Title);
|
|
|
|
return new FindMovieResult(movieByTitleAndOrYear, MovieMatchType.Title);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Only default to not using year when one is parsed if only one movie candidate exists
|
|
|
|
// Only default to not using year when one is parsed if only one movie candidate exists
|
|
|
@ -192,33 +198,31 @@ namespace NzbDrone.Core.Parser
|
|
|
|
movieByTitleAndOrYear = _movieService.FindByTitle(parsedMovieInfo.MovieTitles, null, otherTitles, candidates);
|
|
|
|
movieByTitleAndOrYear = _movieService.FindByTitle(parsedMovieInfo.MovieTitles, null, otherTitles, candidates);
|
|
|
|
if (movieByTitleAndOrYear != null)
|
|
|
|
if (movieByTitleAndOrYear != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = new FindMovieResult(movieByTitleAndOrYear, MovieMatchType.Title);
|
|
|
|
return new FindMovieResult(movieByTitleAndOrYear, MovieMatchType.Title);
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = new FindMovieResult(movieByTitleAndOrYear, MovieMatchType.Unknown);
|
|
|
|
return null;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
movieByTitleAndOrYear = _movieService.FindByTitle(parsedMovieInfo.MovieTitles, null, otherTitles, candidates);
|
|
|
|
movieByTitleAndOrYear = _movieService.FindByTitle(parsedMovieInfo.MovieTitles, null, otherTitles, candidates);
|
|
|
|
if (movieByTitleAndOrYear != null)
|
|
|
|
if (movieByTitleAndOrYear != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = new FindMovieResult(movieByTitleAndOrYear, MovieMatchType.Title);
|
|
|
|
return new FindMovieResult(movieByTitleAndOrYear, MovieMatchType.Title);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = new FindMovieResult(movieByTitleAndOrYear, MovieMatchType.Unknown);
|
|
|
|
return null;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool TryGetMovieBySearchCriteria(ParsedMovieInfo parsedMovieInfo, SearchCriteriaBase searchCriteria, out FindMovieResult result)
|
|
|
|
private FindMovieResult TryGetMovieBySearchCriteria(ParsedMovieInfo parsedMovieInfo, string imdbId, int tmdbId, SearchCriteriaBase searchCriteria)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Movie possibleMovie = null;
|
|
|
|
Movie possibleMovie = null;
|
|
|
|
|
|
|
|
|
|
|
|
var possibleTitles = new List<string>();
|
|
|
|
var possibleTitles = new List<string>
|
|
|
|
|
|
|
|
{
|
|
|
|
possibleTitles.Add(searchCriteria.Movie.MovieMetadata.Value.CleanTitle);
|
|
|
|
searchCriteria.Movie.MovieMetadata.Value.CleanTitle
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
possibleTitles.AddIfNotNull(searchCriteria.Movie.MovieMetadata.Value.CleanOriginalTitle);
|
|
|
|
possibleTitles.AddRange(searchCriteria.Movie.MovieMetadata.Value.AlternativeTitles.Select(t => t.CleanTitle));
|
|
|
|
possibleTitles.AddRange(searchCriteria.Movie.MovieMetadata.Value.AlternativeTitles.Select(t => t.CleanTitle));
|
|
|
|
possibleTitles.AddRange(searchCriteria.Movie.MovieMetadata.Value.Translations.Select(t => t.CleanTitle));
|
|
|
|
possibleTitles.AddRange(searchCriteria.Movie.MovieMetadata.Value.Translations.Select(t => t.CleanTitle));
|
|
|
|
|
|
|
|
|
|
|
@ -237,17 +241,21 @@ namespace NzbDrone.Core.Parser
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (parsedMovieInfo.Year < 1800 || possibleMovie.MovieMetadata.Value.Year == parsedMovieInfo.Year || possibleMovie.MovieMetadata.Value.SecondaryYear == parsedMovieInfo.Year)
|
|
|
|
if (parsedMovieInfo.Year < 1800 || possibleMovie.MovieMetadata.Value.Year == parsedMovieInfo.Year || possibleMovie.MovieMetadata.Value.SecondaryYear == parsedMovieInfo.Year)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = new FindMovieResult(possibleMovie, MovieMatchType.Title);
|
|
|
|
return new FindMovieResult(possibleMovie, MovieMatchType.Title);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = new FindMovieResult(possibleMovie, MovieMatchType.Title);
|
|
|
|
if (tmdbId > 0 && tmdbId == searchCriteria.Movie.TmdbId)
|
|
|
|
return false;
|
|
|
|
{
|
|
|
|
|
|
|
|
return new FindMovieResult(searchCriteria.Movie, MovieMatchType.Id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = new FindMovieResult(searchCriteria.Movie, MovieMatchType.Unknown);
|
|
|
|
if (imdbId.IsNotNullOrWhiteSpace() && imdbId == searchCriteria.Movie.ImdbId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new FindMovieResult(searchCriteria.Movie, MovieMatchType.Id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|