mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Try to add year to release titles that have no year (foriegn release groups) (#1028)
This commit is contained in:
parent
ddc6ccbf15
commit
e3dc31cca5
@ -32,7 +32,7 @@ public override IIndexerRequestGenerator GetRequestGenerator()
|
||||
|
||||
public override IParseIndexerResponse GetParser()
|
||||
{
|
||||
return new NewznabRssParser();
|
||||
return new NewznabRssParser(Settings);
|
||||
}
|
||||
|
||||
public override IEnumerable<ProviderDefinition> DefaultDefinitions
|
||||
|
@ -4,6 +4,7 @@
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Indexers.Exceptions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using RestSharp.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Newznab
|
||||
{
|
||||
@ -11,9 +12,12 @@ public class NewznabRssParser : RssParser
|
||||
{
|
||||
public const string ns = "{http://www.newznab.com/DTD/2010/feeds/attributes/}";
|
||||
|
||||
public NewznabRssParser()
|
||||
private readonly NewznabSettings _settings;
|
||||
|
||||
public NewznabRssParser(NewznabSettings settings)
|
||||
{
|
||||
PreferredEnclosureMimeType = "application/x-nzb";
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
protected override bool PreProcess(IndexerResponse indexerResponse)
|
||||
@ -50,6 +54,20 @@ protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInf
|
||||
releaseInfo = base.ProcessItem(item, releaseInfo);
|
||||
releaseInfo.ImdbId = GetImdbId(item);
|
||||
|
||||
// Fun, lets try to add year to the releaseTitle for our foriegn friends :)
|
||||
if (!releaseInfo.Title.Contains(GetImdbTitle(item) + "." + GetImdbYear(item)))
|
||||
{
|
||||
if (GetImdbYear(item) != 1900)
|
||||
{
|
||||
releaseInfo.Title = releaseInfo.Title.Replace(GetImdbTitle(item), GetImdbTitle(item) + "." + GetImdbYear(item));
|
||||
}
|
||||
}
|
||||
|
||||
//if (_settings.Url == "https://newz-complex.org/www/")
|
||||
//{
|
||||
// releaseInfo.Title = releaseInfo.Title.Replace(GetImdbTitle(item), GetImdbTitle(item) + "." + GetImdbYear(item));
|
||||
//}
|
||||
|
||||
return releaseInfo;
|
||||
}
|
||||
|
||||
@ -125,6 +143,30 @@ protected virtual int GetImdbId(XElement item)
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected virtual string GetImdbTitle(XElement item)
|
||||
{
|
||||
var imdbTitle = TryGetNewznabAttribute(item, "imdbtitle");
|
||||
if (!imdbTitle.IsNullOrWhiteSpace())
|
||||
{
|
||||
return imdbTitle;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
protected virtual int GetImdbYear(XElement item)
|
||||
{
|
||||
var imdbYearString = TryGetNewznabAttribute(item, "imdbyear");
|
||||
int imdbYear;
|
||||
|
||||
if (!imdbYearString.IsNullOrWhiteSpace() && int.TryParse(imdbYearString, out imdbYear))
|
||||
{
|
||||
return imdbYear;
|
||||
}
|
||||
|
||||
return 1900;
|
||||
}
|
||||
|
||||
protected string TryGetNewznabAttribute(XElement item, string key, string defaultValue = "")
|
||||
{
|
||||
var attr = item.Elements(ns + "attr").FirstOrDefault(e => e.Attribute("name").Value.Equals(key, StringComparison.CurrentCultureIgnoreCase));
|
||||
|
Loading…
Reference in New Issue
Block a user