TorznabClient 1.0.3

dotnet add package TorznabClient --version 1.0.3                
NuGet\Install-Package TorznabClient -Version 1.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TorznabClient" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TorznabClient --version 1.0.3                
#r "nuget: TorznabClient, 1.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TorznabClient as a Cake Addin
#addin nuget:?package=TorznabClient&version=1.0.3

// Install TorznabClient as a Cake Tool
#tool nuget:?package=TorznabClient&version=1.0.3                

TorznabClient

NuGet Test

This is a C# client for the Torznab protocol, it also works with Jackett.

Usage Jackett

You can use the AddJackettClient extension method to add the IJackettClient to the service collection. The configuration is expected to be in the JackettClient section of the configuration, but you can change that by passing a sectionName to the AddJackettClient method.

Additionally you can take a look at the TorznabClient.Demo project for a complete example.

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using TorznabClient;

var builder = Host.CreateApplicationBuilder();

// Load configuration, in this case from an in-memory collection.
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddInMemoryCollection(new Dictionary<string, string?>
{
    ["JackettClient:Url"] = "http://localhost:9117/", // Note, only put the base url here.
    ["JackettClient:ApiKey"] = "your_api_key"
});
builder.Configuration.AddConfiguration(configurationBuilder.Build());

// Add Torznab client to the service collection.
builder.Services.AddJackettClient(builder.Configuration);

var host = builder.Build();

var client = host.Services.GetRequiredService<IJackettClient>();
var indexers = await client.GetIndexersAsync();

Console.WriteLine(indexers);

Usage Torznab

You can use the AddTorznabClient extension method to add the ITorznabClient to the service collection. The configuration is expected to be in the TorznabClient section of the configuration, but like in the previous section, you can change that by passing a sectionName to the AddTorznabClient method.

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using TorznabClient;

var builder = Host.CreateApplicationBuilder();

// Load configuration, in this case from an in-memory collection.
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddInMemoryCollection(new Dictionary<string, string?>
{
    ["TorznabClient:Url"] = "http://localhost:9117/api/v2.0/indexers/all/results/torznab",
    ["TorznabClient:ApiKey"] = "your_api_key"
});
builder.Configuration.AddConfiguration(configurationBuilder.Build());

// Add Torznab client to the service collection.
builder.Services.AddTorznabClient(builder.Configuration);

var host = builder.Build();

var client = host.Services.GetRequiredService<ITorznabClient>();
var caps = await client.GetCapsAsync();

Console.WriteLine(caps);

Customizing the client

This works for both the Jackett as well as the Torznab client.

// Specify a custom section name.
builder.Services.AddTorznabClient(builder.Configuration, sectionName: "CustomSectionName");

// Customize the HttpClient
builder.Services.AddTorznabClient(builder.Configuration, configureClient: (IServiceProvider provider, HttpClient httpClient) =>
{
    httpClient.Timeout = TimeSpan.FromSeconds(10);
    httpClient.DefaultRequestHeaders.Add("User-Agent", "TorznabClient.Demo");
});

// Use a Polly policy
builder.Services.AddTorznabClient(builder.Configuration, configureClientBuilder: (IHttpClientBuilder clientBuilder) =>
{
    clientBuilder.AddPolicyHandler(GetRetryPolicy());
});

static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
{
    return HttpPolicyExtensions
        .HandleTransientHttpError()
        .OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
        .WaitAndRetryAsync(6, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2,
            retryAttempt)));
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 123 3/12/2024
1.0.2 88 3/12/2024