mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
[BakaBT] Added categories for tracker (#9227)
This commit is contained in:
@@ -24,6 +24,8 @@ namespace Jackett.Common.Indexers
|
|||||||
private string LoginUrl => SiteLink + "login.php";
|
private string LoginUrl => SiteLink + "login.php";
|
||||||
private readonly string LogoutStr = "<a href=\"logout.php\">Logout</a>";
|
private readonly string LogoutStr = "<a href=\"logout.php\">Logout</a>";
|
||||||
|
|
||||||
|
private readonly List<int> defaultCategories = new List<int> {TorznabCatType.TVAnime.ID};
|
||||||
|
|
||||||
private new ConfigurationDataBasicLogin configData
|
private new ConfigurationDataBasicLogin configData
|
||||||
{
|
{
|
||||||
get => (ConfigurationDataBasicLogin)base.configData;
|
get => (ConfigurationDataBasicLogin)base.configData;
|
||||||
@@ -46,6 +48,15 @@ namespace Jackett.Common.Indexers
|
|||||||
Encoding = Encoding.UTF8;
|
Encoding = Encoding.UTF8;
|
||||||
Language = "en-us";
|
Language = "en-us";
|
||||||
Type = "private";
|
Type = "private";
|
||||||
|
AddCategoryMapping(1, TorznabCatType.TVAnime, "Anime Series");
|
||||||
|
AddCategoryMapping(2, TorznabCatType.TVAnime, "OVA");
|
||||||
|
AddCategoryMapping(3, TorznabCatType.AudioOther, "Soundtrack");
|
||||||
|
AddCategoryMapping(4, TorznabCatType.BooksComics, "Manga");
|
||||||
|
AddCategoryMapping(5, TorznabCatType.TVAnime, "Anime Movie");
|
||||||
|
AddCategoryMapping(6, TorznabCatType.TVOTHER, "Live Action");
|
||||||
|
AddCategoryMapping(7, TorznabCatType.BooksOther, "Artbook");
|
||||||
|
AddCategoryMapping(8, TorznabCatType.AudioVideo, "Music Video");
|
||||||
|
AddCategoryMapping(9, TorznabCatType.BooksEbook, "Light Novel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||||
@@ -108,6 +119,7 @@ namespace Jackett.Common.Indexers
|
|||||||
var parser = new HtmlParser();
|
var parser = new HtmlParser();
|
||||||
var dom = parser.ParseDocument(response.Content);
|
var dom = parser.ParseDocument(response.Content);
|
||||||
var rows = dom.QuerySelectorAll(".torrents tr.torrent, .torrents tr.torrent_alt");
|
var rows = dom.QuerySelectorAll(".torrents tr.torrent, .torrents tr.torrent_alt");
|
||||||
|
ICollection<int> currentCategories = new List<int> {TorznabCatType.TVAnime.ID};
|
||||||
|
|
||||||
foreach (var row in rows)
|
foreach (var row in rows)
|
||||||
{
|
{
|
||||||
@@ -130,6 +142,8 @@ namespace Jackett.Common.Indexers
|
|||||||
var titleSeries = title.Substring(0, titleSplit);
|
var titleSeries = title.Substring(0, titleSplit);
|
||||||
var releaseInfo = title.Substring(titleSplit);
|
var releaseInfo = title.Substring(titleSplit);
|
||||||
|
|
||||||
|
currentCategories = GetNextCategory(row, currentCategories);
|
||||||
|
|
||||||
// For each over each pipe deliminated name
|
// For each over each pipe deliminated name
|
||||||
foreach (var name in titleSeries.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
|
foreach (var name in titleSeries.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
@@ -153,7 +167,7 @@ namespace Jackett.Common.Indexers
|
|||||||
release.Title = release.Title.Substring(0, insertPoint) + "Season 1 " + release.Title.Substring(insertPoint);
|
release.Title = release.Title.Substring(0, insertPoint) + "Season 1 " + release.Title.Substring(insertPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
release.Category = new List<int> { TorznabCatType.TVAnime.ID };
|
release.Category = currentCategories;
|
||||||
release.Description = row.QuerySelector("span.tags")?.TextContent;
|
release.Description = row.QuerySelector("span.tags")?.TextContent;
|
||||||
release.Guid = new Uri(SiteLink + qTitleLink.GetAttribute("href"));
|
release.Guid = new Uri(SiteLink + qTitleLink.GetAttribute("href"));
|
||||||
release.Comments = release.Guid;
|
release.Comments = release.Guid;
|
||||||
@@ -199,6 +213,37 @@ namespace Jackett.Common.Indexers
|
|||||||
return releases;
|
return releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ICollection<int> GetNextCategory(IElement row, ICollection<int> currentCategories)
|
||||||
|
{
|
||||||
|
string nextCategoryName = GetCategoryName(row);
|
||||||
|
if (nextCategoryName != null)
|
||||||
|
{
|
||||||
|
currentCategories = MapTrackerCatDescToNewznab(nextCategoryName);
|
||||||
|
if (currentCategories.Count == 0)
|
||||||
|
return defaultCategories;
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentCategories;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetCategoryName(IElement row)
|
||||||
|
{
|
||||||
|
var categoryElement = row.QuerySelector("td.category span");
|
||||||
|
if (categoryElement == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var categoryName = categoryElement.GetAttribute("title");
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(categoryName))
|
||||||
|
{
|
||||||
|
return categoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task<byte[]> Download(Uri link)
|
public override async Task<byte[]> Download(Uri link)
|
||||||
{
|
{
|
||||||
var downloadPage = await RequestStringWithCookies(link.ToString());
|
var downloadPage = await RequestStringWithCookies(link.ToString());
|
||||||
|
Reference in New Issue
Block a user