

download() function and give the path of the directory in which we want to store the video.Īs a result, after going to the Downloads folder on your PC, you will be able to see the downloaded video. Here we have chosen the first stream format and assigned it to a variable video. Stream contains various parameters like resolution, fps, vcodec etc. Here, we first have to choose any one format for the stream.

Video.download(r'C:\Users\anish\Downloads') Now, we need to store the video in a particular directory, say Downloads. We assign this downloaded video to another variable youtube. So, as we can see, after giving the url variable as an argument to the pytube.YouTube() function, the function downloads the video from YouTube. First, create a variable url in which we will store the URL of the YouTube video we want to download. Now, we are ready to download videos from YouTube. Once you install the pytube library, import it on your IDE. You can now download YouTube videos as MP3 files with HD audio quality. You can install this library easily using the pip command. Pytube library in Python to download Youtube videosįor downloading a video from YouTube using Python, we will need a library called p ytube. In this tutorial, using Python, we will see how you can download a video from YouTube and store it in any directory of your choice.
