public static CurseMod FromJson(string json) { CurseMod mod = JsonConvert.DeserializeObject <CurseMod>(json); foreach (CurseFile file in mod.files) { file.ModPageUrl = mod.GetPageUrl(); } return(mod); }
public static CurseMod FromJson(int modId, string json) { CurseMod mod = JsonConvert.DeserializeObject <CurseMod>(json); mod.ModId = modId; foreach (CurseFile file in mod.files.Values) { file.Mod = mod; } return(mod); }
public CurseMod GetMod(string nameOrId) { var json = Call(nameOrId); // Check if the mod has been removed from Curse and if it corresponds to a KSP mod. var error = JsonConvert.DeserializeObject <CurseError>(json); if (!string.IsNullOrWhiteSpace(error.error)) { throw new Kraken(string.Format( "Could not get the mod from Curse, reason: {0}.", error.message )); } return(CurseMod.FromJson(json)); }
public CurseMod GetMod(int modId) { var json = Call(modId); // Check if the mod has been removed from Curse and if it corresponds to a KSP mod. var error = JsonConvert.DeserializeObject <CurseError>(json); if (error.code != 0) { var errorMessage = string.Format("Could not get the mod from Curse, reason: {0}.", error.message); throw new Kraken(errorMessage); } else if (!error.game.Equals("Kerbal Space Program")) { throw new Kraken("Could not get the mod from Curse, reason: Specified id is not a KSP mod"); } return(CurseMod.FromJson(modId, json)); }
public CurseMod GetMod(string nameOrId) { string json; try { json = Call(nameOrId); } catch (NativeAndCurlDownloadFailedKraken e) { // CurseForge returns a valid json with an error message in some cases. json = e.responseContent; } // Check if the mod has been removed from Curse and if it corresponds to a KSP mod. var error = JsonConvert.DeserializeObject <CurseError>(json); if (!string.IsNullOrWhiteSpace(error.error)) { throw new Kraken($"Could not get the mod from Curse, reason: {error.message}."); } return(CurseMod.FromJson(json)); }
public CurseMod GetMod(string nameOrId) { string json; try { json = Call(nameOrId); } catch (WebException e) { // CurseForge returns a valid json with an error message in some cases. json = new StreamReader(e.Response.GetResponseStream(), System.Text.Encoding.UTF8).ReadToEnd(); } // Check if the mod has been removed from Curse and if it corresponds to a KSP mod. var error = JsonConvert.DeserializeObject <CurseError>(json); if (!string.IsNullOrWhiteSpace(error.error)) { throw new Kraken($"Could not get the mod from Curse, reason: {error.message}."); } return(CurseMod.FromJson(json)); }