/// <summary> /// Fetch a Json API query from the given URL. /// </summary> /// <returns>A JsonValue of the query result if successful, otherwise null.</returns> public static JsonValue?FetchJsonApiQuery(string apiQuery) { string query = WebClientManager.DownloadString(apiQuery); if (!string.IsNullOrEmpty(query)) { return(JsonReader.Parse(query)); } return(null); }
/// <summary> /// Attempt to update BepInEx to the latest version. /// </summary> public static void UpdateBepInEx() { if (!Folders.IsCurrentOutwardPathValid()) { Console.WriteLine("Current Outward folder path not set or invalid! Cannot update BepInEx."); return; } // If an update check hasn't been done this launch, do one now. if (IsBepInExUpdated()) { return; } // If the check we just did failed (no query result), we need to abort. if (string.IsNullOrEmpty(s_latestBepInExVersion)) { return; } try { string releaseURL = $@"https://github.com/BepInEx/BepInEx/releases/latest/download/BepInEx_x64_{s_latestBepInExVersion}.zip"; var tempFile = TemporaryFile.CreateFile(); MefinoGUI.SetProgressMessage($"Downloading BepInEx {s_latestBepInExVersion}"); WebClientManager.DownloadFileAsync(releaseURL, tempFile); while (WebClientManager.IsBusy) { MefinoApp.SendAsyncProgress(WebClientManager.LastDownloadProgress); } MefinoGUI.SetProgressMessage($"Extracting BepInEx {s_latestBepInExVersion}"); ZipHelper.ExtractZip(tempFile, Folders.OUTWARD_FOLDER); Console.WriteLine("Updated BepInEx to version '" + s_latestBepInExVersion + "'"); } catch (Exception ex) { Console.WriteLine("Exception downloading and installing BepInEx!"); Console.WriteLine(ex); } }
/// <summary> /// Search GitHub for Mefino packages. Returns the search result as a JsonValue. /// </summary> public static JsonValue?QueryForMefinoPackages() { try { string query = WebClientManager.DownloadString(WebManifestManager.GITHUB_PACKAGE_QUERY_URL); if (!string.IsNullOrEmpty(query)) { return(JsonReader.Parse(query)); } return(null); } catch { Console.WriteLine("Exception getting Mefino packages from github!"); return(null); } }