New: Use languages from Torznab/Newznab attributes if given

(cherry picked from commit 9c5a07f62a6e32832c10c80813cd3b98c5859989)
pull/1682/head
Qstick 2 years ago committed by Bogdan
parent ec40761757
commit 1fc79f9e9b

@ -126,6 +126,28 @@ namespace NzbDrone.Core.Indexers.Headphones
return results;
}
protected override List<string> GetLanguages(XElement item)
{
var languges = TryGetMultipleNewznabAttributes(item, "language");
var results = new List<string>();
// Try to find <language> elements for some indexers that suck at following the rules.
if (languges.Count == 0)
{
languges = item.Elements("language").Select(e => e.Value).ToList();
}
foreach (var language in languges)
{
if (language.IsNotNullOrWhiteSpace())
{
results.Add(language);
}
}
return results;
}
protected override long GetSize(XElement item)
{
long size;

@ -154,6 +154,28 @@ namespace NzbDrone.Core.Indexers.Newznab
return results;
}
protected override List<string> GetLanguages(XElement item)
{
var languges = TryGetMultipleNewznabAttributes(item, "language");
var results = new List<string>();
// Try to find <language> elements for some indexers that suck at following the rules.
if (languges.Count == 0)
{
languges = item.Elements("language").Select(e => e.Value).ToList();
}
foreach (var language in languges)
{
if (language.IsNotNullOrWhiteSpace())
{
results.Add(language);
}
}
return results;
}
protected override long GetSize(XElement item)
{
long size;

@ -125,6 +125,28 @@ namespace NzbDrone.Core.Indexers.Torznab
return ParseUrl(item.TryGetValue("comments"));
}
protected override List<string> GetLanguages(XElement item)
{
var languges = TryGetMultipleTorznabAttributes(item, "language");
var results = new List<string>();
// Try to find <language> elements for some indexers that suck at following the rules.
if (languges.Count == 0)
{
languges = item.Elements("language").Select(e => e.Value).ToList();
}
foreach (var language in languges)
{
if (language.IsNotNullOrWhiteSpace())
{
results.Add(language);
}
}
return results;
}
protected override long GetSize(XElement item)
{
long size;

@ -166,6 +166,7 @@ namespace NzbDrone.Core.Indexers
releaseInfo.InfoUrl = GetInfoUrl(item);
releaseInfo.CommentUrl = GetCommentUrl(item);
releaseInfo.Categories = GetCategory(item);
releaseInfo.Languages = GetLanguages(item);
try
{
@ -237,6 +238,11 @@ namespace NzbDrone.Core.Indexers
return ParseUrl((string)item.Element("comments"));
}
protected virtual List<string> GetLanguages(XElement item)
{
return new List<string>();
}
protected virtual long GetSize(XElement item)
{
if (UseEnclosureLength)

Loading…
Cancel
Save