Add Premiumize fixes and logging.
Swapped the internal downloader for a new one.
This commit is contained in:
parent
8595e797b6
commit
ffa5e274b7
10 changed files with 70 additions and 97 deletions
|
|
@ -4,6 +4,13 @@ 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/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2.0.26] - 2023-03-30
|
||||
### Changed
|
||||
- Add some logging for Premiumize to better understand errors.
|
||||
- Changed Premiumize to download each file individually instead of creating a zip first.
|
||||
- Swapped the internal downloader for a new version.
|
||||
- Fixed issue when switching providers and it not switching over properly.
|
||||
|
||||
## [2.0.25] - 2023-03-17
|
||||
### Changed
|
||||
- Fixed docker run issues.
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
<a class="navbar-item" routerLink="profile"> Profile </a>
|
||||
<a class="navbar-item" (click)="logout()"> Logout </a>
|
||||
<hr class="navbar-divider" />
|
||||
<div class="navbar-item">Version 2.0.25</div>
|
||||
<div class="navbar-item">Version 2.0.26</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "rdt-client",
|
||||
"version": "2.0.25",
|
||||
"version": "2.0.26",
|
||||
"description": "This is a web interface to manage your torrents on Real-Debrid.",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -95,10 +95,6 @@ public class DbSettingsDownloadClient
|
|||
[Description("Maximum amount of parallel threads that are used to download a single file to your host. If set to 0 no parallel downloading will be done.")]
|
||||
public Int32 ParallelCount { get; set; } = 0;
|
||||
|
||||
[DisplayName("Parallel chunks per download (only used for the Internal Downloader)")]
|
||||
[Description("Split each parallel download in chunks.")]
|
||||
public Int32 ChunkCount { get; set; } = 1;
|
||||
|
||||
[DisplayName("Connection Timeout (only used for the Internal Downloader)")]
|
||||
[Description("Timeout in milliseconds before the downloader times out.")]
|
||||
public Int32 Timeout { get; set; } = 5000;
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@
|
|||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="AllDebrid.NET" Version="1.0.12" />
|
||||
<PackageReference Include="Aria2.NET" Version="1.0.5" />
|
||||
<PackageReference Include="Downloader" Version="3.0.4" />
|
||||
<PackageReference Include="Downloader.NET" Version="1.0.0" />
|
||||
<PackageReference Include="MonoTorrent" Version="2.0.7" />
|
||||
<PackageReference Include="Premiumize.NET" Version="1.0.1" />
|
||||
<PackageReference Include="Premiumize.NET" Version="1.0.3" />
|
||||
<PackageReference Include="RD.NET" Version="2.1.4" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.32.2" />
|
||||
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class DownloadClient
|
|||
|
||||
public IDownloader? Downloader;
|
||||
|
||||
public Data.Enums.DownloadClient Type { get; set; }
|
||||
public Data.Enums.DownloadClient Type { get; private set; }
|
||||
|
||||
public Boolean Finished { get; private set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Net;
|
||||
using Downloader;
|
||||
using DownloaderNET;
|
||||
using Serilog;
|
||||
|
||||
namespace RdtClient.Service.Services.Downloaders;
|
||||
|
|
@ -9,14 +8,16 @@ public class InternalDownloader : IDownloader
|
|||
public event EventHandler<DownloadCompleteEventArgs>? DownloadComplete;
|
||||
public event EventHandler<DownloadProgressEventArgs>? DownloadProgress;
|
||||
|
||||
private readonly DownloadService _downloadService;
|
||||
private readonly DownloadConfiguration _downloadConfiguration;
|
||||
private readonly Downloader _downloadService;
|
||||
private readonly DownloaderNET.Settings _downloadConfiguration;
|
||||
|
||||
private readonly String _filePath;
|
||||
private readonly String _uri;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly CancellationTokenSource _cancellationToken = new();
|
||||
|
||||
private Boolean _finished;
|
||||
|
||||
public InternalDownloader(String uri, String filePath)
|
||||
|
|
@ -25,40 +26,14 @@ public class InternalDownloader : IDownloader
|
|||
|
||||
_uri = uri;
|
||||
_filePath = filePath;
|
||||
|
||||
var settingProxyServer = Settings.Get.DownloadClient.ProxyServer;
|
||||
|
||||
// For all options, see https://github.com/bezzad/Downloader
|
||||
_downloadConfiguration = new DownloadConfiguration
|
||||
{
|
||||
BufferBlockSize = 1024 * 8,
|
||||
MaxTryAgainOnFailover = 5,
|
||||
RangeDownload = false,
|
||||
ClearPackageOnCompletionWithFailure = false,
|
||||
MinimumSizeOfChunking = 1024,
|
||||
ReserveStorageSpaceBeforeStartingDownload = false,
|
||||
CheckDiskSizeBeforeDownload = true,
|
||||
RequestConfiguration =
|
||||
{
|
||||
Accept = "*/*",
|
||||
UserAgent = $"rdt-client",
|
||||
ProtocolVersion = HttpVersion.Version11,
|
||||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
|
||||
KeepAlive = true,
|
||||
UseDefaultCredentials = false
|
||||
}
|
||||
};
|
||||
|
||||
_downloadConfiguration = new DownloaderNET.Settings();
|
||||
|
||||
SetSettings();
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(settingProxyServer))
|
||||
{
|
||||
_downloadConfiguration.RequestConfiguration.Proxy = new WebProxy(new Uri(settingProxyServer), false);
|
||||
}
|
||||
_downloadService = new Downloader(_uri, _filePath, _downloadConfiguration, _cancellationToken.Token);
|
||||
|
||||
_downloadService = new DownloadService(_downloadConfiguration);
|
||||
|
||||
_downloadService.DownloadProgressChanged += (_, args) =>
|
||||
_downloadService.OnProgress += args =>
|
||||
{
|
||||
if (DownloadProgress == null)
|
||||
{
|
||||
|
|
@ -68,32 +43,23 @@ public class InternalDownloader : IDownloader
|
|||
DownloadProgress.Invoke(this,
|
||||
new DownloadProgressEventArgs
|
||||
{
|
||||
Speed = (Int64)args.BytesPerSecondSpeed,
|
||||
BytesDone = args.ReceivedBytesSize,
|
||||
BytesTotal = args.TotalBytesToReceive
|
||||
Speed = (Int64) args.Average(m => m.Speed),
|
||||
BytesDone = args.Sum(m => m.DownloadBytes),
|
||||
BytesTotal = args.Sum(m => m.LengthBytes)
|
||||
});
|
||||
};
|
||||
|
||||
_downloadService.DownloadFileCompleted += (_, args) =>
|
||||
_downloadService.OnComplete += error =>
|
||||
{
|
||||
String? error = null;
|
||||
|
||||
if (args.Cancelled)
|
||||
{
|
||||
error = $"The download was cancelled";
|
||||
}
|
||||
else if (args.Error != null)
|
||||
{
|
||||
error = args.Error.Message;
|
||||
}
|
||||
|
||||
DownloadComplete?.Invoke(this,
|
||||
new DownloadCompleteEventArgs
|
||||
{
|
||||
Error = error
|
||||
Error = error?.Message
|
||||
});
|
||||
|
||||
_finished = true;
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -101,11 +67,7 @@ public class InternalDownloader : IDownloader
|
|||
{
|
||||
_logger.Debug($"Starting download of {_uri}, writing to path: {_filePath}");
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _downloadService.DownloadFileTaskAsync(_uri, _filePath);
|
||||
});
|
||||
|
||||
Task.Run(_downloadService.Download);
|
||||
Task.Run(StartTimer);
|
||||
|
||||
return Task.FromResult<String?>(null);
|
||||
|
|
@ -115,7 +77,7 @@ public class InternalDownloader : IDownloader
|
|||
{
|
||||
_logger.Debug($"Cancelling download {_uri}");
|
||||
|
||||
_downloadService.CancelAsync();
|
||||
_cancellationToken.Cancel(false);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
@ -138,14 +100,7 @@ public class InternalDownloader : IDownloader
|
|||
{
|
||||
settingDownloadParallelCount = 1;
|
||||
}
|
||||
|
||||
var settingDownloadChunkCount = Settings.Get.DownloadClient.ChunkCount;
|
||||
|
||||
if (settingDownloadChunkCount <= 0)
|
||||
{
|
||||
settingDownloadChunkCount = 1;
|
||||
}
|
||||
|
||||
|
||||
var settingDownloadMaxSpeed = Settings.Get.DownloadClient.MaxSpeed;
|
||||
|
||||
if (settingDownloadMaxSpeed <= 0)
|
||||
|
|
@ -162,10 +117,8 @@ public class InternalDownloader : IDownloader
|
|||
settingDownloadTimeout = 1000;
|
||||
}
|
||||
|
||||
_downloadConfiguration.ChunkCount = settingDownloadChunkCount;
|
||||
_downloadConfiguration.ChunkCount = settingDownloadParallelCount;
|
||||
_downloadConfiguration.MaximumBytesPerSecond = settingDownloadMaxSpeed;
|
||||
_downloadConfiguration.ParallelDownload = settingDownloadChunkCount > 1;
|
||||
_downloadConfiguration.ParallelCount = settingDownloadParallelCount;
|
||||
_downloadConfiguration.Timeout = settingDownloadTimeout;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -228,29 +228,35 @@ public class PremiumizeTorrentClient : ITorrentClient
|
|||
}
|
||||
|
||||
var transfers = await GetClient().Transfers.ListAsync();
|
||||
|
||||
Log($"Found {transfers.Count} transfers", torrent);
|
||||
|
||||
var transfer = transfers.FirstOrDefault(m => m.Id == torrent.RdId);
|
||||
|
||||
if (transfer == null)
|
||||
{
|
||||
Log($"Transfer {torrent.RdId} not found!", torrent);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(transfer.FolderId))
|
||||
{
|
||||
Log($"Transfer {torrent.RdId} has no folderId!", torrent);
|
||||
return null;
|
||||
}
|
||||
|
||||
var zip = await GetClient()
|
||||
.Zip.Generate(new List<String>(),
|
||||
new List<String>
|
||||
{
|
||||
transfer.FolderId
|
||||
});
|
||||
var files = await GetClient().Folder.ListAsync(transfer.FolderId);
|
||||
|
||||
return new List<String>
|
||||
var downloadLinks = files.Content.Where(m => !String.IsNullOrWhiteSpace(m.Link)).Select(m => m.Link).ToList();
|
||||
|
||||
Log($"Found {downloadLinks.Count} links", torrent);
|
||||
|
||||
foreach (var link in downloadLinks)
|
||||
{
|
||||
zip
|
||||
};
|
||||
Log($"{link}", torrent);
|
||||
}
|
||||
|
||||
return downloadLinks;
|
||||
}
|
||||
|
||||
private async Task<TorrentClientTorrent> GetInfo(String id)
|
||||
|
|
|
|||
|
|
@ -23,8 +23,24 @@ public class Torrents
|
|||
private readonly ILogger<Torrents> _logger;
|
||||
private readonly TorrentData _torrentData;
|
||||
private readonly Downloads _downloads;
|
||||
|
||||
private readonly ITorrentClient _torrentClient;
|
||||
|
||||
private readonly AllDebridTorrentClient _allDebridTorrentClient;
|
||||
private readonly PremiumizeTorrentClient _premiumizeTorrentClient;
|
||||
private readonly RealDebridTorrentClient _realDebridTorrentClient;
|
||||
|
||||
private ITorrentClient _torrentClient
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Get.Provider.Provider switch
|
||||
{
|
||||
Provider.Premiumize => _premiumizeTorrentClient,
|
||||
Provider.RealDebrid => _realDebridTorrentClient,
|
||||
Provider.AllDebrid => _allDebridTorrentClient,
|
||||
_ => throw new Exception("Invalid Provider")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly SemaphoreSlim TorrentResetLock = new(1, 1);
|
||||
|
||||
|
|
@ -38,14 +54,9 @@ public class Torrents
|
|||
_logger = logger;
|
||||
_torrentData = torrentData;
|
||||
_downloads = downloads;
|
||||
|
||||
_torrentClient = Settings.Get.Provider.Provider switch
|
||||
{
|
||||
Provider.Premiumize => premiumizeTorrentClient,
|
||||
Provider.RealDebrid => realDebridTorrentClient,
|
||||
Provider.AllDebrid => allDebridTorrentClient,
|
||||
_ => throw new Exception("Invalid Provider")
|
||||
};
|
||||
_allDebridTorrentClient = allDebridTorrentClient;
|
||||
_premiumizeTorrentClient = premiumizeTorrentClient;
|
||||
_realDebridTorrentClient = realDebridTorrentClient;
|
||||
}
|
||||
|
||||
public async Task<IList<Torrent>> Get()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>net6.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<UserSecretsId>94c24cba-f03f-4453-a671-3640b517c573</UserSecretsId>
|
||||
<Version>2.0.25</Version>
|
||||
<Version>2.0.26</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>latest</LangVersion>
|
||||
|
|
|
|||
Loading…
Reference in a new issue