[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:
Sam Heinz 2024-12-11 00:03:43 +10:00
parent 9d03c20aaa
commit ac6300a504
6 changed files with 13 additions and 13 deletions

View file

@ -263,16 +263,16 @@ public class AllDebridTorrentClient(ILogger<AllDebridTorrentClient> logger, IHtt
return links.Select(m => m.LinkUrl.ToString()).ToList();
}
public Task<String?> GetFileName(String downloadUrl)
public Task<String> GetFileName(String downloadUrl)
{
if (String.IsNullOrWhiteSpace(downloadUrl))
{
return Task.FromResult<String?>(null);
return Task.FromResult("");
}
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)

View file

@ -15,5 +15,5 @@ public interface ITorrentClient
Task<String> Unrestrict(String link);
Task<Torrent> UpdateData(Torrent torrent, TorrentClientTorrent? torrentClientTorrent);
Task<IList<String>?> GetDownloadLinks(Torrent torrent);
Task<String?> GetFileName(String downloadUrl);
Task<String> GetFileName(String downloadUrl);
}

View file

@ -242,16 +242,16 @@ public class PremiumizeTorrentClient(ILogger<PremiumizeTorrentClient> logger, IH
return downloadLinks;
}
public Task<String?> GetFileName(String downloadUrl)
public Task<String> GetFileName(String downloadUrl)
{
if (String.IsNullOrWhiteSpace(downloadUrl))
{
return Task.FromResult<String?>(null);
return Task.FromResult("");
}
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)

View file

@ -396,16 +396,16 @@ public class RealDebridTorrentClient(ILogger<RealDebridTorrentClient> logger, IH
return null;
}
public Task<String?> GetFileName(String downloadUrl)
public Task<String> GetFileName(String downloadUrl)
{
if (String.IsNullOrWhiteSpace(downloadUrl))
{
return Task.FromResult<String?>(null);
return Task.FromResult("");
}
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)

View file

@ -302,11 +302,11 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
return files;
}
public async Task<String?> GetFileName(String downloadUrl)
public async Task<String> GetFileName(String downloadUrl)
{
if (String.IsNullOrWhiteSpace(downloadUrl))
{
return null;
return "";
}
var uri = new Uri(downloadUrl);

View file

@ -374,7 +374,7 @@ public class Torrents(
{
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!);