1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-01-03 05:44:50 +00:00

Parse "tmdbid" and "imdb" attributes in Newznab and Torznab parsers

This commit is contained in:
Bogdan 2024-10-23 13:53:14 +03:00
parent 2c9292c249
commit 2d2de7f76b
2 changed files with 37 additions and 8 deletions

View file

@ -91,6 +91,8 @@ protected override bool PostProcess(IndexerResponse indexerResponse, List<XEleme
protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInfo) protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInfo)
{ {
releaseInfo = base.ProcessItem(item, releaseInfo); releaseInfo = base.ProcessItem(item, releaseInfo);
releaseInfo.TmdbId = GetTmdbId(item);
releaseInfo.ImdbId = GetImdbId(item); releaseInfo.ImdbId = GetImdbId(item);
releaseInfo.IndexerFlags = GetFlags(item); releaseInfo.IndexerFlags = GetFlags(item);
@ -173,6 +175,18 @@ protected override string GetDownloadUrl(XElement item)
return url; return url;
} }
protected virtual int GetTmdbId(XElement item)
{
var tmdbIdString = TryGetNewznabAttribute(item, "tmdbid");
if (!tmdbIdString.IsNullOrWhiteSpace() && int.TryParse(tmdbIdString, out var tmdbId))
{
return tmdbId;
}
return 0;
}
protected virtual int GetImdbId(XElement item) protected virtual int GetImdbId(XElement item)
{ {
var imdbIdString = TryGetNewznabAttribute(item, "imdb"); var imdbIdString = TryGetNewznabAttribute(item, "imdb");

View file

@ -62,11 +62,8 @@ protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInf
if (torrentInfo != null) if (torrentInfo != null)
{ {
if (GetImdbId(item) != null) torrentInfo.TmdbId = GetTmdbId(item);
{ torrentInfo.ImdbId = GetImdbId(item);
torrentInfo.ImdbId = int.Parse(GetImdbId(item).Substring(2));
}
torrentInfo.IndexerFlags = GetFlags(item); torrentInfo.IndexerFlags = GetFlags(item);
} }
@ -156,10 +153,28 @@ protected override string GetDownloadUrl(XElement item)
return url; return url;
} }
protected virtual string GetImdbId(XElement item) protected virtual int GetTmdbId(XElement item)
{ {
var imdbIdString = TryGetTorznabAttribute(item, "imdbid"); var tmdbIdString = TryGetTorznabAttribute(item, "tmdbid");
return !imdbIdString.IsNullOrWhiteSpace() ? imdbIdString.Substring(2) : null;
if (!tmdbIdString.IsNullOrWhiteSpace() && int.TryParse(tmdbIdString, out var tmdbId))
{
return tmdbId;
}
return 0;
}
protected virtual int GetImdbId(XElement item)
{
var imdbIdString = TryGetTorznabAttribute(item, "imdb");
if (!imdbIdString.IsNullOrWhiteSpace() && int.TryParse(imdbIdString, out var imdbId))
{
return imdbId;
}
return 0;
} }
protected override string GetInfoHash(XElement item) protected override string GetInfoHash(XElement item)