[TB] Replace null with empty string for filenames in TorrentClient
Not sure if its better to do this or allow null value to db, but i had this originally and it worked so i think im better off leaving it for now, but idk. Also got fix for incorrect log
This commit is contained in:
parent
9d03c20aaa
commit
ac6300a504
6 changed files with 13 additions and 13 deletions
|
|
@ -263,16 +263,16 @@ public class AllDebridTorrentClient(ILogger<AllDebridTorrentClient> logger, IHtt
|
||||||
|
|
||||||
return links.Select(m => m.LinkUrl.ToString()).ToList();
|
return links.Select(m => m.LinkUrl.ToString()).ToList();
|
||||||
}
|
}
|
||||||
public Task<String?> GetFileName(String downloadUrl)
|
public Task<String> GetFileName(String downloadUrl)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(downloadUrl))
|
if (String.IsNullOrWhiteSpace(downloadUrl))
|
||||||
{
|
{
|
||||||
return Task.FromResult<String?>(null);
|
return Task.FromResult("");
|
||||||
}
|
}
|
||||||
|
|
||||||
var uri = new Uri(downloadUrl);
|
var uri = new Uri(downloadUrl);
|
||||||
|
|
||||||
return Task.FromResult<String?>(HttpUtility.UrlDecode(uri.Segments.Last()));
|
return Task.FromResult(HttpUtility.UrlDecode(uri.Segments.Last()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<TorrentClientTorrent> GetInfo(String torrentId)
|
private async Task<TorrentClientTorrent> GetInfo(String torrentId)
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,5 @@ public interface ITorrentClient
|
||||||
Task<String> Unrestrict(String link);
|
Task<String> Unrestrict(String link);
|
||||||
Task<Torrent> UpdateData(Torrent torrent, TorrentClientTorrent? torrentClientTorrent);
|
Task<Torrent> UpdateData(Torrent torrent, TorrentClientTorrent? torrentClientTorrent);
|
||||||
Task<IList<String>?> GetDownloadLinks(Torrent torrent);
|
Task<IList<String>?> GetDownloadLinks(Torrent torrent);
|
||||||
Task<String?> GetFileName(String downloadUrl);
|
Task<String> GetFileName(String downloadUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -242,16 +242,16 @@ public class PremiumizeTorrentClient(ILogger<PremiumizeTorrentClient> logger, IH
|
||||||
return downloadLinks;
|
return downloadLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<String?> GetFileName(String downloadUrl)
|
public Task<String> GetFileName(String downloadUrl)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(downloadUrl))
|
if (String.IsNullOrWhiteSpace(downloadUrl))
|
||||||
{
|
{
|
||||||
return Task.FromResult<String?>(null);
|
return Task.FromResult("");
|
||||||
}
|
}
|
||||||
|
|
||||||
var uri = new Uri(downloadUrl);
|
var uri = new Uri(downloadUrl);
|
||||||
|
|
||||||
return Task.FromResult<String?>(HttpUtility.UrlDecode(uri.Segments.Last()));
|
return Task.FromResult(HttpUtility.UrlDecode(uri.Segments.Last()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<TorrentClientTorrent> GetInfo(String id)
|
private async Task<TorrentClientTorrent> GetInfo(String id)
|
||||||
|
|
|
||||||
|
|
@ -396,16 +396,16 @@ public class RealDebridTorrentClient(ILogger<RealDebridTorrentClient> logger, IH
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<String?> GetFileName(String downloadUrl)
|
public Task<String> GetFileName(String downloadUrl)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(downloadUrl))
|
if (String.IsNullOrWhiteSpace(downloadUrl))
|
||||||
{
|
{
|
||||||
return Task.FromResult<String?>(null);
|
return Task.FromResult("");
|
||||||
}
|
}
|
||||||
|
|
||||||
var uri = new Uri(downloadUrl);
|
var uri = new Uri(downloadUrl);
|
||||||
|
|
||||||
return Task.FromResult<String?>(HttpUtility.UrlDecode(uri.Segments.Last()));
|
return Task.FromResult(HttpUtility.UrlDecode(uri.Segments.Last()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTimeOffset? ChangeTimeZone(DateTimeOffset? dateTimeOffset)
|
private DateTimeOffset? ChangeTimeZone(DateTimeOffset? dateTimeOffset)
|
||||||
|
|
|
||||||
|
|
@ -302,11 +302,11 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<String?> GetFileName(String downloadUrl)
|
public async Task<String> GetFileName(String downloadUrl)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(downloadUrl))
|
if (String.IsNullOrWhiteSpace(downloadUrl))
|
||||||
{
|
{
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
var uri = new Uri(downloadUrl);
|
var uri = new Uri(downloadUrl);
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,7 @@ public class Torrents(
|
||||||
{
|
{
|
||||||
var download = await downloads.GetById(downloadId) ?? throw new($"Download with ID {downloadId} not found");
|
var download = await downloads.GetById(downloadId) ?? throw new($"Download with ID {downloadId} not found");
|
||||||
|
|
||||||
Log($"Unrestricting link", download, download.Torrent);
|
Log($"Retrieving filename for", download, download.Torrent);
|
||||||
|
|
||||||
var fileName = await TorrentClient.GetFileName(download.Link!);
|
var fileName = await TorrentClient.GetFileName(download.Link!);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue