async static public Task <LyricSimpleJson> FetchSimpleLyricByTrackId(string trackId)
        {
            if (String.IsNullOrWhiteSpace(trackId))
            {
                return(null);
            }

            WebClient client = new WebClient()
            {
                Encoding = Encoding.UTF8
            };
            Uri    uri       = new Uri(String.Format(SIMPLE_LYRIC_URL, trackId));
            string lyricJson = await client.DownloadStringTaskAsync(uri);

            var jsonSerializerSettings = new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            };
            LyricSimpleJson item = JsonConvert.DeserializeObject <LyricSimpleJson>(lyricJson, jsonSerializerSettings);

            return(item);
        }
示例#2
0
 async public Task FetchSimpleLyricByTrackIdTest()
 {
     LyricSimpleJson result = await WebController.FetchSimpleLyricByTrackId("409326722");
 }