New: Add support for MaxAge to Newznab API

pull/1855/head
Qstick 1 year ago
parent 7dbfa74c40
commit 8d035c6c1f

@ -17,6 +17,10 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
public string SearchType { get; set; }
public int? Limit { get; set; }
public int? Offset { get; set; }
public int? MinAge { get; set; }
public int? MaxAge { get; set; }
public long? MinSize { get; set; }
public long? MaxSize { get; set; }
public string Source { get; set; }
public string Host { get; set; }

@ -18,6 +18,10 @@ namespace NzbDrone.Core.IndexerSearch
public string extended { get; set; }
public int? limit { get; set; }
public int? offset { get; set; }
public int? minage { get; set; }
public int? maxage { get; set; }
public long? minsize { get; set; }
public long? maxsize { get; set; }
public int? rid { get; set; }
public int? tvmazeid { get; set; }
public int? traktid { get; set; }

@ -139,6 +139,10 @@ namespace NzbDrone.Core.IndexerSearch
spec.SearchType = query.t;
spec.Limit = query.limit;
spec.Offset = query.offset;
spec.MinAge = query.minage;
spec.MaxAge = query.maxage;
spec.MinSize = query.minsize;
spec.MaxSize = query.maxsize;
spec.Source = query.source;
spec.Host = query.host;
@ -218,6 +222,34 @@ namespace NzbDrone.Core.IndexerSearch
}
}
if (criteriaBase.MinAge.HasValue && criteriaBase.MinAge.Value > 0)
{
var cutoffDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(criteriaBase.MinAge.Value));
releases = releases.Where(r => r.PublishDate <= cutoffDate).ToList();
}
if (criteriaBase.MaxAge.HasValue && criteriaBase.MaxAge.Value > 0)
{
var cutoffDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(criteriaBase.MaxAge.Value));
releases = releases.Where(r => r.PublishDate >= cutoffDate).ToList();
}
if (criteriaBase.MinSize.HasValue && criteriaBase.MinSize.Value > 0)
{
var minSize = criteriaBase.MinSize.Value;
releases = releases.Where(r => r.Size >= minSize).ToList();
}
if (criteriaBase.MaxSize.HasValue && criteriaBase.MaxSize.Value > 0)
{
var maxSize = criteriaBase.MaxSize.Value;
releases = releases.Where(r => r.Size <= maxSize).ToList();
}
foreach (var query in indexerReports.Queries)
{
_eventAggregator.PublishEvent(new IndexerQueryEvent(indexer.Definition.Id, criteriaBase, query));

@ -272,6 +272,26 @@ namespace NzbDrone.Core.Indexers.Newznab
parameters.Set("offset", searchCriteria.Offset.ToString());
}
if (searchCriteria.MinAge.HasValue)
{
parameters.Set("minage", searchCriteria.MaxAge.ToString());
}
if (searchCriteria.MaxAge.HasValue)
{
parameters.Set("maxage", searchCriteria.MaxAge.ToString());
}
if (searchCriteria.MinSize.HasValue)
{
parameters.Set("minsize", searchCriteria.MaxAge.ToString());
}
if (searchCriteria.MaxSize.HasValue)
{
parameters.Set("maxsize", searchCriteria.MaxAge.ToString());
}
if (parameters.Count > 0)
{
searchUrl += $"&{parameters.GetQueryString()}";

Loading…
Cancel
Save