Throw exception when unable to get size from newznab feed

This commit is contained in:
Mark McDowall
2013-08-12 19:14:03 -07:00
parent 44772c7391
commit 881686e994
2 changed files with 22 additions and 1 deletions
@@ -2,6 +2,7 @@
using System.Drawing;
using System.Linq;
using System.Xml.Linq;
using NLog;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers.Newznab
@@ -20,7 +21,13 @@ namespace NzbDrone.Core.Indexers.Newznab
if (currentResult != null)
{
var attributes = item.Elements(NewznabNamespace + "attr");
var sizeElement = attributes.Single(e => e.Attribute("name").Value == "size");
var sizeElement = attributes.SingleOrDefault(e => e.Attribute("name").Value == "size");
if (sizeElement == null)
{
var message = String.Format("Unable to parse size from: {0} [{1}]", currentResult.Title, currentResult.Indexer);
throw new SizeParsingException(message);
}
currentResult.Size = Convert.ToInt64(sizeElement.Attribute("value").Value);
}