private string getUrlString(TorrentInfo torrentInfo, string eventType)
{
// Random random = new Random();
string uploaded = "0";
if (torrentInfo.uploaded > 0)
{
torrentInfo.uploaded = RoundByDenominator(torrentInfo.uploaded, 0x4000);
uploaded = torrentInfo.uploaded.ToString();
// uploaded = Convert.ToString(torrentInfo.uploaded + random.Next(1, 1023));
}
string downloaded = "0";
if (torrentInfo.downloaded > 0)
{
torrentInfo.downloaded = RoundByDenominator(torrentInfo.downloaded, 0x10);
downloaded = torrentInfo.downloaded.ToString();
// downloaded = Convert.ToString(torrentInfo.downloaded + random.Next(1, 1023));
}
if (torrentInfo.left > 0)
{
torrentInfo.left = torrentInfo.totalsize - torrentInfo.downloaded;
}
string left = torrentInfo.left.ToString();
string key = torrentInfo.key;
string port = torrentInfo.port;
string peerID = torrentInfo.peerID;
string urlString;
urlString = torrentInfo.tracker;
if (urlString.Contains("?"))
{
urlString += "&";
}
else
{
urlString += "?";
}
if (eventType.Contains("started")) urlString = urlString.Replace("&natmapped=1&localip={localip}", "");
if (!eventType.Contains("stopped")) urlString = urlString.Replace("&trackerid=48", "");
urlString += currentClient.Query;
urlString = urlString.Replace("{infohash}", HashUrlEncode(torrentInfo.hash, currentClient.HashUpperCase));
urlString = urlString.Replace("{peerid}", peerID);
urlString = urlString.Replace("{port}", port);
urlString = urlString.Replace("{uploaded}", uploaded);
urlString = urlString.Replace("{downloaded}", downloaded);
urlString = urlString.Replace("{left}", left);
urlString = urlString.Replace("{event}", eventType);
if ((torrentInfo.numberOfPeers == "0") && !eventType.ToLower().Contains("stopped")) torrentInfo.numberOfPeers = "200";
urlString = urlString.Replace("{numwant}", torrentInfo.numberOfPeers);
urlString = urlString.Replace("{key}", key);
urlString = urlString.Replace("{localip}", Functions.GetIp());
return urlString;
}