/// <summary> /// Downloads the mod from ModURL. /// </summary> /// <param name="importInfo">The ImportInfo of the mod to download.</param> /// <returns>True if download was successful, otherwise false.</returns> private static bool DownloadMod(ref ImportInfo importInfo) { ISiteHandler siteHandler = importInfo.SiteHandler; if (siteHandler != null) { ModInfo modInfo = siteHandler.GetModInfo(importInfo.ModURL); importInfo.DownloadSuccessfull = siteHandler.DownloadMod(ref modInfo); importInfo.ModInfo = modInfo; } return(importInfo.DownloadSuccessfull); }
private void btnGotoSpaceport_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ModURL)) { MessageBox.Show(this, Messages.MSG_ENTER_VALID_URL_FIRST); } else { try { ISiteHandler siteHandler = SiteHandlerManager.GetSiteHandlerByURL(ModURL); ////ByName(cbVersionControl.SelectedItem as string); if (siteHandler == null) { // set selected sitehandler to none. cbVersionControl.SelectedItem = cbVersionControl.Items[0]; string msg = string.Format(Messages.MSG_NO_SITEHANDLER_FOUND_FOR_URL_0, ModURL); MessageBox.Show(this, msg, Messages.MSG_TITLE_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ModInfo newModInfo = null; if (siteHandler.IsValidURL(ModURL)) { newModInfo = siteHandler.GetModInfo(ModURL); } if (newModInfo != null) { newModInfo.AdditionalURL = ModInfo.AdditionalURL; ModInfo = newModInfo; } } catch (Exception ex) { string msg = string.Format(Messages.MSG_ERROR_DURING_MODINFO_UPDATE, ModURL, Environment.NewLine, ex.Message); MessageBox.Show(this, msg, Messages.MSG_TITLE_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); Log.AddErrorS(msg, ex); } } }
/// <summary> /// Gets the content of the site of the passed URL and parses it for ModInfos. /// </summary> /// <param name="url">The URL of the site to parse the ModInfos from.</param> /// <returns>The ModInfos parsed from the site of the passed URL.</returns> public ModInfo GetModInfo(string url) { ISiteHandler curseForge = SiteHandlerManager.GetSiteHandlerByName("CurseForge"); return(curseForge.GetModInfo(GetDownloadURL(url))); }