2013-04-07 09:30:37 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.ServiceModel.Syndication;
|
2013-04-15 03:41:39 +02:00
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-04-07 09:30:37 +02:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers.Newznab
|
|
|
|
|
{
|
|
|
|
|
public class NewznabParser : BasicRssParser
|
|
|
|
|
{
|
|
|
|
|
private readonly Newznab _newznabIndexer;
|
|
|
|
|
|
|
|
|
|
public NewznabParser(Newznab newznabIndexer)
|
|
|
|
|
{
|
|
|
|
|
_newznabIndexer = newznabIndexer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string GetNzbInfoUrl(SyndicationItem item)
|
|
|
|
|
{
|
|
|
|
|
return item.Id;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
protected override ReportInfo PostProcessor(SyndicationItem item, ReportInfo currentResult)
|
2013-04-07 09:30:37 +02:00
|
|
|
|
{
|
|
|
|
|
if (currentResult != null)
|
|
|
|
|
{
|
|
|
|
|
if (item.Links.Count > 1)
|
2013-05-02 03:59:09 +02:00
|
|
|
|
{
|
2013-04-07 09:30:37 +02:00
|
|
|
|
currentResult.Size = item.Links[1].Length;
|
2013-05-02 03:59:09 +02:00
|
|
|
|
}
|
2013-04-07 09:30:37 +02:00
|
|
|
|
|
|
|
|
|
currentResult.Indexer = GetName(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return currentResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string GetName(SyndicationItem item)
|
|
|
|
|
{
|
|
|
|
|
var hostname = item.Links[0].Uri.DnsSafeHost.ToLower();
|
|
|
|
|
return String.Format("{0}_{1}", _newznabIndexer.Name, hostname);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|