Tweaked Newznab/Torznab handling of attr without value.

This commit is contained in:
Taloth Saldono 2017-06-19 23:21:28 +02:00
parent 23552c3267
commit 475c99d492
2 changed files with 14 additions and 8 deletions

View File

@ -139,11 +139,14 @@ namespace NzbDrone.Core.Indexers.Newznab
protected string TryGetNewznabAttribute(XElement item, string key, string defaultValue = "")
{
var attr = item.Elements(ns + "attr").FirstOrDefault(e => e.Attribute("name").Value.Equals(key, StringComparison.CurrentCultureIgnoreCase));
if (attr != null)
var attrElement = item.Elements(ns + "attr").FirstOrDefault(e => e.Attribute("name").Value.Equals(key, StringComparison.OrdinalIgnoreCase));
if (attrElement != null)
{
return attr.Attribute("value").Value;
var attrValue = attrElement.Attribute("value");
if (attrValue != null)
{
return attrValue.Value;
}
}
return defaultValue;

View File

@ -181,11 +181,14 @@ namespace NzbDrone.Core.Indexers.Torznab
protected string TryGetTorznabAttribute(XElement item, string key, string defaultValue = "")
{
var attr = item.Elements(ns + "attr").FirstOrDefault(e => e.Attribute("name").Value.Equals(key, StringComparison.CurrentCultureIgnoreCase));
if (attr != null)
var attrElement = item.Elements(ns + "attr").FirstOrDefault(e => e.Attribute("name").Value.Equals(key, StringComparison.OrdinalIgnoreCase));
if (attrElement != null)
{
return attr.Attribute("value").Value;
var attrValue = attrElement.Attribute("value");
if (attrValue != null)
{
return attrValue.Value;
}
}
return defaultValue;