From dc9c7ff050917acdf629bb575badd25791f967d0 Mon Sep 17 00:00:00 2001 From: Sam Heinz <54530346+asylumexp@users.noreply.github.com> Date: Wed, 12 Mar 2025 18:19:24 +1000 Subject: [PATCH] [TB] Add downloading via zip functionality --- .../TorrentClients/TorBoxTorrentClient.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs b/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs index 556faa7..d68b249 100644 --- a/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs +++ b/server/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs @@ -288,9 +288,21 @@ public class TorBoxTorrentClient(ILogger logger, IHttpClien { var torrentId = await GetClient().Torrents.GetHashInfoAsync(torrent.Hash, skipCache: true); - return torrent.Files.Where(file => fileFilter.IsDownloadable(torrent, file.Path, file.Bytes)) - .Select(file => $"https://torbox.app/fakedl/{torrentId?.Id}/{file.Id}") - .ToList(); + bool allFilesDownloadable = torrent.Files.All(file => fileFilter.IsDownloadable(torrent, file.Path, file.Bytes)); + + if (allFilesDownloadable && torrent.DownloadClient != Data.Enums.DownloadClient.Symlink) + { + logger.LogDebug("Downloading files from TorBox as a zip."); + return [$"https://torbox.app/fakedl/{torrentId?.Id}/zip"]; + } + else + { + logger.LogDebug("Downloading files from TorBox individually."); + return torrent.Files + .Where(file => fileFilter.IsDownloadable(torrent, file.Path, file.Bytes)) + .Select(file => $"https://torbox.app/fakedl/{torrentId?.Id}/{file.Id}") + .ToList(); + } } public async Task GetFileName(String downloadUrl)