rdt-client/server/RdtClient.Service/Helpers/Logger.cs
Roger Far d16e7f0c88 Changed the Aria2 updates to be done in the main TorrentRunner loop instead of each downloader making their own connections.
Added checks if Aria2 links actually got added.
Improved debug messages and set Microsoft message to Warning.
Abstracted the RealDebrid client into a ITorrentClient.
Add retry mechanism for server errors from RealDebrid.
2021-10-27 14:55:46 -06:00

31 lines
923 B
C#

using System;
using System.Linq;
using System.Web;
using RdtClient.Data.Models.Data;
namespace RdtClient.Service.Helpers
{
public static class Logger
{
public static String ToLog(this Download download)
{
var fileName = download.Path;
if (!String.IsNullOrWhiteSpace(download.Link))
{
var uri = new Uri(download.Link);
fileName = uri.Segments.Last();
fileName = HttpUtility.UrlDecode(fileName);
}
var done = (Int32)((Double)download.BytesDone / download.BytesTotal) * 100;
return $"for download {fileName} {done}% ({download.DownloadId})";
}
public static String ToLog(this Torrent torrent)
{
return $"for torrent {torrent.RdName} ({torrent.RdId} - {torrent.RdStatusRaw} {torrent.RdProgress}%) ({torrent.TorrentId})";
}
}
}