mirror of
https://github.com/Jackett/Jackett
synced 2025-02-22 22:31:09 +00:00
feat(mejortorrent): improve movie search (#3352)
* feat(newpct): rename title to make them more standarized * fix: add site link configurable * feat: add tests if news are not available Sometimes the web has no news, and even if the tv show searcher is working it throws an error. This way it will check news, and, if not available, will check some series to check aliveness. * fix: remove apostrophes from search closes #3315 * fix: initialize search term if it's null * fix: add multiepisode parsing and minor improvements Now a quality it's ensured Now quality it's cleaned from brackets Add dash as multiepisode separator * refactor: move tv search to function and change site link Sitelink is now a property class * refactor: extract function to get series uris * refactor: extract function to get releases from one uri * feat: add fallback to shows starting with "the" Whenever a shows doesn't return results and doesn't start with "the" search one more time prepending "the". The motivation of this is because of Sonarr sanitizes queries before sending them to Jackett. This indexer needs the article but Sonarr removes it before. * fix(newpct): add missing guid based on link That was causing missing files on applications consuming the newpct indexer. * feat(mejortorrent): add movie search closes: #3310 * feat(mejortorrent): add parse and filter by year * feat(mejortorrent): change movie search algorithm Now movie search is based on longest word, then results are filtered ignoring special characters. * fix(mejortorrent): restore query so jackett log it correctly * fix: add small year correction Some movies are tagged with the year before or after, I think it's safe to fix years with exactly the same name and only a year of difference.
This commit is contained in:
parent
424e7b773d
commit
2fac90df9f
1 changed files with 43 additions and 1 deletions
|
@ -69,6 +69,7 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query, int attempts)
|
||||
{
|
||||
var originalSearchTerm = query.SearchTerm;
|
||||
if (query.SearchTerm == null)
|
||||
{
|
||||
query.SearchTerm = "";
|
||||
|
@ -115,6 +116,7 @@ namespace Jackett.Common.Indexers
|
|||
releases.AddRange(await tvShowPerformer.PerformQuery(query));
|
||||
}
|
||||
|
||||
query.SearchTerm = originalSearchTerm;
|
||||
return releases;
|
||||
}
|
||||
|
||||
|
@ -548,6 +550,22 @@ namespace Jackett.Common.Indexers
|
|||
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
query = SanitizeQuery(query);
|
||||
var movies = await FetchMoviesBasedOnLongestWord(query);
|
||||
return movies;
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<MTReleaseInfo>> FetchMoviesBasedOnLongestWord(TorznabQuery query)
|
||||
{
|
||||
var originalSearch = query.SearchTerm;
|
||||
var regexStr = ".*" + originalSearch.Replace(" ", ".*") + ".*";
|
||||
var regex = new Regex(regexStr, RegexOptions.IgnoreCase);
|
||||
query.SearchTerm = LongestWord(query);
|
||||
var movies = await FetchMovies(query);
|
||||
return movies.Where(m => regex.Match(m.Title).Success);
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<MTReleaseInfo>> FetchMovies(TorznabQuery query)
|
||||
{
|
||||
var uriSearch = CreateSearchUri(query.SearchTerm);
|
||||
var htmlSearch = await requester.MakeRequest(uriSearch);
|
||||
var moviesInfoUris = movieSearchScraper.Extract(htmlSearch);
|
||||
|
@ -572,12 +590,36 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
if (query.Year != null)
|
||||
{
|
||||
movies = movies.Where(m => m.Year == query.Year);
|
||||
movies = movies
|
||||
.Where(m =>
|
||||
m.Year == query.Year ||
|
||||
m.Year == query.Year + 1 ||
|
||||
m.Year == query.Year - 1)
|
||||
.Select(m =>
|
||||
{
|
||||
m.TitleOriginal = m.TitleOriginal.Replace("(" + m.Year + ")", "(" + query.Year + ")");
|
||||
return m;
|
||||
});
|
||||
}
|
||||
|
||||
return movies;
|
||||
}
|
||||
|
||||
private string LongestWord(TorznabQuery query)
|
||||
{
|
||||
var words = query.SearchTerm.Split(' ');
|
||||
if (words.Count() == 0) return null;
|
||||
var longestWord = words.First();
|
||||
foreach(var word in words)
|
||||
{
|
||||
if (word.Length >= longestWord.Length)
|
||||
{
|
||||
longestWord = word;
|
||||
}
|
||||
}
|
||||
return longestWord;
|
||||
}
|
||||
|
||||
private TorznabQuery SanitizeQuery(TorznabQuery query)
|
||||
{
|
||||
var regex = new Regex(@"\d{4}$");
|
||||
|
|
Loading…
Reference in a new issue