1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-10-02 06:07:19 +02:00

Fixed: Exclude invalid releases from Newznab and Torznab parsers

(cherry picked from commit fb060730c7d52cd342484dc68595698a9430df7b)
This commit is contained in:
Bogdan 2024-06-20 00:16:53 +03:00
parent 9a2b4bc81d
commit 7dc64c595c
3 changed files with 29 additions and 27 deletions

View File

@ -72,16 +72,17 @@ protected override bool PreProcess(IndexerResponse indexerResponse)
protected override bool PostProcess(IndexerResponse indexerResponse, List<XElement> items, List<ReleaseInfo> releases)
{
var enclosureTypes = items.SelectMany(GetEnclosures).Select(v => v.Type).Distinct().ToArray();
if (enclosureTypes.Any() && enclosureTypes.Intersect(PreferredEnclosureMimeTypes).Empty())
{
if (enclosureTypes.Intersect(TorrentEnclosureMimeTypes).Any())
{
_logger.Warn("{0} does not contain {1}, found {2}, did you intend to add a Torznab indexer?", indexerResponse.Request.Url, NzbEnclosureMimeType, enclosureTypes[0]);
return false;
}
else
{
_logger.Warn("{1} does not contain {1}, found {2}.", indexerResponse.Request.Url, NzbEnclosureMimeType, enclosureTypes[0]);
}
_logger.Warn("{0} does not contain {1}, found {2}.", indexerResponse.Request.Url, NzbEnclosureMimeType, enclosureTypes[0]);
}
return true;

View File

@ -264,26 +264,26 @@ protected virtual long GetEnclosureLength(XElement item)
protected virtual RssEnclosure[] GetEnclosures(XElement item)
{
var enclosures = item.Elements("enclosure")
.Select(v =>
{
try
{
return new RssEnclosure
{
Url = v.Attribute("url")?.Value,
Type = v.Attribute("type")?.Value,
Length = v.Attribute("length")?.Value?.ParseInt64() ?? 0
};
}
catch (Exception e)
{
_logger.Warn(e, "Failed to get enclosure for: {0}", item.Title());
}
.Select(v =>
{
try
{
return new RssEnclosure
{
Url = v.Attribute("url")?.Value,
Type = v.Attribute("type")?.Value,
Length = v.Attribute("length")?.Value?.ParseInt64() ?? 0
};
}
catch (Exception ex)
{
_logger.Warn(ex, "Failed to get enclosure for: {0}", item.Title());
}
return null;
})
.Where(v => v != null)
.ToArray();
return null;
})
.Where(v => v != null)
.ToArray();
return enclosures;
}

View File

@ -76,16 +76,17 @@ protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInf
protected override bool PostProcess(IndexerResponse indexerResponse, List<XElement> items, List<ReleaseInfo> releases)
{
var enclosureTypes = items.SelectMany(GetEnclosures).Select(v => v.Type).Distinct().ToArray();
if (enclosureTypes.Any() && enclosureTypes.Intersect(PreferredEnclosureMimeTypes).Empty())
{
if (enclosureTypes.Intersect(UsenetEnclosureMimeTypes).Any())
{
_logger.Warn("{0} does not contain {1}, found {2}, did you intend to add a Newznab indexer?", indexerResponse.Request.Url, TorrentEnclosureMimeType, enclosureTypes[0]);
return false;
}
else
{
_logger.Warn("{1} does not contain {1}, found {2}.", indexerResponse.Request.Url, TorrentEnclosureMimeType, enclosureTypes[0]);
}
_logger.Warn("{0} does not contain {1}, found {2}.", indexerResponse.Request.Url, TorrentEnclosureMimeType, enclosureTypes[0]);
}
return true;