mirror of
https://github.com/Jackett/Jackett
synced 2025-03-10 14:14:25 +00:00
anilibria: fix sonarr search (#10979)
This commit is contained in:
parent
cc446cec67
commit
92dbe492e8
1 changed files with 8 additions and 4 deletions
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using Jackett.Common.Models;
|
using Jackett.Common.Models;
|
||||||
using Jackett.Common.Models.IndexerConfig.Bespoke;
|
using Jackett.Common.Models.IndexerConfig.Bespoke;
|
||||||
using Jackett.Common.Services.Interfaces;
|
using Jackett.Common.Services.Interfaces;
|
||||||
|
@ -18,6 +19,8 @@ namespace Jackett.Common.Indexers
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public class AniLibria : BaseWebIndexer
|
public class AniLibria : BaseWebIndexer
|
||||||
{
|
{
|
||||||
|
private static readonly Regex _EpisodeRegex = new Regex(@"(?:[SsEe]?\d{1,4}){1,2}$");
|
||||||
|
|
||||||
public AniLibria(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps, ICacheService cs)
|
public AniLibria(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps, ICacheService cs)
|
||||||
: base(id: "AniLibria",
|
: base(id: "AniLibria",
|
||||||
name: "AniLibria",
|
name: "AniLibria",
|
||||||
|
@ -66,17 +69,18 @@ namespace Jackett.Common.Indexers
|
||||||
|
|
||||||
private async Task<IEnumerable<ReleaseInfo>> PerformSearch(TorznabQuery query)
|
private async Task<IEnumerable<ReleaseInfo>> PerformSearch(TorznabQuery query)
|
||||||
{
|
{
|
||||||
|
var title = _EpisodeRegex.Replace(query.SearchTerm, string.Empty).TrimEnd();
|
||||||
var queryParameters = new NameValueCollection
|
var queryParameters = new NameValueCollection
|
||||||
{
|
{
|
||||||
{ "search", query.SearchTerm },
|
{ "filter", "names,poster.url,code,torrents.list,season.year" },
|
||||||
{ "filter", "names,poster.url,code,torrents.list,season.year" }
|
{ "limit", "100" }
|
||||||
};
|
};
|
||||||
var response = await RequestWithCookiesAndRetryAsync(Configuration.ApiLink.Value + "/searchTitles?" + queryParameters.GetQueryString());
|
var response = await RequestWithCookiesAndRetryAsync(Configuration.ApiLink.Value + "/searchTitles?" + queryParameters.GetQueryString() + "&search=" + Uri.EscapeDataString(title));
|
||||||
if (response.Status != HttpStatusCode.OK)
|
if (response.Status != HttpStatusCode.OK)
|
||||||
throw new WebException($"AniLibria search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);
|
throw new WebException($"AniLibria search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);
|
||||||
|
|
||||||
var results = ParseApiResults(response.ContentString);
|
var results = ParseApiResults(response.ContentString);
|
||||||
return results.Where(release => query.MatchQueryStringAND(release.Title));
|
return results.Where(release => query.MatchQueryStringAND(release.Title, null, title));;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IEnumerable<ReleaseInfo>> FetchNewReleases()
|
private async Task<IEnumerable<ReleaseInfo>> FetchNewReleases()
|
||||||
|
|
Loading…
Add table
Reference in a new issue