diff --git a/server/RdtClient.Data/Models/Internal/DbSettings.cs b/server/RdtClient.Data/Models/Internal/DbSettings.cs
index 1f014ad..c7d4cf1 100644
--- a/server/RdtClient.Data/Models/Internal/DbSettings.cs
+++ b/server/RdtClient.Data/Models/Internal/DbSettings.cs
@@ -177,6 +177,14 @@ or
[DisplayName("Auto Import Defaults")]
public DbSettingsDefaultsWithCategory Default { get; set; } = new();
+
+ [DisplayName("Seeding")]
+ [Description("Set the priority of a torrent, 1 = Auto, 2 = Seed, 3 = disabled. [TorBox Only]")]
+ public Int32 Seeding { get; set; } = 3;
+
+ [DisplayName("Download as Zip")]
+ [Description("Whether to download the files individually or zipped. [TorBox Only]")]
+ public bool Zipped { get; set; } = true;
}
public class DbSettingsIntegrations
@@ -263,12 +271,4 @@ public class DbSettingsDefaults
[DisplayName("Priority")]
[Description("Set the priority of a torrent, 1 = highest, 0 = disabled.")]
public Int32 Priority { get; set; } = 0;
-
- [DisplayName("Seeding")]
- [Description("Set the priority of a torrent, 1 = Auto, 2 = Seed, 3 = disabled. [TorBox Only]")]
- public Int32 Seeding { get; set; } = 3;
-
- [DisplayName("Download as Zip")]
- [Description("Whether to download the files individually or zipped. [TorBox Only]")]
- public bool Zipped { get; set; } = true;
}
\ No newline at end of file
diff --git a/server/RdtClient.Service/RdtClient.Service.csproj b/server/RdtClient.Service/RdtClient.Service.csproj
index fba85e6..ed3e98b 100644
--- a/server/RdtClient.Service/RdtClient.Service.csproj
+++ b/server/RdtClient.Service/RdtClient.Service.csproj
@@ -22,7 +22,7 @@
-
+
diff --git a/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs b/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs
index 5879ef4..830842b 100644
--- a/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs
+++ b/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs
@@ -4,14 +4,12 @@ using TorBoxNET;
using RdtClient.Data.Enums;
using RdtClient.Data.Models.TorrentClient;
using RdtClient.Service.Helpers;
-using RdtClient.Data.Models.Internal;
namespace RdtClient.Service.Services.TorrentClients;
public class TorBoxTorrentClient(ILogger logger, IHttpClientFactory httpClientFactory) : ITorrentClient
{
private TimeSpan? _offset;
- private DbSettingsDefaults _dbSettings = new DbSettingsDefaults();
private TorBoxNetClient GetClient()
{
try
@@ -122,8 +120,9 @@ public class TorBoxTorrentClient(ILogger logger, IHttpClien
public async Task AddMagnet(String magnetLink)
{
-
- var result = await GetClient().Torrents.AddMagnetAsync(magnetLink, _dbSettings.Seeding, _dbSettings.Zipped);
+ var seeding = Settings.Get.Provider.Seeding;
+ var zipped = Settings.Get.Provider.Zipped;
+ var result = await GetClient().Torrents.AddMagnetAsync(magnetLink, seeding, zipped);
if (result.Error == "ACTIVE_LIMIT")
{
@@ -138,7 +137,9 @@ public class TorBoxTorrentClient(ILogger logger, IHttpClien
public async Task AddFile(Byte[] bytes)
{
- var result = await GetClient().Torrents.AddFileAsync(bytes, _dbSettings.Seeding, _dbSettings.Zipped);
+ var seeding = Settings.Get.Provider.Seeding;
+ var zipped = Settings.Get.Provider.Zipped;
+ var result = await GetClient().Torrents.AddFileAsync(bytes, seeding, zipped);
if (result.Error == "ACTIVE_LIMIT")
{
using (var stream = new MemoryStream(bytes))
@@ -189,17 +190,21 @@ public class TorBoxTorrentClient(ILogger logger, IHttpClien
await GetClient().Torrents.ControlAsync(torrentId, "delete");
}
- public async Task Unrestrict(String link)
+ public async Task Unrestrict(string link)
{
- var torrentFile = new List(link.Split('/'));
- var result = await GetClient().Unrestrict.LinkAsync(torrentID: torrentFile[4], fileID: torrentFile[5]);
+ var segments = link.Split('/');
- if (result.Error != null)
+ bool zipped = segments[5] == "zip";
+ string fileId = zipped ? "0" : segments[5];
+
+ var result = await GetClient().Unrestrict.LinkAsync(torrentID: segments[4], fileID: fileId, zipped: zipped);
+
+ if (result?.Error != null)
{
- throw new($"Unrestrict returned an invalid download");
+ throw new("Unrestrict returned an invalid download");
}
- return result.Data!;
+ return result!.Data!;
}
public async Task UpdateData(Data.Models.Data.Torrent torrent, TorrentClientTorrent? torrentClientTorrent)
@@ -297,8 +302,12 @@ public class TorBoxTorrentClient(ILogger logger, IHttpClien
var files = new List();
var torrentId = await GetClient().Torrents.GetInfoAsync(torrent.Hash, skipCache: true);
-
- if (rdTorrent.Files?.Count != 0)
+ if (Settings.Get.Provider.Zipped == true && rdTorrent.Files!.Count() > 100 && torrentId!.AllowZipped == true)
+ {
+ var newFile = $"https://torbox.app/fakedl/{torrentId?.Id}/zip";
+ files.Add(newFile);
+ }
+ else if (rdTorrent.Files?.Count != 0)
{
foreach (var file in rdTorrent.Files!)
{