Example #1
0
        private void SetWikipediaInfo(ArticleRootobject articleRootObject, Artist artist)
        {
            String pageId = articleRootObject.query.pages.Keys.First();

            if (Int32.Parse(pageId) != -1)
            {
                artist.wikipediaProfile = "https://en.wikipedia.org/?curid=" + pageId;
                if (articleRootObject.query.pages[pageId].extract.Length > 50)
                {
                    artist.wikipediaArticle = articleRootObject.query.pages[pageId].extract;
                }
            }
        }
Example #2
0
 public void GetArticleIntro(Artist artist)
 {
     // Use HTTP to Request
     using (var client = new HttpClient(new HttpClientHandler {
         AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
     })) {
         client.BaseAddress = new Uri(EXTRACT_URL);
         HttpResponseMessage response = client.GetAsync("?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=" + artist.name).Result;
         // response.EnsureSuccessStatusCode();
         string            outputString      = response.Content.ReadAsStringAsync().Result;
         ArticleRootobject articleRootObject = JsonConvert.DeserializeObject <ArticleRootobject>(outputString);
         SetWikipediaInfo(articleRootObject, artist);
     }
 }