mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
Fixed: Exclude invalid releases from Newznab and Torznab parsers
(cherry picked from commit fb060730c7d52cd342484dc68595698a9430df7b)
This commit is contained in:
parent
e8ab1f842b
commit
8af134882b
3 changed files with 29 additions and 27 deletions
|
@ -68,16 +68,17 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||||
protected override bool PostProcess(IndexerResponse indexerResponse, List<XElement> items, List<ReleaseInfo> releases)
|
protected override bool PostProcess(IndexerResponse indexerResponse, List<XElement> items, List<ReleaseInfo> releases)
|
||||||
{
|
{
|
||||||
var enclosureTypes = items.SelectMany(GetEnclosures).Select(v => v.Type).Distinct().ToArray();
|
var enclosureTypes = items.SelectMany(GetEnclosures).Select(v => v.Type).Distinct().ToArray();
|
||||||
|
|
||||||
if (enclosureTypes.Any() && enclosureTypes.Intersect(PreferredEnclosureMimeTypes).Empty())
|
if (enclosureTypes.Any() && enclosureTypes.Intersect(PreferredEnclosureMimeTypes).Empty())
|
||||||
{
|
{
|
||||||
if (enclosureTypes.Intersect(TorrentEnclosureMimeTypes).Any())
|
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]);
|
_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("{0} does not contain {1}, found {2}.", indexerResponse.Request.Url, NzbEnclosureMimeType, enclosureTypes[0]);
|
||||||
_logger.Warn("{1} does not contain {1}, found {2}.", indexerResponse.Request.Url, NzbEnclosureMimeType, enclosureTypes[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -262,26 +262,26 @@ namespace NzbDrone.Core.Indexers
|
||||||
protected virtual RssEnclosure[] GetEnclosures(XElement item)
|
protected virtual RssEnclosure[] GetEnclosures(XElement item)
|
||||||
{
|
{
|
||||||
var enclosures = item.Elements("enclosure")
|
var enclosures = item.Elements("enclosure")
|
||||||
.Select(v =>
|
.Select(v =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new RssEnclosure
|
return new RssEnclosure
|
||||||
{
|
{
|
||||||
Url = v.Attribute("url")?.Value,
|
Url = v.Attribute("url")?.Value,
|
||||||
Type = v.Attribute("type")?.Value,
|
Type = v.Attribute("type")?.Value,
|
||||||
Length = v.Attribute("length")?.Value?.ParseInt64() ?? 0
|
Length = v.Attribute("length")?.Value?.ParseInt64() ?? 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Warn(e, "Failed to get enclosure for: {0}", item.Title());
|
_logger.Warn(ex, "Failed to get enclosure for: {0}", item.Title());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.Where(v => v != null)
|
.Where(v => v != null)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
return enclosures;
|
return enclosures;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,16 +59,17 @@ namespace NzbDrone.Core.Indexers.Torznab
|
||||||
protected override bool PostProcess(IndexerResponse indexerResponse, List<XElement> items, List<ReleaseInfo> releases)
|
protected override bool PostProcess(IndexerResponse indexerResponse, List<XElement> items, List<ReleaseInfo> releases)
|
||||||
{
|
{
|
||||||
var enclosureTypes = items.SelectMany(GetEnclosures).Select(v => v.Type).Distinct().ToArray();
|
var enclosureTypes = items.SelectMany(GetEnclosures).Select(v => v.Type).Distinct().ToArray();
|
||||||
|
|
||||||
if (enclosureTypes.Any() && enclosureTypes.Intersect(PreferredEnclosureMimeTypes).Empty())
|
if (enclosureTypes.Any() && enclosureTypes.Intersect(PreferredEnclosureMimeTypes).Empty())
|
||||||
{
|
{
|
||||||
if (enclosureTypes.Intersect(UsenetEnclosureMimeTypes).Any())
|
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]);
|
_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("{0} does not contain {1}, found {2}.", indexerResponse.Request.Url, TorrentEnclosureMimeType, enclosureTypes[0]);
|
||||||
_logger.Warn("{1} does not contain {1}, found {2}.", indexerResponse.Request.Url, TorrentEnclosureMimeType, enclosureTypes[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue