Make uploader log-friendly
This commit is contained in:
parent
eaf7c19138
commit
972fb40395
50
Uploader.cs
50
Uploader.cs
|
@ -25,12 +25,14 @@ class SpookedUploader
|
|||
int offset = 0;
|
||||
const int chunkSize = 512000;
|
||||
|
||||
var expectedChunks = Math.Ceiling((double)byteArray.Length / chunkSize);
|
||||
|
||||
while (byteArray.Length > offset * chunkSize)
|
||||
{
|
||||
byte[] buffer = byteArray.Skip(offset * chunkSize).Take(chunkSize).ToArray();
|
||||
offset += 1;
|
||||
|
||||
ws.Send($"Bytes: {buffer.Length}");
|
||||
Plugin.Logger.LogInfo($"(UPLOAD {uuid}) - {offset}/{expectedChunks} (~{Math.Ceiling((double)buffer.Length / 1000)} KB)");
|
||||
|
||||
List<byte> msgList = new List<byte>();
|
||||
|
||||
|
@ -52,22 +54,6 @@ class SpookedUploader
|
|||
return;
|
||||
}
|
||||
|
||||
// Get co-conspirators lmao
|
||||
// string[] coconspirators = new string[PhotonNetwork.CurrentRoom.PlayerCount];
|
||||
|
||||
// foreach (KeyValuePair<int, Photon.Realtime.Player> player in PhotonNetwork.CurrentRoom.Players)
|
||||
// {
|
||||
// // if (player.Value.IsMasterClient) continue;
|
||||
// coconspirators.AddItem(player.Value.NickName);
|
||||
|
||||
// // if (player.Value.CustomProperties.ContainsKey("SteamID"))
|
||||
// // {
|
||||
// // player.Value.CustomProperties["SteamID"]
|
||||
// // }
|
||||
// }
|
||||
|
||||
// string[] coconspirators = PhotonNetwork.CurrentRoom.Players.Select((player) => player.Value.NickName) as string[];
|
||||
|
||||
ws = new WebSocket(Plugin.URL.Value);
|
||||
|
||||
string viewableUrl = "";
|
||||
|
@ -75,29 +61,39 @@ class SpookedUploader
|
|||
|
||||
ws.OnMessage += (sender, evt) =>
|
||||
{
|
||||
ws.Send(evt.Data);
|
||||
// Plugin.Logger.LogInfo("WS MESSAGE: " + evt.Data);
|
||||
|
||||
Plugin.Logger.LogInfo("WS MESSAGE: " + evt.Data);
|
||||
if (evt.Data.StartsWith("url:")) // Set viewable URL for browser open
|
||||
{
|
||||
viewableUrl = evt.Data.Substring(4);
|
||||
|
||||
if (evt.Data.StartsWith("url:")) viewableUrl = evt.Data.Substring(4);
|
||||
if (evt.Data.StartsWith("uuid:"))
|
||||
Plugin.Logger.LogInfo($"Server reports origin as {viewableUrl}.");
|
||||
}
|
||||
|
||||
if (evt.Data.StartsWith("uuid:")) // Set UUID
|
||||
{
|
||||
uuid = evt.Data.Substring(5);
|
||||
|
||||
Plugin.Logger.LogInfo($"Your video has been assigned the UUID {uuid}. Beginning upload...");
|
||||
|
||||
// Start upload thread
|
||||
new Thread(new ThreadStart(() => UploadThread(evt, ws, path, uuid))).Start();
|
||||
}
|
||||
|
||||
if (evt.Data.StartsWith("fin"))
|
||||
if (evt.Data.StartsWith("fin")) // On upload complete
|
||||
{
|
||||
ws.Close();
|
||||
// Plugin.ModalProxy("Upload Complete", $"Video uploaded to {viewableUrl}! ({uuid})");
|
||||
// System.Diagnostics.Process.Start($"{viewableUrl}/#{uuid}");
|
||||
|
||||
Plugin.Logger.LogInfo($"Upload Complete. Redirecting to {viewableUrl}...");
|
||||
|
||||
Application.OpenURL($"{viewableUrl}/#{uuid}");
|
||||
|
||||
onUpload();
|
||||
}
|
||||
|
||||
if (evt.Data.StartsWith("us"))
|
||||
if (evt.Data.StartsWith("us")) // On heuristics error
|
||||
{
|
||||
Plugin.Logger.LogError("SpookTubeEX has experienced a heuristics error. Please contact ModMail at https://discord.gg/Gw2f86B2vC with this UUID in your ticket request: " + uuid + "\nThis is an automated service, so trolling will get your IP blocked from accessing anything with SpookTubeEX and your Discord account banned from the server. DO NOT SHARE THIS UUID WITH ANYONE!");
|
||||
Plugin.Logger.LogError($"SpookTubeEX has experienced a heuristics error. Please contact ModMail at https://discord.gg/Gw2f86B2vC with this UUID in your ticket request: {uuid}\nThis is an automated service, so trolling will get your IP blocked from accessing anything with SpookTubeEX and your Discord account banned from the server. DO NOT SHARE THIS UUID WITH ANYONE!");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -112,6 +108,8 @@ class SpookedUploader
|
|||
ws.Send(SteamUser.GetSteamID().m_SteamID.ToString());
|
||||
};
|
||||
|
||||
Plugin.Logger.LogInfo($"Connecting to {ws.Url}...");
|
||||
|
||||
ws.Connect();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user