Ejemplo n.º 1
0
        public async Task <JSON_Youtube> GetYoutubeDownloadUrls(string YoutubeVideoUrl)
        {
            using (HtpClient localHttpClient = new HtpClient(new HCHandler()))
            {
                HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new Uri(string.Format("https://www.youtube.com/get_video_info?video_id={0}&el=embedded&ps=default&eurl=&gl=US&hl=en", Utilitiez.TryParseVideoId(YoutubeVideoUrl)))).ConfigureAwait(false);

                var result = await ResPonse.Content.ReadAsStringAsync();

                if (ResPonse.IsSuccessStatusCode)
                {
                    result = WebUtility.UrlDecode(result);
                    var theTxt = string.Concat(Utilitiez.Between(result, "player_response=", "}}}&"), "}}}");
                    return(JsonConvert.DeserializeObject <JSON_Youtube>(theTxt, JSONhandler));
                }
                else
                {
                    ShowError(result);
                    return(null);
                }
            }
        }