mirror of
https://github.com/Prowlarr/Prowlarr
synced 2025-12-06 08:34:28 +01:00
Fixed: (AnimeTosho) Mapping of Subcategory as Parent
This commit is contained in:
parent
4924b45b56
commit
88502cd020
4 changed files with 33 additions and 27 deletions
|
|
@ -1,15 +1,16 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<caps>
|
<caps>
|
||||||
<server version="1.0" title="Anime Tosho" strapline="Anime NZB/DDL mirror" url="https://animetosho.org/"/>
|
<server version="1.0" title="Anime Tosho" strapline="Anime NZB/DDL mirror" url="https://animetosho.org/" />
|
||||||
<limits max="200" default="75"/>
|
<limits max="200" default="75" />
|
||||||
<retention days="9999"/>
|
<retention days="9999" />
|
||||||
<registration available="no" open="yes" />
|
<registration available="no" open="yes" />
|
||||||
<searching>
|
<searching>
|
||||||
<search available="yes" supportedParams="q" />
|
<search available="yes" supportedParams="q" />
|
||||||
<tv-search available="no" supportedParams="q" />
|
<tv-search available="no" supportedParams="q" />
|
||||||
<movie-search available="no" supportedParams="q" />
|
<movie-search available="no" supportedParams="q" />
|
||||||
</searching>
|
</searching>
|
||||||
<categories>
|
<categories>
|
||||||
<category id="5070" name="Anime" description="Anime"/>
|
<category id="5070" name="Anime" description="Anime" />
|
||||||
</categories>
|
<category id="2020" name="Movies/Other" description="Movies (Anime)" />
|
||||||
</caps>
|
</categories>
|
||||||
|
</caps>
|
||||||
|
|
|
||||||
|
|
@ -83,17 +83,18 @@ public void should_map_different_categories()
|
||||||
bookCats.Should().Contain("8000");
|
bookCats.Should().Contain("8000");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[TestCase(5070)]
|
||||||
public void should_find_sub_categories_as_main_categories()
|
[TestCase(2020)]
|
||||||
|
public void should_find_sub_categories_as_main_categories(int category)
|
||||||
{
|
{
|
||||||
GivenCapsResponse(ReadAllText("Files/Indexers/Torznab/torznab_animetosho_caps.xml"));
|
GivenCapsResponse(ReadAllText("Files/Indexers/Torznab/torznab_animetosho_caps.xml"));
|
||||||
|
|
||||||
var caps = Subject.GetCapabilities(_settings, _definition);
|
var caps = Subject.GetCapabilities(_settings, _definition);
|
||||||
|
|
||||||
var bookCats = caps.Categories.MapTrackerCatToNewznab("5070");
|
var indexerCategories = caps.Categories.MapTrackerCatToNewznab(category.ToString());
|
||||||
|
|
||||||
bookCats.Count.Should().Be(2);
|
indexerCategories.Count.Should().Be(2);
|
||||||
bookCats.First().Id.Should().Be(5070);
|
indexerCategories.First().Id.Should().Be(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
||||||
|
|
@ -224,24 +224,28 @@ private IndexerCapabilities ParseCapabilities(HttpResponse response)
|
||||||
foreach (var xmlCategory in xmlCategories.Elements("category"))
|
foreach (var xmlCategory in xmlCategories.Elements("category"))
|
||||||
{
|
{
|
||||||
var parentName = xmlCategory.Attribute("name").Value;
|
var parentName = xmlCategory.Attribute("name").Value;
|
||||||
var parentNameLower = parentName?.ToLowerInvariant();
|
|
||||||
var parentId = int.Parse(xmlCategory.Attribute("id").Value);
|
var parentId = int.Parse(xmlCategory.Attribute("id").Value);
|
||||||
|
|
||||||
var mappedCat = NewznabStandardCategory.ParentCats.FirstOrDefault(x => parentNameLower.Contains(x.Name.ToLower()));
|
var mappedCat = NewznabStandardCategory.ParentCats.FirstOrDefault(x => parentName.Equals(x.Name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
if (mappedCat == null)
|
if (mappedCat is null)
|
||||||
{
|
{
|
||||||
// Try to find name and Id in AllCats for sub cats that are mapped as parents
|
// Try to find name and ID in AllCats for sub cats that are mapped as parents
|
||||||
mappedCat = NewznabStandardCategory.AllCats.FirstOrDefault(x => x.Id == parentId && x.Name.ToLower().Contains(parentNameLower));
|
mappedCat = NewznabStandardCategory.AllCats.FirstOrDefault(x => x.Id == parentId && x.Name.Contains(parentName, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mappedCat == null)
|
if (mappedCat is null)
|
||||||
|
{
|
||||||
|
mappedCat = NewznabStandardCategory.ParentCats.FirstOrDefault(x => parentName.Contains(x.Name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mappedCat is null)
|
||||||
{
|
{
|
||||||
// Try by parent id if name fails
|
// Try by parent id if name fails
|
||||||
mappedCat = NewznabStandardCategory.ParentCats.FirstOrDefault(x => x.Id == parentId);
|
mappedCat = NewznabStandardCategory.ParentCats.FirstOrDefault(x => x.Id == parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mappedCat == null)
|
if (mappedCat is null)
|
||||||
{
|
{
|
||||||
// Fallback to Other
|
// Fallback to Other
|
||||||
mappedCat = NewznabStandardCategory.Other;
|
mappedCat = NewznabStandardCategory.Other;
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ public static class NewznabStandardCategory
|
||||||
|
|
||||||
public static readonly IndexerCategory[] ParentCats =
|
public static readonly IndexerCategory[] ParentCats =
|
||||||
{
|
{
|
||||||
ZedOther,
|
|
||||||
Console,
|
Console,
|
||||||
Movies,
|
Movies,
|
||||||
Audio,
|
Audio,
|
||||||
|
|
@ -100,7 +99,8 @@ public static class NewznabStandardCategory
|
||||||
TV,
|
TV,
|
||||||
XXX,
|
XXX,
|
||||||
Books,
|
Books,
|
||||||
Other
|
Other,
|
||||||
|
ZedOther
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly IndexerCategory[] AllCats =
|
public static readonly IndexerCategory[] AllCats =
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue