From d556545e7fd050da1550d8e1ed48415caa3457d5 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 28 Dec 2022 13:44:07 +0200 Subject: [PATCH] Fixed: Changed torznab parser to use additional attributes --- .../Definitions/Torznab/TorznabRssParser.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Torznab/TorznabRssParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Torznab/TorznabRssParser.cs index 6097acb85..042a41979 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Torznab/TorznabRssParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Torznab/TorznabRssParser.cs @@ -74,8 +74,18 @@ namespace NzbDrone.Core.Indexers.Torznab torrentInfo.DownloadVolumeFactor = downloadFactor; torrentInfo.UploadVolumeFactor = uploadFactor; + torrentInfo.ImdbId = GetIntAttribute(item, new[] { "imdb", "imdbid" }); + torrentInfo.TmdbId = GetIntAttribute(item, new[] { "tmdbid", "tmdb" }); + torrentInfo.TvdbId = GetIntAttribute(item, new[] { "tvdbid", "tvdb" }); + torrentInfo.TvMazeId = GetIntAttribute(item, new[] { "tvmazeid", "tvmaze" }); + torrentInfo.TraktId = GetIntAttribute(item, new[] { "traktid", "trakt" }); + torrentInfo.TvRageId = GetIntAttribute(item, new[] { "rageid" }); + torrentInfo.Grabs = GetIntAttribute(item, new[] { "grabs" }); + torrentInfo.Files = GetIntAttribute(item, new[] { "files" }); + torrentInfo.IndexerFlags = GetFlags(item); torrentInfo.PosterUrl = GetPosterUrl(item); + torrentInfo.InfoHash = GetInfoHash(item); } return torrentInfo; @@ -287,5 +297,21 @@ namespace NzbDrone.Core.Indexers.Torznab return results; } + + protected virtual int GetIntAttribute(XElement item, string[] attributes) + { + foreach (var attr in attributes) + { + var idString = TryGetTorznabAttribute(item, attr); + int idInt; + + if (!idString.IsNullOrWhiteSpace() && int.TryParse(idString, out idInt)) + { + return idInt; + } + } + + return 0; + } } }