I am trying to download you tube video using c# code but i am not getting proper code. I have searched many link but din't get any proper links and code.
I want to download the you tube video in my local folder with c# code. I have tried one link but that code just getting null video in my local folder so any one have the idea how can do that.
Below is the code i have tried so far.
var VedioUrl = "https://www.youtube.com/embed/" + objYouTube.VideoID + ".mp4";
WebRequest MyRequest = HttpWebRequest.Create(VedioUrl);
WebResponse MyResponse = MyRequest.GetResponse();
string RealURL = MyResponse.ResponseUri.ToString();
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(RealURL);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader(receiveStream, encode);
StreamWriter writer = new StreamWriter(Server.MapPath("~/youtube/" + objYouTube.VideoID + ".mp4"), true);
writer.Write(readStream.ReadToEnd());
writer.Close();
so here is my video url which i am trying to download : "https://www.youtube.com/embed/UCsiNPbLbwZk43FOCRrdKBlA.mp4"