private void uploadFiles_do(object sender, DoWorkEventArgs e) { uploadError = false; updateStatus("Ready to upload " + osuUploadTickets.Count + " files."); for (int i = 0; i < osuUploadTickets.Count; i++) { UploadTicket sp = osuUploadTickets[i]; updateStatus(String.Format("Uploading {0}...", Path.GetFileName(sp.Filename))); string url = string.Format("http://peppy.chigau.com/upload.php?u={0}&p={1}&c={2}&of={3}&oc={4}&r={5}", ConfigManager.sUsername, ConfigManager.sPassword, sp.Ticket, GeneralHelper.UrlEncode(oszFilename), oszTicket, (i == 0 ? 1 : 0)); FileStream f = File.OpenRead(sp.Filename); byte[] file = new byte[f.Length]; f.Read(file, 0, (int)f.Length); f.Close(); try { fileUpload = new FileUploadNetRequest(url, file, Path.GetFileName(sp.Filename), "osu"); fileUpload.onUpdate += up_onUpdate; string error = fileUpload.BlockingPerform(); Console.WriteLine(error); fileUpload.onUpdate -= up_onUpdate; } catch (Exception) { uploadError = true; } progress = (int)((float)(i + 1) / osuUploadTickets.Count * 100); } if (oszFilename != null) { File.Delete(oszFilename); } if (hasVideo) { updateStatus("Creating no-video file..."); string url = string.Format("http://peppy.chigau.com/novideo.php?file={0}", GeneralHelper.UrlEncode(oszFilename)); DataNetRequest r = new DataNetRequest(url); r.onFinish += r_onFinish; NetManager.AddRequest(r); while (!noVideoFinished) { Thread.Sleep(100); } } }
private void doSendScore(object sender, DoWorkEventArgs e) { GameBase.User.spriteInfo.Text = "Submitting score..."; try { byte[] zipped = new byte[0]; if (pass) { rawReplayCompressed = SevenZipHelper.Compress(new ASCIIEncoding().GetBytes(replayFormatted)); zipped = rawReplayCompressed; /*MemoryStream s = new MemoryStream(); * DeflaterOutputStream ds = new DeflaterOutputStream(s, new Deflater(9)); * * ds.Write(bytes, 0, bytes.Length); * ds.Finish(); * ds.Flush(); * zipped = s.ToArray();*/ } FileUploadNetRequest fileUpload = new FileUploadNetRequest( string.Format("http://osu.ppy.sh/web/osu-submit.php?score={0}&pass={1}", onlineFormatted, ConfigManager.sPassword), zipped, "replay", "score"); int retryCount = 1; while (retryCount > 0) { try { string[] response = fileUpload.BlockingPerform().Split('\n'); if (response.Length > 0) { Int32.TryParse(response[0], out onlineRank); Int32.TryParse(response[1], out GameBase.User.NextRank); } if (response.Length > 2) { GameBase.User.AchievementImages = response[2].Split(' '); } else { GameBase.User.AchievementImages = null; } break; } catch { } retryCount--; } } catch (Exception ex) { Console.WriteLine(ex); } if (SubmissionComplete != null) { SubmissionComplete(this); } if (!pass) { GameBase.User.Refresh(); } else { BeatmapManager.GetOnlineBeatmapInfo(BeatmapManager.Current); } }
private void initialSubmission_do(object sender, DoWorkEventArgs e) { bool first = true; for (int j = 0; j < beatmaps.Count; j++) { Beatmap b = beatmaps[j]; int action = 0; if (beatmaps.Count == 1) { action = 3; } else if (j == beatmaps.Count - 1) { action = 2; } else if (j == 0) { action = 1; } string url = string.Format(Urls.SUBMIT_GET_ID, ConfigManager.sUsername, ConfigManager.sPassword, action, BeatmapManager.Current.BeatmapSetId, hasVideo ? 1 : 0); FileStream f = File.OpenRead(b.Filename); byte[] file = new byte[f.Length]; f.Read(file, 0, (int)f.Length); f.Close(); fileUpload = new FileUploadNetRequest(url, file, Path.GetFileName(b.Filename), "osu"); fileUpload.onUpdate += up_onUpdate; string ret = fileUpload.BlockingPerform(); fileUpload.onUpdate -= up_onUpdate; string[] lines = ret.Split('\n'); if (lines[0] == "ranked") { error = "This beatmap is already ranked. Updates to ranked maps are not supported currently!"; return; } if (lines[0] == "graveyarded") { error = "This beatmap is currently in the beatmap graveyard. Before updating the map, you should first reply in the thread requesting it be resurrected by a mod!"; return; } if (lines.Length < 2) { error = "An error occurred:\n" + ret; return; } beatmapSetId = Int32.Parse(lines[1]); oszTicket = lines[2]; osuUploadTickets.Add(new UploadTicket(b.Filename, lines[3])); oszFilename = lines[4]; if (lines[0] == "old") { isNewSubmission = false; threadId = Int32.Parse(lines[5]); approved = Int32.Parse(lines[6]); oldSubject = lines[7]; oldMessage = ""; for (int i = 8; i < lines.Length; i++) { if (lines[i].Contains("Filesize")) { filesize = Int32.Parse( lines[i].Remove(0, lines[i].LastIndexOf(' ')).Replace(",", "").Replace("kb", "")); } oldMessage += lines[i] + "\r\n"; } } first = false; } if (isNewSubmission || radioFull.Checked) { osuUploadTickets.Clear(); ZipConstants.DefaultCodePage = 932; FastZip fz = new FastZip(); fz.CreateZip(oszFilename, BeatmapManager.Current.ContainingFolder, true, "[^z]+$"); filesize = new FileInfo(oszFilename).Length / 1024; osuUploadTickets.Insert(0, new UploadTicket(oszFilename, oszTicket)); } }