Merge branch 'master' into refactor/get-download-info
This commit is contained in:
commit
609c67e0c6
5 changed files with 84 additions and 19 deletions
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
|
@ -9,7 +9,7 @@ assignees: ''
|
||||||
|
|
||||||
**What version are you using?**
|
**What version are you using?**
|
||||||
|
|
||||||
**Wat OS are you running?**
|
**What OS are you running?**
|
||||||
|
|
||||||
**Are you using Docker or as a service?**
|
**Are you using Docker or as a service?**
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Changed
|
||||||
|
- Download .zip of torrent files from TorBox when possible, thanks @asylumexp!
|
||||||
|
|
||||||
## [2.0.102] - 2025-03-07
|
## [2.0.102] - 2025-03-07
|
||||||
### Changed
|
### Changed
|
||||||
- Fixed Angular build for Docker.
|
- Fixed Angular build for Docker.
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using Newtonsoft.Json;
|
||||||
using TorBoxNET;
|
using TorBoxNET;
|
||||||
using RdtClient.Data.Enums;
|
using RdtClient.Data.Enums;
|
||||||
using RdtClient.Data.Models.TorrentClient;
|
using RdtClient.Data.Models.TorrentClient;
|
||||||
|
using System.Web;
|
||||||
using RdtClient.Data.Models.Data;
|
using RdtClient.Data.Models.Data;
|
||||||
using RdtClient.Service.Helpers;
|
using RdtClient.Service.Helpers;
|
||||||
|
|
||||||
|
|
@ -287,10 +288,32 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
||||||
public async Task<IList<DownloadInfo>?> GetDownloadInfos(Torrent torrent)
|
public async Task<IList<DownloadInfo>?> GetDownloadInfos(Torrent torrent)
|
||||||
{
|
{
|
||||||
var torrentId = await GetClient().Torrents.GetHashInfoAsync(torrent.Hash, skipCache: true);
|
var torrentId = await GetClient().Torrents.GetHashInfoAsync(torrent.Hash, skipCache: true);
|
||||||
|
var downloadableFiles = torrent.Files.Where(file => fileFilter.IsDownloadable(torrent, file.Path, file.Bytes)).ToList();
|
||||||
|
|
||||||
return torrent.Files.Where(file => fileFilter.IsDownloadable(torrent, file.Path, file.Bytes))
|
if (downloadableFiles.Count == torrent.Files.Count && torrent.DownloadClient != Data.Enums.DownloadClient.Symlink)
|
||||||
.Select(file => new DownloadInfo { RestrictedLink = $"https://torbox.app/fakedl/{torrentId?.Id}/{file.Id}", FileName = Path.GetFileName(file.Path)})
|
{
|
||||||
.ToList();
|
logger.LogDebug("Downloading files from TorBox as a zip.");
|
||||||
|
|
||||||
|
return
|
||||||
|
[
|
||||||
|
new DownloadInfo
|
||||||
|
{
|
||||||
|
RestrictedLink = $"https://torbox.app/fakedl/{torrentId?.Id}/zip",
|
||||||
|
FileName = $"{torrent.RdName}.zip"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogDebug("Downloading files from TorBox individually.");
|
||||||
|
|
||||||
|
return downloadableFiles.Select(file => new DownloadInfo
|
||||||
|
{
|
||||||
|
RestrictedLink = $"https://torbox.app/fakedl/{torrentId?.Id}/{file.Id}",
|
||||||
|
FileName = Path.GetFileName(file.Path)
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
@ -319,6 +342,43 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
||||||
return Map(result!);
|
return Map(result!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void MoveHashDirContents(String extractPath, Torrent _torrent)
|
||||||
|
{
|
||||||
|
var hashDir = Path.Combine(extractPath, _torrent.Hash);
|
||||||
|
|
||||||
|
if (Directory.Exists(hashDir))
|
||||||
|
{
|
||||||
|
var innerFolder = Directory.GetDirectories(hashDir)[0];
|
||||||
|
|
||||||
|
var moveDir = extractPath;
|
||||||
|
if (!extractPath.EndsWith(_torrent.RdName!))
|
||||||
|
{
|
||||||
|
moveDir = hashDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var file in Directory.GetFiles(innerFolder))
|
||||||
|
{
|
||||||
|
var destFile = Path.Combine(moveDir, Path.GetFileName(file));
|
||||||
|
File.Move(file, destFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var dir in Directory.GetDirectories(innerFolder))
|
||||||
|
{
|
||||||
|
var destDir = Path.Combine(moveDir, Path.GetFileName(dir));
|
||||||
|
Directory.Move(dir, destDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extractPath.Contains(_torrent.RdName!))
|
||||||
|
{
|
||||||
|
Directory.Delete(innerFolder, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Directory.Delete(hashDir, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void Log(String message, Torrent? torrent = null)
|
private void Log(String message, Torrent? torrent = null)
|
||||||
{
|
{
|
||||||
if (torrent != null)
|
if (torrent != null)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ using RdtClient.Service.Services.Downloaders;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Web;
|
|
||||||
|
|
||||||
namespace RdtClient.Service.Services;
|
namespace RdtClient.Service.Services;
|
||||||
|
|
||||||
|
|
@ -450,13 +449,8 @@ public class TorrentRunner(ILogger<TorrentRunner> logger, Torrents torrents, Dow
|
||||||
|
|
||||||
// Check if the unpacking process is even needed
|
// Check if the unpacking process is even needed
|
||||||
var uri = new Uri(download.Link);
|
var uri = new Uri(download.Link);
|
||||||
var fileName = uri.Segments.Last();
|
|
||||||
|
|
||||||
fileName = HttpUtility.UrlDecode(fileName);
|
var extension = Path.GetExtension(download.FileName);
|
||||||
|
|
||||||
Log($"Found file name {fileName}", download, torrent);
|
|
||||||
|
|
||||||
var extension = Path.GetExtension(fileName);
|
|
||||||
|
|
||||||
if ((extension != ".rar" && extension != ".zip") ||
|
if ((extension != ".rar" && extension != ".zip") ||
|
||||||
torrent.DownloadClient == Data.Enums.DownloadClient.Symlink)
|
torrent.DownloadClient == Data.Enums.DownloadClient.Symlink)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using RdtClient.Data.Models.Data;
|
using RdtClient.Data.Models.Data;
|
||||||
using RdtClient.Service.Helpers;
|
using RdtClient.Service.Helpers;
|
||||||
|
using RdtClient.Service.Services.TorrentClients;
|
||||||
using SharpCompress.Archives;
|
using SharpCompress.Archives;
|
||||||
using SharpCompress.Archives.Rar;
|
using SharpCompress.Archives.Rar;
|
||||||
using SharpCompress.Archives.Zip;
|
using SharpCompress.Archives.Zip;
|
||||||
|
|
@ -102,6 +103,11 @@ public class UnpackClient(Download download, String destinationPath)
|
||||||
|
|
||||||
await FileHelper.Delete(filePath);
|
await FileHelper.Delete(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_torrent.ClientKind == Data.Enums.Provider.TorBox)
|
||||||
|
{
|
||||||
|
TorBoxTorrentClient.MoveHashDirContents(extractPath, _torrent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -113,6 +119,7 @@ public class UnpackClient(Download download, String destinationPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static async Task<IList<String>> GetArchiveFiles(String filePath)
|
private static async Task<IList<String>> GetArchiveFiles(String filePath)
|
||||||
{
|
{
|
||||||
await using Stream stream = File.OpenRead(filePath);
|
await using Stream stream = File.OpenRead(filePath);
|
||||||
|
|
@ -161,7 +168,7 @@ public class UnpackClient(Download download, String destinationPath)
|
||||||
d =>
|
d =>
|
||||||
{
|
{
|
||||||
Debug.WriteLine(d);
|
Debug.WriteLine(d);
|
||||||
Progess = (Int32) Math.Round(d);
|
Progess = (Int32)Math.Round(d);
|
||||||
},
|
},
|
||||||
cancellationToken: cancellationToken);
|
cancellationToken: cancellationToken);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue