mirror of
https://github.com/Jackett/Jackett.git
synced 2025-10-03 08:57:46 +02:00
core: nullable query.season
nebulance-api: skip invalid requests
This commit is contained in:
@@ -168,7 +168,7 @@ namespace Jackett.Common.Indexers.Definitions
|
|||||||
else if (DateTime.TryParseExact($"{query.Season} {query.Episode}", "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var showDate))
|
else if (DateTime.TryParseExact($"{query.Season} {query.Episode}", "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var showDate))
|
||||||
{
|
{
|
||||||
// Daily Episode
|
// Daily Episode
|
||||||
parameters.Name = showDate.ToString("yyyy.MM.dd");
|
parameters.Name = showDate.ToString("yyyy.MM.dd", CultureInfo.InvariantCulture);
|
||||||
parameters.Category = "Episode";
|
parameters.Category = "Episode";
|
||||||
pageableRequests.Add(GetPagedRequests(parameters, btnResults, btnOffset));
|
pageableRequests.Add(GetPagedRequests(parameters, btnResults, btnOffset));
|
||||||
}
|
}
|
||||||
|
@@ -95,7 +95,7 @@ namespace Jackett.Common.Indexers.Definitions
|
|||||||
|
|
||||||
public override IIndexerRequestGenerator GetRequestGenerator()
|
public override IIndexerRequestGenerator GetRequestGenerator()
|
||||||
{
|
{
|
||||||
return new NebulanceAPIRequestGenerator(TorznabCaps, configData, SiteLink);
|
return new NebulanceAPIRequestGenerator(TorznabCaps, configData, SiteLink, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IParseIndexerResponse GetParser()
|
public override IParseIndexerResponse GetParser()
|
||||||
@@ -140,12 +140,14 @@ namespace Jackett.Common.Indexers.Definitions
|
|||||||
private readonly TorznabCapabilities _torznabCaps;
|
private readonly TorznabCapabilities _torznabCaps;
|
||||||
private readonly ConfigurationDataAPIKey _configData;
|
private readonly ConfigurationDataAPIKey _configData;
|
||||||
private readonly string _siteLink;
|
private readonly string _siteLink;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public NebulanceAPIRequestGenerator(TorznabCapabilities torznabCaps, ConfigurationDataAPIKey configData, string siteLink)
|
public NebulanceAPIRequestGenerator(TorznabCapabilities torznabCaps, ConfigurationDataAPIKey configData, string siteLink, Logger logger)
|
||||||
{
|
{
|
||||||
_torznabCaps = torznabCaps;
|
_torznabCaps = torznabCaps;
|
||||||
_configData = configData;
|
_configData = configData;
|
||||||
_siteLink = siteLink;
|
_siteLink = siteLink;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexerPageableRequestChain GetSearchRequests(TorznabQuery query)
|
public IndexerPageableRequestChain GetSearchRequests(TorznabQuery query)
|
||||||
@@ -183,9 +185,9 @@ namespace Jackett.Common.Indexers.Definitions
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (query.Season > 0)
|
if (query.Season.HasValue)
|
||||||
{
|
{
|
||||||
queryParams.Season = query.Season;
|
queryParams.Season = query.Season.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.Episode.IsNotNullOrWhiteSpace() && int.TryParse(query.Episode, out var episodeNumber))
|
if (query.Episode.IsNotNullOrWhiteSpace() && int.TryParse(query.Episode, out var episodeNumber))
|
||||||
@@ -194,6 +196,16 @@ namespace Jackett.Common.Indexers.Definitions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((queryParams.Season.HasValue || queryParams.Episode.HasValue) &&
|
||||||
|
queryParams.Name.IsNullOrWhiteSpace() &&
|
||||||
|
queryParams.Release.IsNullOrWhiteSpace() &&
|
||||||
|
!queryParams.TvMaze.HasValue)
|
||||||
|
{
|
||||||
|
_logger.Debug("NBL API does not support season calls without name, series, id, imdb, tvmaze, or time keys.");
|
||||||
|
|
||||||
|
return new IndexerPageableRequestChain();
|
||||||
|
}
|
||||||
|
|
||||||
pageableRequests.Add(GetPagedRequests(queryParams, limit, offset));
|
pageableRequests.Add(GetPagedRequests(queryParams, limit, offset));
|
||||||
|
|
||||||
return pageableRequests;
|
return pageableRequests;
|
||||||
|
@@ -288,7 +288,7 @@ namespace Jackett.Common.Indexers.Definitions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter by Season
|
// Filter by Season
|
||||||
if (query.Season != 0 && !releaseInfo.Title.Contains("S" + query.Season.ToString("D2")))
|
if (query.Season.HasValue && !releaseInfo.Title.Contains("S" + query.Season.Value.ToString("D2")))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ namespace Jackett.Common.Models
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public bool Cache { get; set; } = true;
|
public bool Cache { get; set; } = true;
|
||||||
|
|
||||||
public int Season { get; set; }
|
public int? Season { get; set; }
|
||||||
public string Episode { get; set; }
|
public string Episode { get; set; }
|
||||||
public string SearchTerm { get; set; }
|
public string SearchTerm { get; set; }
|
||||||
|
|
||||||
@@ -227,7 +227,9 @@ namespace Jackett.Common.Models
|
|||||||
if (limit != null && limit > 0)
|
if (limit != null && limit > 0)
|
||||||
{
|
{
|
||||||
if (limit > queryString.Length)
|
if (limit > queryString.Length)
|
||||||
|
{
|
||||||
limit = queryString.Length;
|
limit = queryString.Length;
|
||||||
|
}
|
||||||
|
|
||||||
queryString = queryString.Substring(0, (int)limit);
|
queryString = queryString.Substring(0, (int)limit);
|
||||||
}
|
}
|
||||||
@@ -243,14 +245,20 @@ namespace Jackett.Common.Models
|
|||||||
|
|
||||||
public string GetEpisodeSearchString()
|
public string GetEpisodeSearchString()
|
||||||
{
|
{
|
||||||
if (Season == 0)
|
if (Season == null || Season == 0)
|
||||||
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
string episodeString;
|
string episodeString;
|
||||||
if (DateTime.TryParseExact($"{Season} {Episode}", "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var showDate))
|
if (DateTime.TryParseExact($"{Season} {Episode}", "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var showDate))
|
||||||
episodeString = showDate.ToString("yyyy.MM.dd");
|
{
|
||||||
else if (string.IsNullOrEmpty(Episode))
|
episodeString = showDate.ToString("yyyy.MM.dd", CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
else if (Episode.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
episodeString = $"S{Season:00}";
|
episodeString = $"S{Season:00}";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -261,8 +269,8 @@ namespace Jackett.Common.Models
|
|||||||
{
|
{
|
||||||
episodeString = $"S{Season:00}E{Episode}";
|
episodeString = $"S{Season:00}E{Episode}";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return episodeString;
|
return episodeString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user