/// <summary> /// Find version that match requirements /// </summary> /// <param name="stable">do version have to be stable</param> /// <returns></returns> internal ComponentVersion WebUIGetLatestVersion(bool stable) { var client = new System.Net.WebClient(); client.Headers.Add("Accept: application/vnd.github.v3+json"); client.Headers.Add("User-Agent", "jmmserver"); var response = client.DownloadString(new Uri("https://api.github.com/repos/japanesemediamanager/shokoserver-webui/releases/latest")); dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject(response); ComponentVersion version = new ComponentVersion(); if (result.prerelease == "False") { //not pre-build if (stable) { version.version = result.tag_name; } else { version.version = WebUIGetVersionsTag(false); } } else { //pre-build if (stable) { version.version = WebUIGetVersionsTag(true); } else { version.version = result.tag_name; } } return version; }
/// <summary> /// Check for newest unstable version and return object { version: string, url: string } /// </summary> /// <returns></returns> private ComponentVersion WebUILatestUnstableVersion() { ComponentVersion version = new ComponentVersion(); version = WebUIGetLatestVersion(false); return version; }
/// <summary> /// Check for newest stable version and return object { version: string, url: string } /// </summary> /// <returns></returns> private ComponentVersion WebUILatestStableVersion() { ComponentVersion version = new ComponentVersion(); version = WebUIGetLatestVersion(true); return version; }