[DL] GetDownloadLinks -> GetDownloadInfos
This commit is contained in:
parent
88af15b3bc
commit
2b2c5462f1
1 changed files with 18 additions and 26 deletions
|
|
@ -1,12 +1,13 @@
|
||||||
using Microsoft.Extensions.Logging;
|
using System.Diagnostics;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using DebridLinkFrNET;
|
using DebridLinkFrNET;
|
||||||
using RdtClient.Data.Enums;
|
using RdtClient.Data.Enums;
|
||||||
using RdtClient.Data.Models.TorrentClient;
|
using RdtClient.Data.Models.TorrentClient;
|
||||||
using RdtClient.Service.Helpers;
|
using RdtClient.Service.Helpers;
|
||||||
using DebridLinkFrNET.Models;
|
using RdtClient.Data.Models.Data;
|
||||||
using System.Web;
|
|
||||||
using Download = RdtClient.Data.Models.Data.Download;
|
using Download = RdtClient.Data.Models.Data.Download;
|
||||||
|
using Torrent = DebridLinkFrNET.Models.Torrent;
|
||||||
|
|
||||||
namespace RdtClient.Service.Services.TorrentClients;
|
namespace RdtClient.Service.Services.TorrentClients;
|
||||||
|
|
||||||
|
|
@ -234,7 +235,7 @@ public class DebridLinkClient(ILogger<DebridLinkClient> logger, IHttpClientFacto
|
||||||
return torrent;
|
return torrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IList<String>?> GetDownloadLinks(Data.Models.Data.Torrent torrent)
|
public async Task<IList<DownloadInfo>?> GetDownloadInfos(Data.Models.Data.Torrent torrent)
|
||||||
{
|
{
|
||||||
if (torrent.RdId == null)
|
if (torrent.RdId == null)
|
||||||
{
|
{
|
||||||
|
|
@ -248,19 +249,14 @@ public class DebridLinkClient(ILogger<DebridLinkClient> logger, IHttpClientFacto
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var downloadLinks = rdTorrent.Files?
|
return rdTorrent.Files?
|
||||||
.Where(m => fileFilter.IsDownloadable(torrent, m.Path, m.Bytes) && m.DownloadLink != null)
|
.Where(m => fileFilter.IsDownloadable(torrent, m.Path, m.Bytes) && m.DownloadLink != null)
|
||||||
.Select(m => m.DownloadLink!)
|
.Select(m => new DownloadInfo
|
||||||
.ToList() ?? [];
|
{
|
||||||
|
RestrictedLink = m.DownloadLink!,
|
||||||
Log($"Found {downloadLinks.Count} links", torrent);
|
FileName = Path.GetFileName(m.Path)
|
||||||
|
})
|
||||||
foreach (var link in downloadLinks)
|
.ToList();
|
||||||
{
|
|
||||||
Log($"{link}", torrent);
|
|
||||||
}
|
|
||||||
|
|
||||||
return downloadLinks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<TorrentClientTorrent> GetInfo(String torrentId)
|
private async Task<TorrentClientTorrent> GetInfo(String torrentId)
|
||||||
|
|
@ -280,16 +276,12 @@ public class DebridLinkClient(ILogger<DebridLinkClient> logger, IHttpClientFacto
|
||||||
logger.LogDebug(message);
|
logger.LogDebug(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<String> GetFileName(String downloadUrl)
|
public Task<String> GetFileName(Download download)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(downloadUrl))
|
// FileName is set in GetDownlaadInfos
|
||||||
{
|
Debug.Assert(download.FileName != null);
|
||||||
return Task.FromResult("");
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = new Uri(downloadUrl);
|
return Task.FromResult(download.FileName);
|
||||||
|
|
||||||
return Task.FromResult(HttpUtility.UrlDecode(uri.Segments.Last()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String? GetSymlinkPath(Data.Models.Data.Torrent torrent, Download download)
|
public static String? GetSymlinkPath(Data.Models.Data.Torrent torrent, Download download)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue