private static async Task <string> FetchArt(int id) { string response; using (var dpb = new Derpibooru()) response = await dpb.Request($"{id}.json"); var data = JObject.Parse(response); var url = "https:" + data["image"]; return(url); }
private static async Task <int> Random(string query) { string response; using (var dpb = new Derpibooru()) response = await dpb.Request($"{SearchPath}.json?q={query}&random_image=y"); var data = JObject.Parse(response); if (!data.HasValues) { throw new ArgumentException($"'{query}' に該当するエントリーは見つかりませんでした。"); } var id = int.Parse(data["id"].ToString()); return(id); }