Add option to only download the files that are available on RD.
This commit is contained in:
parent
8bd26b7441
commit
ed10c630ee
8 changed files with 56 additions and 16 deletions
|
|
@ -112,6 +112,19 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" [(ngModel)]="settingOnlyDownloadAvailableFiles" />
|
||||
Only download available files on RealDebrid
|
||||
</label>
|
||||
<div class="help">
|
||||
When selected, it will only download files in the torrent that have been download by Real Debrid. You can
|
||||
use this in combination with the Min File size setting above.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label">Test download path permissions</label>
|
||||
<div class="control">
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ export class SettingsComponent implements OnInit {
|
|||
public settingDownloadMaxSpeed: number;
|
||||
public settingUnpackLimit: number;
|
||||
public settingMinFileSize: number;
|
||||
public settingOnlyDownloadAvailableFiles: boolean;
|
||||
|
||||
constructor(private settingsService: SettingsService) {}
|
||||
|
||||
|
|
@ -66,6 +67,7 @@ export class SettingsComponent implements OnInit {
|
|||
this.settingDownloadMaxSpeed = parseInt(this.getSetting(results, 'DownloadMaxSpeed'), 10);
|
||||
this.settingUnpackLimit = parseInt(this.getSetting(results, 'UnpackLimit'), 10);
|
||||
this.settingMinFileSize = parseInt(this.getSetting(results, 'MinFileSize'), 10);
|
||||
this.settingOnlyDownloadAvailableFiles = this.getSetting(results, 'OnlyDownloadAvailableFiles') === 'true';
|
||||
},
|
||||
(err) => {
|
||||
this.error = err.error;
|
||||
|
|
@ -118,6 +120,10 @@ export class SettingsComponent implements OnInit {
|
|||
settingId: 'MinFileSize',
|
||||
value: (this.settingMinFileSize ?? 0).toString(),
|
||||
},
|
||||
{
|
||||
settingId: 'OnlyDownloadAvailableFiles',
|
||||
value: (this.settingOnlyDownloadAvailableFiles ? '1' : '0').toString(),
|
||||
},
|
||||
];
|
||||
|
||||
this.settingsService.update(settings).subscribe(
|
||||
|
|
|
|||
|
|
@ -101,6 +101,12 @@ namespace RdtClient.Data.Data
|
|||
Value = "0"
|
||||
},
|
||||
new Setting
|
||||
{
|
||||
SettingId = "OnlyDownloadAvailableFiles",
|
||||
Type = "Int32",
|
||||
Value = "1"
|
||||
},
|
||||
new Setting
|
||||
{
|
||||
SettingId = "DownloadChunkCount",
|
||||
Type = "Int32",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="RD.NET" Version="1.0.0" />
|
||||
<PackageReference Include="RD.NET" Version="1.0.1" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Downloader" Version="2.0.7" />
|
||||
<PackageReference Include="Downloader" Version="2.0.9" />
|
||||
<PackageReference Include="MonoTorrent" Version="1.0.28" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="RD.NET" Version="1.0.0" />
|
||||
<PackageReference Include="RD.NET" Version="1.0.1" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="Serilog.Exceptions" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
|
||||
|
|
|
|||
|
|
@ -77,7 +77,10 @@ namespace RdtClient.Service.Services
|
|||
}
|
||||
|
||||
settingMinFileSize = settingMinFileSize * 1024 * 1024;
|
||||
|
||||
|
||||
var settingOnlyDownloadAvailableFilesRaw = settings.GetNumber("OnlyDownloadAvailableFiles");
|
||||
var settingOnlyDownloadAvailableFiles = settingOnlyDownloadAvailableFilesRaw == 1;
|
||||
|
||||
var settingDownloadLimit = settings.GetNumber("DownloadLimit");
|
||||
if (settingDownloadLimit < 1)
|
||||
{
|
||||
|
|
@ -264,18 +267,22 @@ namespace RdtClient.Service.Services
|
|||
// RealDebrid is waiting for file selection, select which files to download.
|
||||
if (torrent.AutoDownload && torrent.RdStatus == RealDebridStatus.WaitingForFileSelection)
|
||||
{
|
||||
var fileIds = torrent.Files
|
||||
.Select(m => m.Id.ToString())
|
||||
.ToArray();
|
||||
var files = torrent.Files;
|
||||
|
||||
if (settingOnlyDownloadAvailableFiles)
|
||||
{
|
||||
var availableFiles = await _torrents.GetAvailableFiles(torrent.Hash);
|
||||
|
||||
files = torrent.Files.Where(m => availableFiles.Any(f => m.Path.EndsWith(f))).ToList();
|
||||
}
|
||||
|
||||
if (settingMinFileSize > 0)
|
||||
{
|
||||
fileIds = torrent.Files
|
||||
.Where(m => m.Bytes > settingMinFileSize)
|
||||
.Select(m => m.Id.ToString())
|
||||
.ToArray();
|
||||
files = files.Where(m => m.Bytes > settingMinFileSize).ToList();
|
||||
}
|
||||
|
||||
var fileIds = files.Select(m => m.Id.ToString()).ToArray();
|
||||
|
||||
await _torrents.SelectFiles(torrent.RdId, fileIds);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ namespace RdtClient.Service.Services
|
|||
Task UpdateCategory(String hash, String category);
|
||||
Task UploadMagnet(String magnetLink, String category, Boolean autoDownload, Boolean autoUnpack, Boolean autoDelete);
|
||||
Task UploadFile(Byte[] bytes, String category, Boolean autoDownload, Boolean autoUnpack, Boolean autoDelete);
|
||||
Task<List<String>> GetAvailableFiles(String hash);
|
||||
Task SelectFiles(String torrentId, IList<String> fileIds);
|
||||
Task Delete(Guid torrentId, Boolean deleteData, Boolean deleteRdTorrent, Boolean deleteLocalFiles);
|
||||
Task Unrestrict(Guid torrentId);
|
||||
|
|
@ -152,6 +153,17 @@ namespace RdtClient.Service.Services
|
|||
await Add(rdTorrent.Id, torrent.InfoHash.ToHex(), category, autoDownload, autoUnpack, autoDelete);
|
||||
}
|
||||
|
||||
public async Task<List<String>> GetAvailableFiles(String hash)
|
||||
{
|
||||
var result = await GetRdNetClient().GetAvailableFiles(hash);
|
||||
|
||||
var files = result.SelectMany(m => m.Value).SelectMany(m => m.Value).SelectMany(m => m.Values);
|
||||
|
||||
var groups = files.GroupBy(m => m.Filename);
|
||||
|
||||
return groups.Select(m => m.Key).ToList();
|
||||
}
|
||||
|
||||
public async Task SelectFiles(String torrentId, IList<String> fileIds)
|
||||
{
|
||||
await GetRdNetClient().SelectTorrentFilesAsync(torrentId, fileIds.ToArray());
|
||||
|
|
@ -246,11 +258,6 @@ namespace RdtClient.Service.Services
|
|||
|
||||
public async Task<Profile> GetProfile()
|
||||
{
|
||||
if (_rdtNetClient == null)
|
||||
{
|
||||
return new Profile();
|
||||
}
|
||||
|
||||
var user = await GetRdNetClient().GetUserAsync();
|
||||
|
||||
var profile = new Profile
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ namespace RdtClient.Web
|
|||
.Enrich.WithExceptionDetails()
|
||||
.WriteTo.File(appSettings.Logging.File.Path, logLevel, rollOnFileSizeLimit: true, fileSizeLimitBytes: appSettings.Logging.File.FileSizeLimitBytes, retainedFileCountLimit: appSettings.Logging.File.MaxRollingFiles)
|
||||
.WriteTo.Console()
|
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning)
|
||||
.MinimumLevel.Information()
|
||||
.CreateLogger();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue