Add DB values for seeding and zipped, pass to addtorrent
This commit is contained in:
parent
91dcdb9d7c
commit
70584d1acb
3 changed files with 17 additions and 6 deletions
|
|
@ -55,7 +55,8 @@
|
|||
<a href="https://www.premiumize.me/" target="_blank" rel="noopener"
|
||||
>Use this link to sign up to Premiumize.</a
|
||||
>
|
||||
<a href="https://torbox.app/" target="_blank" rel="noopener">Use this link to sign up to Premiumize.</a>
|
||||
<a href="https://torbox.app/" target="_blank" rel="noopener"
|
||||
>Use this link to sign up to TorBox.</a>
|
||||
<br />
|
||||
<small>(Referal links)</small>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -263,4 +263,12 @@ 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;
|
||||
}
|
||||
|
|
@ -4,14 +4,14 @@ using TorBoxNET;
|
|||
using RdtClient.Data.Enums;
|
||||
using RdtClient.Data.Models.TorrentClient;
|
||||
using RdtClient.Service.Helpers;
|
||||
using MonoTorrent;
|
||||
using RdtClient.Data.Models.Internal;
|
||||
|
||||
namespace RdtClient.Service.Services.TorrentClients;
|
||||
|
||||
public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClientFactory httpClientFactory) : ITorrentClient
|
||||
{
|
||||
private TimeSpan? _offset;
|
||||
|
||||
private DbSettingsDefaults _dbSettings = new DbSettingsDefaults();
|
||||
private TorBoxNetClient GetClient()
|
||||
{
|
||||
try
|
||||
|
|
@ -122,7 +122,8 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
|||
|
||||
public async Task<String> AddMagnet(String magnetLink)
|
||||
{
|
||||
var result = await GetClient().Torrents.AddMagnetAsync(magnetLink, seeding: 2);
|
||||
|
||||
var result = await GetClient().Torrents.AddMagnetAsync(magnetLink, _dbSettings.Seeding, _dbSettings.Zipped);
|
||||
|
||||
if (result.Error == "ACTIVE_LIMIT")
|
||||
{
|
||||
|
|
@ -137,7 +138,7 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
|||
|
||||
public async Task<String> AddFile(Byte[] bytes)
|
||||
{
|
||||
var result = await GetClient().Torrents.AddFileAsync(bytes, seeding: 2);
|
||||
var result = await GetClient().Torrents.AddFileAsync(bytes, _dbSettings.Seeding, _dbSettings.Zipped);
|
||||
if (result.Error == "ACTIVE_LIMIT")
|
||||
{
|
||||
using (var stream = new MemoryStream(bytes))
|
||||
|
|
@ -145,7 +146,8 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
|||
var torrent = MonoTorrent.Torrent.Load(stream);
|
||||
return torrent!.InfoHash.ToHex()!.ToLowerInvariant();
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
return result.Data!.Hash!;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue