mirror of
https://github.com/Radarr/Radarr
synced 2025-01-04 06:23:32 +00: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
2 changed files with 44 additions and 2 deletions
|
@ -32,7 +32,7 @@ public override IIndexerRequestGenerator GetRequestGenerator()
|
||||||
|
|
||||||
public override IParseIndexerResponse GetParser()
|
public override IParseIndexerResponse GetParser()
|
||||||
{
|
{
|
||||||
return new NewznabRssParser();
|
return new NewznabRssParser(Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<ProviderDefinition> DefaultDefinitions
|
public override IEnumerable<ProviderDefinition> DefaultDefinitions
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Indexers.Exceptions;
|
using NzbDrone.Core.Indexers.Exceptions;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using RestSharp.Extensions;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.Newznab
|
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 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";
|
PreferredEnclosureMimeType = "application/x-nzb";
|
||||||
|
_settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool PreProcess(IndexerResponse indexerResponse)
|
protected override bool PreProcess(IndexerResponse indexerResponse)
|
||||||
|
@ -50,6 +54,20 @@ protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInf
|
||||||
releaseInfo = base.ProcessItem(item, releaseInfo);
|
releaseInfo = base.ProcessItem(item, releaseInfo);
|
||||||
releaseInfo.ImdbId = GetImdbId(item);
|
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;
|
return releaseInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +143,30 @@ protected virtual int GetImdbId(XElement item)
|
||||||
return 0;
|
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 = "")
|
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));
|
var attr = item.Elements(ns + "attr").FirstOrDefault(e => e.Attribute("name").Value.Equals(key, StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
|
Loading…
Reference in a new issue