fixed asset downloading (again)

This commit is contained in:
Bitl 2022-03-11 10:50:49 -07:00
parent c7463f1bda
commit 69627b19ad
2 changed files with 21 additions and 6 deletions

View File

@ -14,6 +14,7 @@ class Downloader
public readonly string fileName;
public readonly string fileFilter;
public readonly string filePath;
public static bool showErrorInfo;
private string downloadOutcome;
private static string downloadOutcomeException;
@ -54,8 +55,10 @@ class Downloader
InitDownload(path, fileext, additionalText);
}
public void InitDownload(string path, string fileext, string additionalText, bool removeSpaces = false)
public void InitDownload(string path, string fileext, string additionalText, bool removeSpaces = false, bool extraErrorInfo = true)
{
showErrorInfo = extraErrorInfo;
string outputfilename = "";
if (removeSpaces == true)
@ -124,6 +127,11 @@ class Downloader
{
downloadOutcome = "Error: Download of file " + Path.GetFileName(name) + " failed. The file wasn't downloaded to the assigned directory.";
}
if (showErrorInfo)
{
downloadOutcome += "\n\nMore error info:\n\nFile URL: " + fileURL + "\n\nFile Path: " + name;
}
}
}
}
@ -209,7 +217,7 @@ class Downloader
HttpWebResponse errorResponse = ex.Response as HttpWebResponse;
if (errorResponse.StatusCode == HttpStatusCode.Conflict)
{
downloadOutcomeException = "Error: Unable to download item. Is it publically available?";
downloadOutcomeException = "Error: Unable to download item. The item may not be publically available.";
}
else
{

View File

@ -144,7 +144,7 @@ public static class RobloxXML
try
{
download.InitDownload(path, fileext, "", true);
download.InitDownload(path, fileext, "", true, false);
if (download.getDownloadOutcome().Contains("Error"))
{
throw new IOException(download.getDownloadOutcome());
@ -158,7 +158,7 @@ public static class RobloxXML
catch (Exception)
{
#endif
MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset SDK - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("The download has experienced an error: " + ex.Message + "\n\nMore error info:\n\nFile URL: " + url + "\n\nFile Path: " + path + "\\" + (id + fileext).Replace(" ", ""), "Novetus Asset SDK - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
@ -187,7 +187,7 @@ public static class RobloxXML
public static string FixURLString(string str, string str2)
{
string fixedStr = str.Replace("?version=1&id=", "?id=")
string fixedStr = str.ToLower().Replace("?version=1&id=", "?id=")
.Replace("?version=1&id=", "?id=")
.Replace("&", "&")
.Replace("amp;", "&");
@ -199,9 +199,16 @@ public static class RobloxXML
baseurl = fixedStr.Before("/asset?id=");
}
string finalUrl = fixedStr.Replace(baseurl + "/asset/?id=", str2)
string fixedUrl = fixedStr.Replace(baseurl + "/asset/?id=", str2)
.Replace(baseurl + "/asset?id=", str2);
//...because scripts mess it up.
string id = fixedUrl.After("id=");
string fixedID = Regex.Replace(id, "[^0-9]", "");
//really fucking hacky.
string finalUrl = fixedUrl.Before("id=") + "id=" + fixedID;
return finalUrl;
}