mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
Allow trackers url to be configurable + version bump (#173)
this allows people to use only the udp collection, only the tcp collection, or all.
This commit is contained in:
@@ -3,7 +3,9 @@ namespace QBitCollector.Features.Qbit;
|
||||
public class QbitConfiguration
|
||||
{
|
||||
private const string Prefix = "QBIT";
|
||||
private const string ConnectionStringVariable = "HOST";
|
||||
private const string HOST_VARIABLE = "HOST";
|
||||
private const string TRACKERS_URL_VARIABLE = "TRACKERS_URL";
|
||||
|
||||
public string? Host { get; init; } = Prefix.GetRequiredEnvironmentVariableAsString(ConnectionStringVariable);
|
||||
public string? Host { get; init; } = Prefix.GetRequiredEnvironmentVariableAsString(HOST_VARIABLE);
|
||||
public string? TrackersUrl { get; init; } = Prefix.GetRequiredEnvironmentVariableAsString(TRACKERS_URL_VARIABLE);
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace QBitCollector.Features.Trackers;
|
||||
|
||||
public class TrackersService(IDistributedCache cache, HttpClient client, IMemoryCache memoryCache) : ITrackersService
|
||||
public class TrackersService(IDistributedCache cache, HttpClient client, IMemoryCache memoryCache, QbitConfiguration configuration) : ITrackersService
|
||||
{
|
||||
private const string TrackersListUrl = "https://ngosang.github.io/trackerslist/trackers_all.txt";
|
||||
private const string CacheKey = "trackers";
|
||||
|
||||
public async Task<List<string>> GetTrackers()
|
||||
@@ -42,7 +41,7 @@ public class TrackersService(IDistributedCache cache, HttpClient client, IMemory
|
||||
|
||||
private async Task<List<string>> GetTrackersAsync()
|
||||
{
|
||||
var response = await client.GetStringAsync(TrackersListUrl);
|
||||
var response = await client.GetStringAsync(configuration.TrackersUrl);
|
||||
|
||||
var lines = response.Split(["\r\n", "\r", "\n"], StringSplitOptions.None);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user