Fixed: (Anime Tosho) Only include Releases which have a NZB (#351)

pull/360/head
Yukine 3 years ago committed by GitHub
parent 4cbd2cd8bc
commit afa87b7113
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers.Exceptions;
@ -80,6 +81,20 @@ namespace NzbDrone.Core.Indexers.Newznab
protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInfo)
{
if (!item.Elements("enclosure").Any(e =>
{
var type = e.Attribute("type");
if (type == null)
{
return true;
}
return type.Value == "application/x-nzb";
}))
{
return null;
}
releaseInfo = base.ProcessItem(item, releaseInfo);
releaseInfo.ImdbId = GetImdbId(item);
releaseInfo.Grabs = GetGrabs(item);
@ -151,7 +166,29 @@ namespace NzbDrone.Core.Indexers.Newznab
if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
{
url = ParseUrl((string)item.Element("enclosure").Attribute("url"));
var enclosure = item.Elements("enclosure");
var filtered = enclosure.Where(e =>
{
var type = e.Attribute("type");
if (type == null)
{
return true;
}
return type.Value == "application/x-nzb";
});
var xElements = filtered as XElement[] ?? filtered.ToArray();
if (!xElements.Any())
{
return url;
}
var attr = xElements.First().Attribute("url");
if (attr != null)
{
url = attr.Value;
}
}
return url;

@ -82,12 +82,7 @@ namespace NzbDrone.Core.Indexers
}
}
if (!PostProcess(indexerResponse, items, releases))
{
return new List<ReleaseInfo>();
}
return releases;
return !PostProcess(indexerResponse, items, releases) ? new List<ReleaseInfo>() : releases;
}
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
@ -147,6 +142,11 @@ namespace NzbDrone.Core.Indexers
releaseInfo = ProcessItem(item, releaseInfo);
if (releaseInfo == null)
{
return null;
}
_logger.Trace("Parsed: {0}", releaseInfo.Title);
return PostProcessItem(item, releaseInfo);

Loading…
Cancel
Save