Fixed: (AvistaZ) Allow search by episode

async-translations
Bogdan 1 year ago
parent 3ce3f8acdd
commit ef9a3a4f2a

@ -1,7 +1,9 @@
using System.Collections.Generic;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers.Definitions.Avistaz;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Indexers.Definitions
@ -23,6 +25,18 @@ namespace NzbDrone.Core.Indexers.Definitions
{
}
public override IIndexerRequestGenerator GetRequestGenerator()
{
return new AvistaZRequestGenerator
{
Settings = Settings,
Capabilities = Capabilities,
PageSize = PageSize,
HttpClient = _httpClient,
Logger = _logger
};
}
public override IParseIndexerResponse GetParser()
{
return new AvistaZParser();
@ -57,6 +71,17 @@ namespace NzbDrone.Core.Indexers.Definitions
}
}
public class AvistaZRequestGenerator : AvistazRequestGenerator
{
// AvistaZ has episodes without season. eg Running Man E323
protected override string GetEpisodeSearchTerm(TvSearchCriteria searchCriteria)
{
return searchCriteria.Season is null or 0 && searchCriteria.Episode.IsNotNullOrWhiteSpace()
? $"E{searchCriteria.Episode}"
: $"{searchCriteria.EpisodeSearchString}";
}
}
public class AvistaZParser : AvistazParserBase
{
protected override string TimezoneOffset => "+02:00";

@ -105,7 +105,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
}
else
{
parameters.Add("search", GetSearchTerm(searchCriteria.SanitizedSearchTerm).Trim());
parameters.Add("search", searchCriteria.SanitizedSearchTerm.Trim());
}
var pageableRequests = new IndexerPageableRequestChain();
@ -117,7 +117,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
{
var parameters = GetBasicSearchParameters(searchCriteria);
parameters.Add("search", GetSearchTerm(searchCriteria.SanitizedSearchTerm).Trim());
parameters.Add("search", searchCriteria.SanitizedSearchTerm.Trim());
var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetRequest(parameters));
@ -131,16 +131,16 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
if (searchCriteria.ImdbId.IsNotNullOrWhiteSpace())
{
parameters.Add("imdb", searchCriteria.FullImdbId);
parameters.Add("search", GetSearchTerm(searchCriteria.EpisodeSearchString).Trim());
parameters.Add("search", GetEpisodeSearchTerm(searchCriteria).Trim());
}
else if (searchCriteria.TvdbId.HasValue)
{
parameters.Add("tvdb", searchCriteria.TvdbId.Value.ToString());
parameters.Add("search", GetSearchTerm(searchCriteria.EpisodeSearchString).Trim());
parameters.Add("search", GetEpisodeSearchTerm(searchCriteria).Trim());
}
else
{
parameters.Add("search", GetSearchTerm(searchCriteria.SanitizedTvSearchString).Trim());
parameters.Add("search", $"{searchCriteria.SanitizedSearchTerm} {GetEpisodeSearchTerm(searchCriteria)}".Trim());
}
var pageableRequests = new IndexerPageableRequestChain();
@ -153,18 +153,17 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
return new IndexerPageableRequestChain();
}
// hook to adjust the search term
protected virtual string GetSearchTerm(string term) => term;
public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
{
var parameters = GetBasicSearchParameters(searchCriteria);
parameters.Add("search", GetSearchTerm(searchCriteria.SanitizedSearchTerm).Trim());
parameters.Add("search", searchCriteria.SanitizedSearchTerm.Trim());
var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetRequest(parameters));
return pageableRequests;
}
protected virtual string GetEpisodeSearchTerm(TvSearchCriteria searchCriteria) => searchCriteria.EpisodeSearchString;
}
}

Loading…
Cancel
Save