diff --git a/NzbDrone.Core/Indexers/Newznab/NewznabParser.cs b/NzbDrone.Core/Indexers/Newznab/NewznabParser.cs index e04fe077f..519953085 100644 --- a/NzbDrone.Core/Indexers/Newznab/NewznabParser.cs +++ b/NzbDrone.Core/Indexers/Newznab/NewznabParser.cs @@ -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 @@ protected override ReportInfo PostProcessor(XElement item, ReportInfo currentRes 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); } diff --git a/NzbDrone.Core/Indexers/Newznab/SizeParsingException.cs b/NzbDrone.Core/Indexers/Newznab/SizeParsingException.cs new file mode 100644 index 000000000..33735a7ba --- /dev/null +++ b/NzbDrone.Core/Indexers/Newznab/SizeParsingException.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.Indexers.Newznab +{ + public class SizeParsingException : Exception + { + public SizeParsingException(string message) : base(message) + { + } + } +}