mirror of
https://github.com/Jackett/Jackett
synced 2025-02-25 15:42:48 +00:00
Newpct: optionally remove year from movies (#7597)
This commit is contained in:
parent
4bd4d9cb0f
commit
538fa6a38d
1 changed files with 22 additions and 0 deletions
|
@ -85,6 +85,7 @@ namespace Jackett.Common.Indexers
|
||||||
private readonly Regex _titleListRegex = new Regex(@"Serie( *Descargar)?(.+?)(Temporada(.+?)(\d+)(.+?))?Capitulos?(.+?)(\d+)((.+?)(\d+))?(.+?)-(.+?)Calidad(.*)", RegexOptions.IgnoreCase);
|
private readonly Regex _titleListRegex = new Regex(@"Serie( *Descargar)?(.+?)(Temporada(.+?)(\d+)(.+?))?Capitulos?(.+?)(\d+)((.+?)(\d+))?(.+?)-(.+?)Calidad(.*)", RegexOptions.IgnoreCase);
|
||||||
private readonly Regex _titleClassicRegex = new Regex(@"(\[[^\]]*\])?\[Cap\.(\d{1,2})(\d{2})([_-](\d{1,2})(\d{2}))?\]", RegexOptions.IgnoreCase);
|
private readonly Regex _titleClassicRegex = new Regex(@"(\[[^\]]*\])?\[Cap\.(\d{1,2})(\d{2})([_-](\d{1,2})(\d{2}))?\]", RegexOptions.IgnoreCase);
|
||||||
private readonly Regex _titleClassicTvQualityRegex = new Regex(@"\[([^\]]*HDTV[^\]]*)", RegexOptions.IgnoreCase);
|
private readonly Regex _titleClassicTvQualityRegex = new Regex(@"\[([^\]]*HDTV[^\]]*)", RegexOptions.IgnoreCase);
|
||||||
|
private readonly Regex _titleYearRegex = new Regex(@"[\[\(] *(\d{4}) *[\]\)]");
|
||||||
private readonly DownloadMatcher[] _downloadMatchers = new DownloadMatcher[]
|
private readonly DownloadMatcher[] _downloadMatchers = new DownloadMatcher[]
|
||||||
{
|
{
|
||||||
new DownloadMatcher()
|
new DownloadMatcher()
|
||||||
|
@ -103,10 +104,13 @@ namespace Jackett.Common.Indexers
|
||||||
private readonly int _maxEpisodesListPages = 100;
|
private readonly int _maxEpisodesListPages = 100;
|
||||||
private readonly int[] _allTvCategories = (new TorznabCategory[] { TorznabCatType.TV }).Concat(TorznabCatType.TV.SubCategories).Select(c => c.ID).ToArray();
|
private readonly int[] _allTvCategories = (new TorznabCategory[] { TorznabCatType.TV }).Concat(TorznabCatType.TV.SubCategories).Select(c => c.ID).ToArray();
|
||||||
private readonly int[] _allMoviesCategories = (new TorznabCategory[] { TorznabCatType.Movies }).Concat(TorznabCatType.Movies.SubCategories).Select(c => c.ID).ToArray();
|
private readonly int[] _allMoviesCategories = (new TorznabCategory[] { TorznabCatType.Movies }).Concat(TorznabCatType.Movies.SubCategories).Select(c => c.ID).ToArray();
|
||||||
|
private readonly int _firstYearAllowed = 1885;
|
||||||
|
private readonly int _lastYearAllowedFromNow = 3;
|
||||||
|
|
||||||
private bool _includeVo;
|
private bool _includeVo;
|
||||||
private bool _filterMovies;
|
private bool _filterMovies;
|
||||||
private bool _removeMovieAccents;
|
private bool _removeMovieAccents;
|
||||||
|
private bool _removeMovieYear;
|
||||||
private DateTime _dailyNow;
|
private DateTime _dailyNow;
|
||||||
private int _dailyResultIdx;
|
private int _dailyResultIdx;
|
||||||
|
|
||||||
|
@ -146,6 +150,9 @@ namespace Jackett.Common.Indexers
|
||||||
|
|
||||||
var removeMovieAccentsItem = new BoolItem() { Name = "Remove accents in movie searchs", Value = true };
|
var removeMovieAccentsItem = new BoolItem() { Name = "Remove accents in movie searchs", Value = true };
|
||||||
configData.AddDynamic("RemoveMovieAccents", removeMovieAccentsItem);
|
configData.AddDynamic("RemoveMovieAccents", removeMovieAccentsItem);
|
||||||
|
|
||||||
|
var removeMovieYearItem = new BoolItem() { Name = "Remove year from movie results", Value = false };
|
||||||
|
configData.AddDynamic("RemoveMovieYear", removeMovieYearItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||||
|
@ -257,6 +264,7 @@ namespace Jackett.Common.Indexers
|
||||||
_includeVo = ((BoolItem)configData.GetDynamic("IncludeVo")).Value;
|
_includeVo = ((BoolItem)configData.GetDynamic("IncludeVo")).Value;
|
||||||
_filterMovies = ((BoolItem)configData.GetDynamic("FilterMovies")).Value;
|
_filterMovies = ((BoolItem)configData.GetDynamic("FilterMovies")).Value;
|
||||||
_removeMovieAccents = ((BoolItem)configData.GetDynamic("RemoveMovieAccents")).Value;
|
_removeMovieAccents = ((BoolItem)configData.GetDynamic("RemoveMovieAccents")).Value;
|
||||||
|
_removeMovieYear = ((BoolItem)configData.GetDynamic("RemoveMovieYear")).Value;
|
||||||
_dailyNow = DateTime.Now;
|
_dailyNow = DateTime.Now;
|
||||||
_dailyResultIdx = 0;
|
_dailyResultIdx = 0;
|
||||||
var rssMode = string.IsNullOrEmpty(query.SanitizedSearchTerm);
|
var rssMode = string.IsNullOrEmpty(query.SanitizedSearchTerm);
|
||||||
|
@ -957,6 +965,20 @@ namespace Jackett.Common.Indexers
|
||||||
|
|
||||||
var result = string.Join(".", titleParts);
|
var result = string.Join(".", titleParts);
|
||||||
|
|
||||||
|
if (release.NewpctReleaseType == ReleaseType.Movie)
|
||||||
|
{
|
||||||
|
if (_removeMovieYear)
|
||||||
|
{
|
||||||
|
Match match = _titleYearRegex.Match(result);
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
int year = int.Parse(match.Groups[1].Value);
|
||||||
|
if (year >= _firstYearAllowed && year <= DateTime.Now.Year + _lastYearAllowedFromNow)
|
||||||
|
result = result.Replace(match.Groups[0].Value, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result = Regex.Replace(result, @"[\[\]]+", ".");
|
result = Regex.Replace(result, @"[\[\]]+", ".");
|
||||||
result = Regex.Replace(result, @"\.[ \.]*\.", ".");
|
result = Regex.Replace(result, @"\.[ \.]*\.", ".");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue