Fixed: Category parsing for some not-so-great Torznab feeds

MoreThanTv
This commit is contained in:
Qstick
2022-12-20 20:50:30 -06:00
parent 30f53c20ed
commit ad95d73e9d
4 changed files with 105 additions and 2 deletions
@@ -127,6 +127,12 @@ namespace NzbDrone.Core.Indexers.Newznab
var cats = TryGetMultipleNewznabAttributes(item, "category");
var results = new List<IndexerCategory>();
// Try to find <category> elements for some indexers that suck at following the rules.
if (results.Count == 0)
{
cats = item.Elements("category").Select(e => e.Value).ToList();
}
foreach (var cat in cats)
{
var indexerCat = capabilities.Categories.MapTrackerCatToNewznab(cat);
@@ -165,9 +165,15 @@ namespace NzbDrone.Core.Indexers.Torznab
protected override ICollection<IndexerCategory> GetCategory(XElement item)
{
var capabilities = _capabilitiesProvider.GetCapabilities(_settings, _definition);
var cats = TryGetMultipleNewznabAttributes(item, "category");
var cats = TryGetMultipleTorznabAttributes(item, "category");
var results = new List<IndexerCategory>();
// Try to find <category> elements for some indexers that suck at following the rules.
if (results.Count == 0)
{
cats = item.Elements("category").Select(e => e.Value).ToList();
}
foreach (var cat in cats)
{
var indexerCat = capabilities.Categories.MapTrackerCatToNewznab(cat);
@@ -265,7 +271,7 @@ namespace NzbDrone.Core.Indexers.Torznab
return defaultValue;
}
protected List<string> TryGetMultipleNewznabAttributes(XElement item, string key)
protected List<string> TryGetMultipleTorznabAttributes(XElement item, string key)
{
var attrElements = item.Elements(ns + "attr").Where(e => e.Attribute("name").Value.Equals(key, StringComparison.OrdinalIgnoreCase));
var results = new List<string>();