58 lines
1.9 KiB
C#
58 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PoEco.Net.Web
|
|
{
|
|
internal class Stash
|
|
{
|
|
public static void DownloadStash(string token, string url, string path)
|
|
{
|
|
WebClient webClient = new WebClient();
|
|
webClient.Encoding = Encoding.UTF8;
|
|
webClient.Headers.Add(HttpRequestHeader.Cookie, "POESESSID=" + token);
|
|
webClient.Headers.Add("user-agent", $"PoEcoDB/{Program.version} (poeco@mxpoe.ovh)");
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
|
try
|
|
{
|
|
Uri address = new Uri(url);
|
|
webClient.DownloadFile(address, path);
|
|
}
|
|
catch (WebException ex)
|
|
{
|
|
Utilities.Message.CMW(ex.Message, true, 3);
|
|
Utilities.Message.CMW("URL: " + url, true, 3);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Utilities.Message.CMW(ex.Message,true,3);
|
|
}
|
|
}
|
|
|
|
public static void GetStash(string token, string url, string path)
|
|
{
|
|
WebClient webClient = new WebClient();
|
|
webClient.Encoding = Encoding.UTF8;
|
|
webClient.Headers.Add("Authorization", "Bearer " + token);
|
|
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
|
try
|
|
{
|
|
Uri address = new Uri(url);
|
|
webClient.DownloadFile(address, path);
|
|
}
|
|
catch (WebException ex)
|
|
{
|
|
Utilities.Message.CMW(ex.Message, true, 3);
|
|
Utilities.Message.CMW("URL: " + url, true, 3);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Utilities.Message.CMW(ex.Message, true, 3);
|
|
}
|
|
}
|
|
}
|
|
}
|