Fixed: Hopefully fixed sqlite errors when finding by title.

v0.2.0.1293
Leonardo Galli 6 years ago
parent 420cbf6dd0
commit e7ad09cf62

@ -234,40 +234,40 @@ namespace NzbDrone.Core.Movies
cleanTitleWithArabicNumbers = cleanTitleWithArabicNumbers.Replace(romanNumber, arabicNumber); cleanTitleWithArabicNumbers = cleanTitleWithArabicNumbers.Replace(romanNumber, arabicNumber);
} }
return Query(q => Movie result = Query(q =>
{
return q.Where(s => s.CleanTitle == cleanTitle).FirstWithYear(year);
});
if (result == null)
{ {
Movie result = q.Where(s => s.CleanTitle == cleanTitle).FirstWithYear(year); result =
Query(q => q.Where(movie => movie.CleanTitle == cleanTitleWithArabicNumbers).FirstWithYear(year)) ??
Query(q => q.Where(movie => movie.CleanTitle == cleanTitleWithRomanNumbers).FirstWithYear(year));
if (result == null) if (result == null)
{ {
result = /*IEnumerable<Movie> movies = All();
q.Where(movie => movie.CleanTitle == cleanTitleWithArabicNumbers).FirstWithYear(year) ?? Func<string, string> titleCleaner = title => CoreParser.CleanSeriesTitle(title.ToLower());
q.Where(movie => movie.CleanTitle == cleanTitleWithRomanNumbers).FirstWithYear(year); Func<IEnumerable<AlternativeTitle>, string, bool> altTitleComparer =
(alternativeTitles, atitle) =>
if (result == null) alternativeTitles.Any(altTitle => altTitle.CleanTitle == atitle);*/
{
/*IEnumerable<Movie> movies = All(); /*result = movies.Where(m => altTitleComparer(m.AlternativeTitles, cleanTitle) ||
Func<string, string> titleCleaner = title => CoreParser.CleanSeriesTitle(title.ToLower()); altTitleComparer(m.AlternativeTitles, cleanTitleWithRomanNumbers) ||
Func<IEnumerable<AlternativeTitle>, string, bool> altTitleComparer = altTitleComparer(m.AlternativeTitles, cleanTitleWithArabicNumbers)).FirstWithYear(year);*/
(alternativeTitles, atitle) =>
alternativeTitles.Any(altTitle => altTitle.CleanTitle == atitle);*/ //result = Query.Join<Movie, AlternativeTitle>(JoinType.Inner, m => m._newAltTitles,
//(m, t) => m.Id == t.MovieId && (t.CleanTitle == cleanTitle)).FirstWithYear(year);
/*result = movies.Where(m => altTitleComparer(m.AlternativeTitles, cleanTitle) || result = Query(q => q.Where<AlternativeTitle>(t =>
altTitleComparer(m.AlternativeTitles, cleanTitleWithRomanNumbers) || t.CleanTitle == cleanTitle || t.CleanTitle == cleanTitleWithArabicNumbers
altTitleComparer(m.AlternativeTitles, cleanTitleWithArabicNumbers)).FirstWithYear(year);*/ || t.CleanTitle == cleanTitleWithRomanNumbers)
.FirstWithYear(year));
//result = Query.Join<Movie, AlternativeTitle>(JoinType.Inner, m => m._newAltTitles,
//(m, t) => m.Id == t.MovieId && (t.CleanTitle == cleanTitle)).FirstWithYear(year);
result = q.Where<AlternativeTitle>(t =>
t.CleanTitle == cleanTitle || t.CleanTitle == cleanTitleWithArabicNumbers
|| t.CleanTitle == cleanTitleWithRomanNumbers)
.FirstWithYear(year);
}
} }
}
return result; return result;
});
/*return year.HasValue /*return year.HasValue
? results?.FirstOrDefault(movie => movie.Year == year.Value) ? results?.FirstOrDefault(movie => movie.Year == year.Value)

Loading…
Cancel
Save