1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

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

View File

@ -2,6 +2,7 @@
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using NLog;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers.Newznab namespace NzbDrone.Core.Indexers.Newznab
@ -20,7 +21,13 @@ protected override ReportInfo PostProcessor(XElement item, ReportInfo currentRes
if (currentResult != null) if (currentResult != null)
{ {
var attributes = item.Elements(NewznabNamespace + "attr"); 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); currentResult.Size = Convert.ToInt64(sizeElement.Attribute("value").Value);
} }

View File

@ -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)
{
}
}
}