add content blocker (#5)

* refactored code
added deluge support
added transmission support
added content blocker
added blacklist and whitelist

* increased level on some logs; updated test docker compose; updated dev appsettings

* updated docker compose and readme

* moved some logs

* fixed env var typo; fixed sonarr and radarr default download client
This commit is contained in:
Marius Nechifor
2024-11-18 20:08:01 +02:00
committed by GitHub
parent b323cb40ae
commit e0a6c7842b
154 changed files with 4752 additions and 789 deletions
+4
View File
@@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
+7
View File
@@ -0,0 +1,7 @@
namespace Domain.Enums;
public enum BlocklistType
{
Blacklist,
Whitelist
}
@@ -1,4 +1,4 @@
namespace Domain.Arr.Enums;
namespace Domain.Enums;
public enum InstanceType
{
@@ -3,6 +3,7 @@
public record QueueRecord
{
public int SeriesId { get; init; }
public int EpisodeId { get; init; }
public int MovieId { get; init; }
public required string Title { get; init; }
public string Status { get; init; }
@@ -0,0 +1,8 @@
namespace Domain.Models.Deluge.Exceptions;
public class DelugeClientException : Exception
{
public DelugeClientException(string message) : base(message)
{
}
}
@@ -0,0 +1,8 @@
namespace Domain.Models.Deluge.Exceptions;
public sealed class DelugeLoginException : DelugeClientException
{
public DelugeLoginException() : base("login failed")
{
}
}
@@ -0,0 +1,8 @@
namespace Domain.Models.Deluge.Exceptions;
public sealed class DelugeLogoutException : DelugeClientException
{
public DelugeLogoutException() : base("logout failed")
{
}
}
@@ -0,0 +1,32 @@
using Newtonsoft.Json;
namespace Domain.Models.Deluge.Request;
public class DelugeRequest
{
[JsonProperty(PropertyName = "id")]
public int RequestId { get; set; }
[JsonProperty(PropertyName = "method")]
public String Method { get; set; }
[JsonProperty(PropertyName = "params")]
public List<Object> Params { get; set; }
[JsonIgnore]
public NullValueHandling NullValueHandling { get; set; }
public DelugeRequest(int requestId, String method, params object[] parameters)
{
RequestId = requestId;
Method = method;
Params = new List<Object>();
if (parameters != null)
{
Params.AddRange(parameters);
}
NullValueHandling = NullValueHandling.Include;
}
}
@@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace Domain.Models.Deluge.Response;
public sealed record DelugeContents
{
[JsonPropertyName("contents")]
public Dictionary<string, DelugeFileOrDirectory> Contents { get; set; }
[JsonPropertyName("type")]
public string Type { get; set; } // Always "dir" for the root
}
@@ -0,0 +1,12 @@
using Newtonsoft.Json;
namespace Domain.Models.Deluge.Response;
public sealed record DelugeError
{
[JsonProperty(PropertyName = "message")]
public String Message { get; set; }
[JsonProperty(PropertyName = "code")]
public int Code { get; set; }
}
@@ -0,0 +1,33 @@
using System.Text.Json.Serialization;
namespace Domain.Models.Deluge.Response;
public class DelugeFileOrDirectory
{
[JsonPropertyName("type")]
public string Type { get; set; } // "file" or "dir"
[JsonPropertyName("contents")]
public Dictionary<string, DelugeFileOrDirectory>? Contents { get; set; } // Recursive property for directories
[JsonPropertyName("index")]
public required int Index { get; set; }
[JsonPropertyName("path")]
public string Path { get; set; }
[JsonPropertyName("size")]
public int? Size { get; set; }
[JsonPropertyName("offset")]
public int? Offset { get; set; }
[JsonPropertyName("progress")]
public double? Progress { get; set; }
[JsonPropertyName("priority")]
public required int Priority { get; set; }
[JsonPropertyName("progresses")]
public List<double> Progresses { get; set; }
}
@@ -0,0 +1,6 @@
namespace Domain.Models.Deluge.Response;
public sealed record DelugeMinimalStatus
{
public string? Hash { get; set; }
}
@@ -0,0 +1,15 @@
using Newtonsoft.Json;
namespace Domain.Models.Deluge.Response;
public sealed record DelugeResponse<T>
{
[JsonProperty(PropertyName = "id")]
public int ResponseId { get; set; }
[JsonProperty(PropertyName = "result")]
public T? Result { get; set; }
[JsonProperty(PropertyName = "error")]
public DelugeError? Error { get; set; }
}
@@ -0,0 +1,30 @@
using Newtonsoft.Json;
namespace Domain.Models.Deluge.Response;
public record DelugeTorrent
{
[JsonProperty(PropertyName = "comment")]
public string Comment { get; set; }
[JsonProperty(PropertyName = "is_seed")]
public bool IsSeed { get; set; }
[JsonProperty(PropertyName = "hash")]
public string Hash { get; set; }
[JsonProperty(PropertyName = "paused")]
public bool Paused { get; set; }
[JsonProperty(PropertyName = "ratio")]
public double Ratio { get; set; }
[JsonProperty(PropertyName = "message")]
public string Message { get; set; }
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
[JsonProperty(PropertyName = "label")]
public string Label { get; set; }
}
@@ -0,0 +1,110 @@
using Newtonsoft.Json;
namespace Domain.Models.Deluge.Response;
public sealed record DelugeTorrentExtended : DelugeTorrent
{
[JsonProperty(PropertyName = "total_done")]
public long TotalDone { get; set; }
[JsonProperty(PropertyName = "total_payload_download")]
public long TotalPayloadDownload { get; set; }
[JsonProperty(PropertyName = "total_uploaded")]
public long TotalUploaded { get; set; }
[JsonProperty(PropertyName = "next_announce")]
public int NextAnnounce { get; set; }
[JsonProperty(PropertyName = "tracker_status")]
public string TrackerStatus { get; set; }
[JsonProperty(PropertyName = "num_pieces")]
public int NumPieces { get; set; }
[JsonProperty(PropertyName = "piece_length")]
public long PieceLength { get; set; }
[JsonProperty(PropertyName = "is_auto_managed")]
public bool IsAutoManaged { get; set; }
[JsonProperty(PropertyName = "active_time")]
public long ActiveTime { get; set; }
[JsonProperty(PropertyName = "seeding_time")]
public long SeedingTime { get; set; }
[JsonProperty(PropertyName = "time_since_transfer")]
public long TimeSinceTransfer { get; set; }
[JsonProperty(PropertyName = "seed_rank")]
public int SeedRank { get; set; }
[JsonProperty(PropertyName = "last_seen_complete")]
public long LastSeenComplete { get; set; }
[JsonProperty(PropertyName = "completed_time")]
public long CompletedTime { get; set; }
[JsonProperty(PropertyName = "owner")] public string Owner { get; set; }
[JsonProperty(PropertyName = "public")]
public bool Public { get; set; }
[JsonProperty(PropertyName = "shared")]
public bool Shared { get; set; }
[JsonProperty(PropertyName = "queue")] public int Queue { get; set; }
[JsonProperty(PropertyName = "total_wanted")]
public long TotalWanted { get; set; }
[JsonProperty(PropertyName = "state")] public string State { get; set; }
[JsonProperty(PropertyName = "progress")]
public float Progress { get; set; }
[JsonProperty(PropertyName = "num_seeds")]
public int NumSeeds { get; set; }
[JsonProperty(PropertyName = "total_seeds")]
public int TotalSeeds { get; set; }
[JsonProperty(PropertyName = "num_peers")]
public int NumPeers { get; set; }
[JsonProperty(PropertyName = "total_peers")]
public int TotalPeers { get; set; }
[JsonProperty(PropertyName = "download_payload_rate")]
public long DownloadPayloadRate { get; set; }
[JsonProperty(PropertyName = "upload_payload_rate")]
public long UploadPayloadRate { get; set; }
[JsonProperty(PropertyName = "eta")] public long Eta { get; set; }
[JsonProperty(PropertyName = "distributed_copies")]
public float DistributedCopies { get; set; }
[JsonProperty(PropertyName = "time_added")]
public int TimeAdded { get; set; }
[JsonProperty(PropertyName = "tracker_host")]
public string TrackerHost { get; set; }
[JsonProperty(PropertyName = "download_location")]
public string DownloadLocation { get; set; }
[JsonProperty(PropertyName = "total_remaining")]
public long TotalRemaining { get; set; }
[JsonProperty(PropertyName = "max_download_speed")]
public long MaxDownloadSpeed { get; set; }
[JsonProperty(PropertyName = "max_upload_speed")]
public long MaxUploadSpeed { get; set; }
[JsonProperty(PropertyName = "seeds_peers_ratio")]
public float SeedsPeersRatio { get; set; }
}
@@ -1,4 +1,4 @@
namespace Domain.Radarr;
namespace Domain.Models.Radarr;
public sealed record RadarrCommand
{
@@ -1,4 +1,4 @@
namespace Domain.Sonarr;
namespace Domain.Models.Sonarr;
public sealed record SonarrCommand
{