From 2cbdb5bcba03cf36f53054263558103d3a8dedbe Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 16 Nov 2023 18:49:46 +0200 Subject: [PATCH] New: (HDBits) Add Use Filenames option --- .../Indexers/Definitions/HDBits/HDBitsParser.cs | 10 +++++++++- .../Indexers/Definitions/HDBits/HDBitsSettings.cs | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsParser.cs b/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsParser.cs index cc3493b2d..b157aaf9b 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsParser.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Net; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.Parser.Model; @@ -73,7 +74,7 @@ namespace NzbDrone.Core.Indexers.Definitions.HDBits releaseInfos.Add(new HDBitsInfo { Guid = $"HDBits-{id}", - Title = result.Name, + Title = GetTitle(result), Size = result.Size, Categories = _categories.MapTrackerCatToNewznab(result.TypeCategory.ToString()), InfoHash = result.Hash, @@ -99,6 +100,13 @@ namespace NzbDrone.Core.Indexers.Definitions.HDBits public Action, DateTime?> CookiesUpdater { get; set; } + private string GetTitle(TorrentQueryResponse item) + { + return _settings.UseFilenames && item.FileName.IsNotNullOrWhiteSpace() + ? item.FileName.Replace(".torrent", "", StringComparison.InvariantCultureIgnoreCase) + : item.Name; + } + private double GetDownloadVolumeFactor(TorrentQueryResponse item) { if (item.FreeLeech == "yes") diff --git a/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsSettings.cs b/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsSettings.cs index e93f025f4..9047a26d5 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsSettings.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsSettings.cs @@ -25,6 +25,7 @@ namespace NzbDrone.Core.Indexers.Definitions.HDBits Codecs = Array.Empty(); Mediums = Array.Empty(); FreeleechOnly = false; + UseFilenames = false; } [FieldDefinition(2, Label = "Username", HelpText = "Site Username", Privacy = PrivacyLevel.UserName)] @@ -42,6 +43,9 @@ namespace NzbDrone.Core.Indexers.Definitions.HDBits [FieldDefinition(6, Label = "Freeleech Only", Type = FieldType.Checkbox, Advanced = true, HelpText = "Show freeleech releases only")] public bool FreeleechOnly { get; set; } + [FieldDefinition(7, Label = "Use Filenames", Type = FieldType.Checkbox, HelpText = "Check this option if you want to use torrent filenames as release titles")] + public bool UseFilenames { get; set; } + public override NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this));