Fixed: (AnimeTosho) Mapping of Subcat as Parent

pull/1260/head
Qstick 2 years ago
parent a5a4f62f25
commit 6636cbc4ae

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<caps>
<server version="1.0" title="Anime Tosho" strapline="Anime NZB/DDL mirror" url="https://animetosho.org/"/>
<limits max="200" default="75"/>
<retention days="9999"/>
<registration available="no" open="yes" />
<searching>
<search available="yes" supportedParams="q" />
<tv-search available="no" supportedParams="q" />
<movie-search available="no" supportedParams="q" />
</searching>
<categories>
<category id="5070" name="Anime" description="Anime"/>
</categories>
</caps>

@ -84,6 +84,19 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
bookCats.Should().Contain("8000");
}
[Test]
public void should_find_sub_categories_as_main_categories()
{
GivenCapsResponse(ReadAllText("Files/Indexers/Torznab/torznab_animetosho_caps.xml"));
var caps = Subject.GetCapabilities(_settings, _definition);
var bookCats = caps.Categories.MapTrackerCatToNewznab("5070");
bookCats.Count.Should().Be(2);
bookCats.First().Id.Should().Be(5070);
}
[Test]
public void should_map_by_name_when_available()
{

@ -223,9 +223,16 @@ namespace NzbDrone.Core.Indexers.Newznab
foreach (var xmlCategory in xmlCategories.Elements("category"))
{
var parentName = xmlCategory.Attribute("name").Value;
var parentNameLower = parentName?.ToLowerInvariant();
var parentId = int.Parse(xmlCategory.Attribute("id").Value);
var mappedCat = NewznabStandardCategory.ParentCats.FirstOrDefault(x => parentName.ToLower().Contains(x.Name.ToLower()));
var mappedCat = NewznabStandardCategory.ParentCats.FirstOrDefault(x => parentNameLower.Contains(x.Name.ToLower()));
if (mappedCat == null)
{
// 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));
}
if (mappedCat == null)
{

Loading…
Cancel
Save