From c72ad70b663705e7fa7d0993617807e037ade35c Mon Sep 17 00:00:00 2001 From: Christian Franchin Date: Sun, 3 May 2020 19:21:54 -0300 Subject: [PATCH] bjshare: Fix web format and series naming on 24h search (#8502) --- src/Jackett.Common/Indexers/BJShare.cs | 56 +++++++++++++++++++++----- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/src/Jackett.Common/Indexers/BJShare.cs b/src/Jackett.Common/Indexers/BJShare.cs index 0231551b3..49c546f65 100644 --- a/src/Jackett.Common/Indexers/BJShare.cs +++ b/src/Jackett.Common/Indexers/BJShare.cs @@ -164,6 +164,36 @@ namespace Jackett.Common.Indexers return false; } + private string FixYearPosition(string title, string year) + { + int index = title.LastIndexOf('-'); + // If its a series + if (index != -1) + { + title = title.Substring(0, index) + year + " " + title.Substring(index + 1); + } + else + { + title += " " + year; + } + + return title; + } + + private string FixNovelNumber(string title) + { + + if (title.Contains("[Novela]")) + { + title = Regex.Replace(title, @"(Cap[\.]?[ ]?)", "S01E"); + title = Regex.Replace(title, @"(\[Novela\]\ )", ""); + title = Regex.Replace(title, @"(\ \-\s*Completo)", " - S01"); + return title; + } + + return title; + } + private string FixAbsoluteNumbering(string title) { // if result is absolute numbered, convert title from SXXEXX to EXX @@ -183,14 +213,6 @@ namespace Jackett.Common.Indexers return title; } - if (title.Contains("[Novela]")) - { - title = Regex.Replace(title, @"(Cap[\.]?[ ]?)", "S01E"); - title = Regex.Replace(title, @"(\[Novela\]\ )", ""); - title = Regex.Replace(title, @"(\ \-\s*Completo)", " - S01"); - return title; - } - return title; } @@ -296,6 +318,7 @@ namespace Jackett.Common.Indexers } release.Description = release.Description.Replace(" / Free", ""); // Remove Free Tag + release.Description = release.Description.Replace("/ WEB ", "/ WEB-DL "); // Fix web/web-dl release.Description = release.Description.Replace("Full HD", "1080p"); // Handles HDR conflict release.Description = release.Description.Replace("/ HD /", "/ 720p /"); @@ -398,6 +421,7 @@ namespace Jackett.Common.Indexers var year = ""; release.Description = ""; var extraInfo = ""; + var releaseQuality = ""; foreach (var child in qBJinfoBox.ChildNodes) { var type = child.NodeType; @@ -419,7 +443,16 @@ namespace Jackett.Common.Indexers release.PublishDate = publishDate.ToLocalTime(); } else if (line.StartsWith("Ano:")) + { year = line.Substring("Ano: ".Length); + } + else if (line.StartsWith("Qualidade:")) + { + releaseQuality = line.Substring("Qualidade: ".Length); + if (releaseQuality == "WEB") + releaseQuality = "WEB-DL"; + extraInfo += releaseQuality + " "; + } else { release.Description += line + "\n"; @@ -436,9 +469,12 @@ namespace Jackett.Common.Indexers } var catStr = qCatLink.GetAttribute("href").Split('=')[1].Split('&')[0]; - release.Title = FixAbsoluteNumbering(release.Title); if (!string.IsNullOrEmpty(year)) - release.Title += " " + year; + release.Title = FixYearPosition(release.Title, year); + + release.Title = FixAbsoluteNumbering(release.Title); + release.Title = FixNovelNumber(release.Title); + if (qQuality != null) { var quality = qQuality.TextContent;