awesomehd: remove the year from the search (#8342)

Part of #7829
This commit is contained in:
Diego Heras 2020-04-24 19:44:24 +02:00 committed by GitHub
parent 9e3ecaee1f
commit 9b130c3e5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
using Jackett.Common.Models; using Jackett.Common.Models;
@ -18,6 +19,7 @@ namespace Jackett.Common.Indexers
{ {
private string SearchUrl => SiteLink + "searchapi.php"; private string SearchUrl => SiteLink + "searchapi.php";
private string TorrentUrl => SiteLink + "torrents.php"; private string TorrentUrl => SiteLink + "torrents.php";
private readonly Regex _removeYearRegex = new Regex(@" [\(\[]?(19|20)\d{2}[\)\]]?$", RegexOptions.Compiled);
private new ConfigurationDataPasskey configData => (ConfigurationDataPasskey)base.configData; private new ConfigurationDataPasskey configData => (ConfigurationDataPasskey)base.configData;
public AwesomeHD(IIndexerConfigurationService configService, Utils.Clients.WebClient c, Logger l, IProtectionService ps) public AwesomeHD(IIndexerConfigurationService configService, Utils.Clients.WebClient c, Logger l, IProtectionService ps)
@ -75,10 +77,13 @@ namespace Jackett.Common.Indexers
} }
else if (!string.IsNullOrWhiteSpace(query.GetQueryString())) else if (!string.IsNullOrWhiteSpace(query.GetQueryString()))
{ {
var searchTerm = query.SearchTerm; // not use query.GetQueryString(), because it includes the season // not use query.GetQueryString(), because it includes the season
if (query.Season > 0) // search for tv series var searchTerm = query.SearchTerm;
// search for tv series
if (query.Season > 0)
searchTerm += $": Season {query.Season:D2}"; searchTerm += $": Season {query.Season:D2}";
// remove the year, it's not supported in the api
searchTerm = _removeYearRegex.Replace(searchTerm, "");
qc.Add("action", "titlesearch"); qc.Add("action", "titlesearch");
qc.Add("title", searchTerm); qc.Add("title", searchTerm);
} }