Support for Gazelle Indexers (RED, AR)

This commit is contained in:
Qstick
2021-02-14 00:47:21 -05:00
parent 0fb7168669
commit 30367b53fd
71 changed files with 1196 additions and 1933 deletions
@@ -7,6 +7,7 @@ namespace NzbDrone.Core.Indexers.HDBits
public class HDBits : HttpIndexerBase<HDBitsSettings>
{
public override string Name => "HDBits";
public override string BaseUrl => "https://hdbits.org";
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
public override IndexerPrivacy Privacy => IndexerPrivacy.Private;
@@ -19,12 +20,12 @@ namespace NzbDrone.Core.Indexers.HDBits
public override IIndexerRequestGenerator GetRequestGenerator()
{
return new HDBitsRequestGenerator() { Settings = Settings };
return new HDBitsRequestGenerator() { Settings = Settings, BaseUrl = BaseUrl };
}
public override IParseIndexerResponse GetParser()
{
return new HDBitsParser(Settings);
return new HDBitsParser(Settings, BaseUrl);
}
}
}
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Net;
using Newtonsoft.Json;
@@ -11,11 +11,13 @@ namespace NzbDrone.Core.Indexers.HDBits
{
public class HDBitsParser : IParseIndexerResponse
{
private readonly string _baseUrl;
private readonly HDBitsSettings _settings;
public HDBitsParser(HDBitsSettings settings)
public HDBitsParser(HDBitsSettings settings, string baseUrl)
{
_settings = settings;
_baseUrl = baseUrl;
}
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
@@ -89,7 +91,7 @@ namespace NzbDrone.Core.Indexers.HDBits
private string GetDownloadUrl(string torrentId)
{
var url = new HttpUri(_settings.BaseUrl)
var url = new HttpUri(_baseUrl)
.CombinePath("/download.php")
.AddQueryParam("id", torrentId)
.AddQueryParam("passkey", _settings.ApiKey);
@@ -99,7 +101,7 @@ namespace NzbDrone.Core.Indexers.HDBits
private string GetInfoUrl(string torrentId)
{
var url = new HttpUri(_settings.BaseUrl)
var url = new HttpUri(_baseUrl)
.CombinePath("/details.php")
.AddQueryParam("id", torrentId);
@@ -11,6 +11,7 @@ namespace NzbDrone.Core.Indexers.HDBits
public class HDBitsRequestGenerator : IIndexerRequestGenerator
{
public HDBitsSettings Settings { get; set; }
public string BaseUrl { get; set; }
public virtual IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
{
@@ -52,7 +53,7 @@ namespace NzbDrone.Core.Indexers.HDBits
private IEnumerable<IndexerRequest> GetRequest(TorrentQuery query)
{
var request = new HttpRequestBuilder(Settings.BaseUrl)
var request = new HttpRequestBuilder(BaseUrl)
.Resource("/api/torrents")
.Build();
@@ -1,8 +1,7 @@
using System.Collections.Generic;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Languages;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.HDBits
@@ -11,18 +10,16 @@ namespace NzbDrone.Core.Indexers.HDBits
{
public HDBitsSettingsValidator()
{
RuleFor(c => c.BaseUrl).ValidRootUrl();
RuleFor(c => c.ApiKey).NotEmpty();
}
}
public class HDBitsSettings : IIndexerSettings
public class HDBitsSettings : IProviderConfig
{
private static readonly HDBitsSettingsValidator Validator = new HDBitsSettingsValidator();
public HDBitsSettings()
{
BaseUrl = "https://hdbits.org";
Codecs = System.Array.Empty<int>();
Mediums = System.Array.Empty<int>();
}
@@ -33,9 +30,6 @@ namespace NzbDrone.Core.Indexers.HDBits
[FieldDefinition(2, Label = "API Key", Privacy = PrivacyLevel.ApiKey)]
public string ApiKey { get; set; }
[FieldDefinition(3, Label = "API URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since your API key will be sent to that host.")]
public string BaseUrl { get; set; }
[FieldDefinition(5, Label = "Codecs", Type = FieldType.TagSelect, SelectOptions = typeof(HdBitsCodec), Advanced = true, HelpText = "Options: h264, Mpeg2, VC1, Xvid. If unspecified, all options are used.")]
public IEnumerable<int> Codecs { get; set; }