Fixed: (Newznab) Parse Imdb, Tmdb, RageId, Tvdbid from indexer

Fixes #656
This commit is contained in:
Qstick
2021-11-30 21:47:44 -06:00
parent 1ffab661da
commit b5a2f68bde
2 changed files with 12 additions and 36 deletions

View File

@@ -90,7 +90,7 @@ namespace NzbDrone.Core.IndexerSearch
r.Categories == null ? null : from c in r.Categories select GetNabElement("category", c.Id, protocol), r.Categories == null ? null : from c in r.Categories select GetNabElement("category", c.Id, protocol),
r.IndexerFlags == null ? null : from f in r.IndexerFlags select GetNabElement("tag", f.Name, protocol), r.IndexerFlags == null ? null : from f in r.IndexerFlags select GetNabElement("tag", f.Name, protocol),
GetNabElement("rageid", r.TvRageId, protocol), GetNabElement("rageid", r.TvRageId, protocol),
GetNabElement("thetvdb", r.TvdbId, protocol), GetNabElement("tvdbid", r.TvdbId, protocol),
GetNabElement("imdb", r.ImdbId.ToString("D7"), protocol), GetNabElement("imdb", r.ImdbId.ToString("D7"), protocol),
GetNabElement("tmdb", r.TmdbId, protocol), GetNabElement("tmdb", r.TmdbId, protocol),
GetNabElement("seeders", t.Seeders, protocol), GetNabElement("seeders", t.Seeders, protocol),

View File

@@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.Indexers.Exceptions;
@@ -96,9 +95,12 @@ namespace NzbDrone.Core.Indexers.Newznab
} }
releaseInfo = base.ProcessItem(item, releaseInfo); releaseInfo = base.ProcessItem(item, releaseInfo);
releaseInfo.ImdbId = GetImdbId(item); releaseInfo.ImdbId = GetIntAttribute(item, "imdb");
releaseInfo.Grabs = GetGrabs(item); releaseInfo.TmdbId = GetIntAttribute(item, "tmdb");
releaseInfo.Files = GetFiles(item); releaseInfo.TvdbId = GetIntAttribute(item, "tvdbid");
releaseInfo.TvRageId = GetIntAttribute(item, "rageid");
releaseInfo.Grabs = GetIntAttribute(item, "grabs");
releaseInfo.Files = GetIntAttribute(item, "files");
releaseInfo.PosterUrl = GetPosterUrl(item); releaseInfo.PosterUrl = GetPosterUrl(item);
return releaseInfo; return releaseInfo;
@@ -195,27 +197,14 @@ namespace NzbDrone.Core.Indexers.Newznab
return url; return url;
} }
protected virtual int GetImdbId(XElement item) protected virtual int GetIntAttribute(XElement item, string attribute)
{ {
var imdbIdString = TryGetNewznabAttribute(item, "imdb"); var idString = TryGetNewznabAttribute(item, attribute);
int imdbId; int idInt;
if (!imdbIdString.IsNullOrWhiteSpace() && int.TryParse(imdbIdString, out imdbId)) if (!idString.IsNullOrWhiteSpace() && int.TryParse(idString, out idInt))
{ {
return imdbId; return idInt;
}
return 0;
}
protected virtual int GetGrabs(XElement item)
{
var grabsString = TryGetNewznabAttribute(item, "grabs");
int grabs;
if (!grabsString.IsNullOrWhiteSpace() && int.TryParse(grabsString, out grabs))
{
return grabs;
} }
return 0; return 0;
@@ -226,19 +215,6 @@ namespace NzbDrone.Core.Indexers.Newznab
return ParseUrl(TryGetNewznabAttribute(item, "coverurl")); return ParseUrl(TryGetNewznabAttribute(item, "coverurl"));
} }
protected virtual int GetFiles(XElement item)
{
var filesString = TryGetNewznabAttribute(item, "files");
int files;
if (!filesString.IsNullOrWhiteSpace() && int.TryParse(filesString, out files))
{
return files;
}
return 0;
}
protected virtual int GetImdbYear(XElement item) protected virtual int GetImdbYear(XElement item)
{ {
var imdbYearString = TryGetNewznabAttribute(item, "imdbyear"); var imdbYearString = TryGetNewznabAttribute(item, "imdbyear");