|
|
|
@ -19,6 +19,21 @@ namespace NzbDrone.Core.Tv
|
|
|
|
|
|
|
|
|
|
public class MovieRepository : BasicRepository<Movie>, IMovieRepository
|
|
|
|
|
{
|
|
|
|
|
private readonly Dictionary<string, string> romanNumeralsMapper = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "1", "I"},
|
|
|
|
|
{ "2", "II"},
|
|
|
|
|
{ "3", "III"},
|
|
|
|
|
{ "4", "IV"},
|
|
|
|
|
{ "5", "V"},
|
|
|
|
|
{ "6", "VI"},
|
|
|
|
|
{ "7", "VII"},
|
|
|
|
|
{ "8", "VII"},
|
|
|
|
|
{ "9", "IX"},
|
|
|
|
|
{ "10", "X"},
|
|
|
|
|
|
|
|
|
|
}; //If a movie has more than 10 parts fuck 'em.
|
|
|
|
|
|
|
|
|
|
public MovieRepository(IMainDatabase database, IEventAggregator eventAggregator)
|
|
|
|
|
: base(database, eventAggregator)
|
|
|
|
|
{
|
|
|
|
@ -33,8 +48,46 @@ namespace NzbDrone.Core.Tv
|
|
|
|
|
{
|
|
|
|
|
cleanTitle = cleanTitle.ToLowerInvariant();
|
|
|
|
|
|
|
|
|
|
return Query.Where(s => s.CleanTitle == cleanTitle)
|
|
|
|
|
.SingleOrDefault();
|
|
|
|
|
var cleanRoman = cleanTitle;
|
|
|
|
|
|
|
|
|
|
var cleanNum = cleanTitle;
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<string, string> entry in romanNumeralsMapper)
|
|
|
|
|
{
|
|
|
|
|
string num = entry.Key;
|
|
|
|
|
string roman = entry.Value.ToLower();
|
|
|
|
|
|
|
|
|
|
cleanRoman = cleanRoman.Replace(num, roman);
|
|
|
|
|
|
|
|
|
|
cleanNum = cleanNum.Replace(roman, num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = Query.Where(s => s.CleanTitle == cleanTitle).SingleOrDefault();
|
|
|
|
|
|
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
result = Query.Where(s => s.CleanTitle == cleanNum).OrWhere(s => s.CleanTitle == cleanRoman).SingleOrDefault();
|
|
|
|
|
|
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
var movies = this.All();
|
|
|
|
|
|
|
|
|
|
result = movies.Where(m => m.AlternativeTitles.Any(t => Parser.Parser.CleanSeriesTitle(t.ToLower()) == cleanTitle ||
|
|
|
|
|
Parser.Parser.CleanSeriesTitle(t.ToLower()) == cleanRoman ||
|
|
|
|
|
Parser.Parser.CleanSeriesTitle(t.ToLower()) == cleanNum)).SingleOrDefault();
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Movie FindByTitle(string cleanTitle, int year)
|
|
|
|
|