diff --git a/CHANGELOG.md b/CHANGELOG.md index 585ef0e8..531ed935 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - A quick and dirty fix for RdName including a file type extension, such as MKV and RDT-Client using the extension in the directory path causing issues, eg. with ARR apps, unless it's removed. - Added missing TorBox information to readme. - Added links to every provider's API keys to readme. +- Added uploading torrents to a secondary provider. ### Changed - Modified list sorting. - Multiple changes to default setting values including some regex in default settings to exclude certain files from being downloaded. @@ -27,6 +28,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - GHCR in build workflow. - Removed some junk from changelog. +## [2.0.92] - 2024-12-18 +### Changed +- Torbox fixes. + ## [2.0.91] - 2024-12-11 ### Changed - Torbox fixes. diff --git a/client/src/app/navbar/navbar.component.html b/client/src/app/navbar/navbar.component.html index 21173dc4..a33cc2b9 100644 --- a/client/src/app/navbar/navbar.component.html +++ b/client/src/app/navbar/navbar.component.html @@ -55,7 +55,7 @@ Profile Logout - Version 2.0.91 + Version 2.0.92 diff --git a/package.json b/package.json index 27223e05..ba7e536d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rdt-client", - "version": "2.0.91", + "version": "2.0.92", "description": "A web interface to manage your torrents on various debrid services.", "main": "index.js", "dependencies": { diff --git a/server/RdtClient.Data/Enums/SecondaryProvider.cs b/server/RdtClient.Data/Enums/SecondaryProvider.cs new file mode 100644 index 00000000..6315cb2b --- /dev/null +++ b/server/RdtClient.Data/Enums/SecondaryProvider.cs @@ -0,0 +1,18 @@ +using System.ComponentModel; + +namespace RdtClient.Data.Enums; + +public enum SecondaryProvider +{ + [Description("RealDebrid")] + RealDebrid, + + [Description("AllDebrid")] + AllDebrid, + + [Description("Premiumize")] + Premiumize, + + [Description("TorBox")] + TorBox +} \ No newline at end of file diff --git a/server/RdtClient.Data/Models/Internal/DbSettings.cs b/server/RdtClient.Data/Models/Internal/DbSettings.cs index 0411c030..5d379276 100644 --- a/server/RdtClient.Data/Models/Internal/DbSettings.cs +++ b/server/RdtClient.Data/Models/Internal/DbSettings.cs @@ -16,6 +16,10 @@ public class DbSettings [DisplayName("Provider")] [Description("")] public DbSettingsProvider Provider { get; set; } = new(); + + [DisplayName("Secondary Provider")] + [Description("")] + public DbSettingsSecondaryProvider SecondaryProvider { get; set; } = new(); [DisplayName("qBittorrent / *darr")] [Description("The following settings only apply when a torrent gets added through the qbittorrent API, usually Radarr or Sonarr.")] @@ -151,8 +155,7 @@ public class DbSettingsProvider https://real-debrid.com/ https://alldebrid.com/ https://www.premiumize.me/ -https://torbox.app/ -At this point only 1 provider can be used at the time.")] +https://torbox.app/")] public Provider Provider { get; set; } = Provider.RealDebrid; [DisplayName("API Key")] @@ -165,7 +168,48 @@ public class DbSettingsProvider or https://torbox.app/settings/")] public String ApiKey { get; set; } = ""; + + [DisplayName("Automatically import and process torrents added to provider")] + [Description("When selected, import downloads that are not added through DebridClient but have been directly added to your debrid provider.")] + public Boolean AutoImport { get; set; } = false; + + [DisplayName("Automatically delete downloads removed from provider")] + [Description("When selected, cancel and delete downloads that have been removed from your debrid provider.")] + public Boolean AutoDelete { get; set; } = false; + + [DisplayName("Connection Timeout")] + [Description("Timeout in seconds to make a connection to the provider. Increase if you experience timeouts in the logs.")] + public Int32 Timeout { get; set; } = 10; + + [DisplayName("Check Interval")] + [Description("The interval to check the torrents info on the providers API. Minumum is 3 seconds. When there are no active downloads this limit is increased * 3.")] + public Int32 CheckInterval { get; set; } = 10; + + [DisplayName("Auto Import Defaults")] + public DbSettingsDefaultsWithCategory Default { get; set; } = new(); +} + +public class DbSettingsSecondaryProvider +{ + [DisplayName("Secondary Provider")] + [Description(@"The following 4 providers are supported: +https://real-debrid.com/ +https://alldebrid.com/ +https://www.premiumize.me/ +https://torbox.app/")] + public SecondaryProvider SecondaryProvider { get; set; } = SecondaryProvider.TorBox; + [DisplayName("Secondary API Key")] + [Description(@"You can find your API key here: +https://real-debrid.com/apitoken +or +https://alldebrid.com/apikeys/ +or +https://www.premiumize.me/account/ +or +https://torbox.app/settings/")] + public String SecondaryApiKey { get; set; } = ""; + [DisplayName("Automatically import and process torrents added to provider")] [Description("When selected, import downloads that are not added through DebridClient but have been directly added to your debrid provider.")] public Boolean AutoImport { get; set; } = false; diff --git a/server/RdtClient.Service/Services/TorrentClients/AllDebridTorrentClient.cs b/server/RdtClient.Service/Services/TorrentClients/AllDebridTorrentClient.cs index dd3f4249..1dac6299 100644 --- a/server/RdtClient.Service/Services/TorrentClients/AllDebridTorrentClient.cs +++ b/server/RdtClient.Service/Services/TorrentClients/AllDebridTorrentClient.cs @@ -17,7 +17,15 @@ private AllDebridNETClient GetClient() try { var apiKey = Settings.Get.Provider.ApiKey; - + if (Settings.Get.SecondaryProvider.SecondaryProvider == SecondaryProvider.AllDebrid) + { + apiKey = Settings.Get.SecondaryProvider.SecondaryApiKey; + } + else + { + throw new InvalidOperationException("All-Debrid is not set as a provider."); + } + if (String.IsNullOrWhiteSpace(apiKey)) { throw new("All-Debrid API Key not set in the settings"); diff --git a/server/RdtClient.Service/Services/TorrentClients/PremiumizeTorrentClient.cs b/server/RdtClient.Service/Services/TorrentClients/PremiumizeTorrentClient.cs index 4a1745b6..a1667870 100644 --- a/server/RdtClient.Service/Services/TorrentClients/PremiumizeTorrentClient.cs +++ b/server/RdtClient.Service/Services/TorrentClients/PremiumizeTorrentClient.cs @@ -16,7 +16,15 @@ private PremiumizeNETClient GetClient() try { var apiKey = Settings.Get.Provider.ApiKey; - + if (Settings.Get.SecondaryProvider.SecondaryProvider == SecondaryProvider.Premiumize) + { + apiKey = Settings.Get.SecondaryProvider.SecondaryApiKey; + } + else + { + throw new InvalidOperationException("Premiumize is not set as a provider."); + } + if (String.IsNullOrWhiteSpace(apiKey)) { throw new("Premiumize API Key not set in the settings"); diff --git a/server/RdtClient.Service/Services/TorrentClients/RealDebridTorrentClient.cs b/server/RdtClient.Service/Services/TorrentClients/RealDebridTorrentClient.cs index 12359c46..78383cee 100644 --- a/server/RdtClient.Service/Services/TorrentClients/RealDebridTorrentClient.cs +++ b/server/RdtClient.Service/Services/TorrentClients/RealDebridTorrentClient.cs @@ -18,7 +18,15 @@ private RdNetClient GetClient() try { var apiKey = Settings.Get.Provider.ApiKey; - + if (Settings.Get.SecondaryProvider.SecondaryProvider == SecondaryProvider.RealDebrid) + { + apiKey = Settings.Get.SecondaryProvider.SecondaryApiKey; + } + else + { + throw new InvalidOperationException("Real-Debrid is not set as a provider."); + } + if (String.IsNullOrWhiteSpace(apiKey)) { throw new("Real-Debrid API Key not set in the settings"); diff --git a/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs b/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs index 69b2f950..574dca3a 100644 --- a/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs +++ b/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs @@ -15,7 +15,15 @@ private TorBoxNetClient GetClient() try { var apiKey = Settings.Get.Provider.ApiKey; - + if (Settings.Get.SecondaryProvider.SecondaryProvider == SecondaryProvider.TorBox) + { + apiKey = Settings.Get.SecondaryProvider.SecondaryApiKey; + } + else + { + throw new InvalidOperationException("TorBox is not set as a provider."); + } + if (String.IsNullOrWhiteSpace(apiKey)) { throw new("TorBox API Key not set in the settings"); @@ -74,7 +82,7 @@ private TorrentClientTorrent Map(TorrentInfoResult torrent) Progress = (Int64)(torrent.Progress * 100.0), Status = torrent.DownloadState, Added = ChangeTimeZone(torrent.CreatedAt)!.Value, - Files = (torrent.Files).Select(m => new TorrentClientFile + Files = (torrent.Files ?? []).Select(m => new TorrentClientFile { Path = String.Join("/", m.Name.Split('/').Skip(1)), Bytes = m.Size, diff --git a/server/RdtClient.Service/Services/Torrents.cs b/server/RdtClient.Service/Services/Torrents.cs index cc254c6d..d40dc670 100644 --- a/server/RdtClient.Service/Services/Torrents.cs +++ b/server/RdtClient.Service/Services/Torrents.cs @@ -46,6 +46,21 @@ private ITorrentClient TorrentClient }; } } + + private ITorrentClient SecondaryTorrentClient + { + get + { + return Settings.Get.SecondaryProvider.SecondaryProvider switch + { + SecondaryProvider.Premiumize => premiumizeTorrentClient, + SecondaryProvider.RealDebrid => realDebridTorrentClient, + SecondaryProvider.AllDebrid => allDebridTorrentClient, + SecondaryProvider.TorBox => torBoxTorrentClient, + _ => throw new("Invalid Secondary Provider") + }; + } + } private static readonly SemaphoreSlim TorrentResetLock = new(1, 1); @@ -147,6 +162,13 @@ public async Task UploadMagnet(String magnetLink, Torrent torrent) } } + if (!String.IsNullOrWhiteSpace(Settings.Get.SecondaryProvider.SecondaryApiKey)) + { + // Add to secondary provider + var secondaryID = await SecondaryTorrentClient.AddMagnet(magnetLink); + Log($"Magnet link also added to secondary provider with ID {secondaryID}", torrent); + } + return newTorrent; } @@ -198,6 +220,13 @@ public async Task UploadFile(Byte[] bytes, Torrent torrent) } } + if (!String.IsNullOrWhiteSpace(Settings.Get.SecondaryProvider.SecondaryApiKey)) + { + // Add to secondary provider + var secondaryID = await SecondaryTorrentClient.AddFile(bytes); + Log($"Magnet link also added to secondary provider with ID {secondaryID}", torrent); + } + return newTorrent; } diff --git a/server/RdtClient.Web/RdtClient.Web.csproj b/server/RdtClient.Web/RdtClient.Web.csproj index 3647d333..dea7f253 100644 --- a/server/RdtClient.Web/RdtClient.Web.csproj +++ b/server/RdtClient.Web/RdtClient.Web.csproj @@ -4,7 +4,7 @@ net9.0 Exe 94c24cba-f03f-4453-a671-3640b517c573 - 2.0.91 + 2.0.92 enable enable latest