mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
CouchPotato - Change prefilter to allow results with no year #158
This commit is contained in:
@@ -12,6 +12,8 @@ namespace Jackett.Utils
|
|||||||
{
|
{
|
||||||
static Regex reduceSpacesRegex = new Regex("\\s{2,}", RegexOptions.Compiled);
|
static Regex reduceSpacesRegex = new Regex("\\s{2,}", RegexOptions.Compiled);
|
||||||
|
|
||||||
|
static Regex findYearRegex = new Regex(@"(?<=\[|\(|\s)(\d{4})(?=\]|\)|\s)", RegexOptions.Compiled);
|
||||||
|
|
||||||
public static TorznabCapabilities CreateDefaultTorznabTVCaps()
|
public static TorznabCapabilities CreateDefaultTorznabTVCaps()
|
||||||
{
|
{
|
||||||
var caps = new TorznabCapabilities();
|
var caps = new TorznabCapabilities();
|
||||||
@@ -23,7 +25,22 @@ namespace Jackett.Utils
|
|||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<ReleaseInfo> FilterResultsToTitle(IEnumerable<ReleaseInfo> results, string name, int year)
|
private static int GetYearFromTitle(string title)
|
||||||
|
{
|
||||||
|
var match = findYearRegex.Match(title);
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
var year = ParseUtil.CoerceInt(match.Value);
|
||||||
|
if(year>1850 && year < 2100)
|
||||||
|
{
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<ReleaseInfo> FilterResultsToTitle(IEnumerable<ReleaseInfo> results, string name, int imdbYear)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
return results;
|
return results;
|
||||||
@@ -34,12 +51,18 @@ namespace Jackett.Utils
|
|||||||
{
|
{
|
||||||
if (result.Title == null)
|
if (result.Title == null)
|
||||||
continue;
|
continue;
|
||||||
if (CleanTitle(result.Title).Contains(name) &&
|
|
||||||
(year ==0 || result.Title.Contains(year.ToString())))
|
// Match on title
|
||||||
|
if (CleanTitle(result.Title).Contains(name))
|
||||||
|
{
|
||||||
|
// Match on year
|
||||||
|
var titleYear = GetYearFromTitle(result.Title);
|
||||||
|
if (imdbYear == 0 || titleYear == 0 || titleYear == imdbYear)
|
||||||
{
|
{
|
||||||
filteredResults.Add(result);
|
filteredResults.Add(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return filteredResults;
|
return filteredResults;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user