minor feed fetch cleanup.

pull/4/head
kay.one 11 years ago
parent 8f1127b57e
commit bac51706ae

@ -94,14 +94,11 @@ namespace NzbDrone.Core.Indexers
{
var result = new List<ReportInfo>();
var body = "......";
foreach (var url in urls)
{
try
{
_logger.Trace("Downloading Feed " + url);
body = _httpProvider.DownloadString(url);
var stream = _httpProvider.DownloadStream(url);
result.AddRange(indexer.Parser.Process(stream));
}
@ -114,13 +111,13 @@ namespace NzbDrone.Core.Indexers
else
{
webException.Data.Add("FeedUrl", url);
_logger.WarnException("An error occurred while processing feed. " + url + " " + body, webException);
_logger.WarnException("An error occurred while processing feed. " + url, webException);
}
}
catch (Exception feedEx)
{
feedEx.Data.Add("FeedUrl", url);
_logger.ErrorException("An error occurred while processing feed. " + url + " " + body, feedEx);
_logger.ErrorException("An error occurred while processing feed. " + url, feedEx);
}
}

@ -11,7 +11,7 @@ namespace NzbDrone.Core.Indexers.Newznab
{
get
{
return new NewznabParser(this);
return new NewznabParser();
}
}
@ -26,7 +26,7 @@ namespace NzbDrone.Core.Indexers.Newznab
Enable = false,
Name = "Nzbs.org",
Implementation = GetType().Name,
Settings = GetSettings("http://nzbs.org", new List<Int32>{ 5000 })
Settings = GetSettings("http://nzbs.org", new List<Int32> { 5000 })
});
@ -70,7 +70,7 @@ namespace NzbDrone.Core.Indexers.Newznab
//Todo: We should be able to update settings on start
if (Name.Equals("nzbs.org", StringComparison.InvariantCultureIgnoreCase))
{
Settings.Categories = new List<int>{ 5000 };
Settings.Categories = new List<int> { 5000 };
}
var url = String.Format("{0}/api?t=tvsearch&cat={1}", Settings.Url.TrimEnd('/'), String.Join(",", Settings.Categories));

@ -8,14 +8,7 @@ namespace NzbDrone.Core.Indexers.Newznab
{
public class NewznabParser : BasicRssParser
{
private static XNamespace NEWZNAB = "http://www.newznab.com/DTD/2010/feeds/attributes/";
private readonly Newznab _newznabIndexer;
public NewznabParser(Newznab newznabIndexer)
{
_newznabIndexer = newznabIndexer;
}
private static readonly XNamespace NewznabNamespace = "http://www.newznab.com/DTD/2010/feeds/attributes/";
protected override string GetNzbInfoUrl(XElement item)
{
@ -26,7 +19,7 @@ namespace NzbDrone.Core.Indexers.Newznab
{
if (currentResult != null)
{
var attributes = item.Elements(NEWZNAB + "attr");
var attributes = item.Elements(NewznabNamespace + "attr");
var sizeElement = attributes.Single(e => e.Attribute("name").Value == "size");
currentResult.Size = Convert.ToInt64(sizeElement.Attribute("value").Value);

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data.Odbc;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace NzbDrone.Core.Indexers
@ -11,38 +9,32 @@ namespace NzbDrone.Core.Indexers
{
public static string Title(this XElement item)
{
return TryGetValue(item, "title", "Unknown");
return item.TryGetValue("title", "Unknown");
}
public static DateTime PublishDate(this XElement item)
{
return DateTime.Parse(TryGetValue(item, "pubDate"));
return DateTime.Parse(item.TryGetValue("pubDate"));
}
public static List<String> Links(this XElement item)
{
var result = new List<String>();
var elements = item.Elements("link");
foreach (var link in elements)
{
result.Add(link.Value);
}
return result;
return elements.Select(link => link.Value).ToList();
}
public static string Description(this XElement item)
{
return TryGetValue(item, "description");
return item.TryGetValue("description");
}
public static string Comments(this XElement item)
{
return TryGetValue(item, "comments");
return item.TryGetValue("comments");
}
private static string TryGetValue(XElement item, string elementName, string defaultValue = "")
private static string TryGetValue(this XElement item, string elementName, string defaultValue = "")
{
var element = item.Element(elementName);

@ -104,7 +104,6 @@
<Private>True</Private>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Web" />
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />

Loading…
Cancel
Save