mirror of
https://github.com/Radarr/Radarr
synced 2024-12-26 17:59:14 +00:00
minor feed fetch cleanup.
This commit is contained in:
parent
8f1127b57e
commit
bac51706ae
5 changed files with 16 additions and 35 deletions
|
@ -94,16 +94,13 @@ private List<ReportInfo> Fetch(IIndexer indexer, IEnumerable<string> urls)
|
|||
{
|
||||
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));
|
||||
_logger.Trace("Downloading Feed " + url);
|
||||
var stream = _httpProvider.DownloadStream(url);
|
||||
result.AddRange(indexer.Parser.Process(stream));
|
||||
}
|
||||
catch (WebException webException)
|
||||
{
|
||||
|
@ -114,13 +111,13 @@ private List<ReportInfo> Fetch(IIndexer indexer, IEnumerable<string> urls)
|
|||
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 @@ public override IParseFeed Parser
|
|||
{
|
||||
get
|
||||
{
|
||||
return new NewznabParser(this);
|
||||
return new NewznabParser();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public override IEnumerable<IndexerDefinition> DefaultDefinitions
|
|||
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 @@ public override IEnumerable<string> RecentFeed
|
|||
//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 @@ protected override ReportInfo PostProcessor(XElement item, ReportInfo currentRes
|
|||
{
|
||||
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 @@ public static class XElementExtensions
|
|||
{
|
||||
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…
Reference in a new issue