bjshare: Fixed search to match with Sonarr and Radarr standards. resolves #4365 (#6174)

This commit is contained in:
Artur Ligieri Nunes
2019-10-15 16:35:07 -03:00
committed by garfield69
parent 9e5dbf9a8f
commit e6929c0bab

View File

@@ -123,7 +123,26 @@ namespace Jackett.Common.Indexers
// In this indexer, it looks that it is added "automatically", so all current and new releases will be broken
// until they or the source from where they get that info fix it...
return title.Contains("One Piece") ? Regex.Replace(title, @"(Ep[\.]?[ ]?)|([S]\d\d[Ee])", "E") : title;
if (title.Contains("One Piece"))
{
title = Regex.Replace(title, @"(Ep[\.]?[ ]?)|([S]\d\d[Ee])", "E");
return title;
}
else if (title.Contains("[Novela]"))
{
title = Regex.Replace(title, @"(Cap[\.]?[ ]?)", "S01E");
title = Regex.Replace(title, @"(\[Novela\]\ )", "");
title = Regex.Replace(title, @"(\ \-\s*Completo)", " - S01");
return title;
}
else
{
return title;
}
// return title.Contains("One Piece") ? Regex.Replace(title, @"(Ep[\.]?[ ]?)|([S]\d\d[Ee])", "E") : title;
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
@@ -320,6 +339,7 @@ namespace Jackett.Common.Indexers
string yearStr = null;
if (row.ClassList.Contains("group") || row.ClassList.Contains("torrent")) // group/ungrouped headers
{
var qCatLink = row.QuerySelector("a[href^=\"/torrents.php?filter_cat\"]");
@@ -377,6 +397,7 @@ namespace Jackett.Common.Indexers
{
var qDescription = row.QuerySelector("div.torrent_info");
release.Description = qDescription.TextContent;
title = FixAbsoluteNumbering(title);
var cleanTitle = Regex.Replace(title, @" - ((S\d{2})?(E\d{2,4})?)", "");
var seasonEp = Regex.Replace(title, @"^(.*?) - ((S\d{2})?(E\d{2,4})?)", "$2");
@@ -386,10 +407,16 @@ namespace Jackett.Common.Indexers
{
release.Title = cleanTitle + " " + seasonEp;
}
else
// the seasonEp RegEx is getting all when done with movies, and then cleaning again when getting international name,
// so it was cutting of the year of movies and getting clonflict in Radarr
else if (categoryStr == "2" || categoryStr == "6")
{
release.Title = cleanTitle + " " + yearStr + " " + seasonEp;
}
else
{
release.Title = cleanTitle + " " + yearStr;
}
release.Category = category;
}
@@ -399,10 +426,28 @@ namespace Jackett.Common.Indexers
release.Description = release.Description.Replace("/ HD / ", "/ 720p /");
release.Description = release.Description.Replace(" / HD]", " / 720p]");
release.Description = release.Description.Replace("4K", "2160p");
release.Description = release.Description.Replace("SD", "480p");
// Adjust the description in order to can be read by Radarr and Sonarr
var cleanDescription = release.Description.Trim().TrimStart('[').TrimEnd(']');
String[] titleElements;
string[] stringSeparators = new string[] {" / "};
titleElements = cleanDescription.Split(stringSeparators,StringSplitOptions.None);
if (titleElements[titleElements.Length - 1] == "3D")
{
release.Title += " " + titleElements[titleElements.Length - 2] + " " + titleElements[titleElements.Length - 1] + " " + titleElements[3] + " " + titleElements[2] + " " + titleElements[1] + " " + titleElements[4];
}
else
{
release.Title += " " + titleElements[titleElements.Length - 1] + " " + titleElements[3] + " " + titleElements[2] + " " + titleElements[1] + " " + titleElements[4];
}
// Get international title if available, or use the full title if not
release.Title = Regex.Replace(release.Title, @".* \[(.*?)\](.*)", "$1$2");
release.Title += " " + release.Description; // add year and Description to the release Title to add some meaning to it
// This tracker does not provide an publish date to search terms (only on last 24h page)
release.PublishDate = DateTime.Today;