mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-24 16:53:54 +00:00
Throw exception when unable to get size from newznab feed
This commit is contained in:
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);
|
||||
}
|
||||
|
|
14
NzbDrone.Core/Indexers/Newznab/SizeParsingException.cs
Normal file
14
NzbDrone.Core/Indexers/Newznab/SizeParsingException.cs
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue