Enabled direct downloads to mitigate server load.

This commit is contained in:
Assistant 2020-01-05 11:04:52 -04:00
parent e3246856f1
commit 2da74c454b

View file

@ -28,6 +28,7 @@ namespace ModAssistant
private static readonly string[] Protocols = new[] { "modelsaber", "beatsaver" };
private const bool BypassDownloadCounter = true;
public static void InstallAsset(string link)
{
Uri uri = new Uri(link);
@ -81,8 +82,17 @@ namespace ModAssistant
)
);
if (BypassDownloadCounter)
{
DownloadAsset(BeatSaverURLPrefix + Response.directDownload, CustomSongsFolder, Response.hash + ".zip");
}
else
{
DownloadAsset(BeatSaverURLPrefix + Response.downloadURL, CustomSongsFolder, Response.hash + ".zip");
}
if (File.Exists(zip))
{
using (FileStream stream = new FileStream(zip, FileMode.Open))
{
using (ZipArchive archive = new ZipArchive(stream))
@ -101,6 +111,11 @@ namespace ModAssistant
File.Delete(zip);
}
else
{
MessageBox.Show("Could not download the song.\nThere might be issues with BeatSaver or your internet connection.", "Failed to download song ZIP");
}
}
private static void ModelSaber(Uri uri)
{
@ -239,6 +254,7 @@ namespace ModAssistant
public Uploader uploader { get; set; }
public DateTime uploaded { get; set; }
public string hash { get; set; }
public string directDownload { get; set; }
public string downloadURL { get; set; }
public string coverURL { get; set; }