Todays script will download YouTube content as MP3 format files. We will be using pytube which is a lightweight, Pythonic, dependency-free, library for downloading YouTube Videos. The library is very easy to use and quite intuitive.
We start by taking input which will be the URL of the YouTube video we are interested in, using this URL we then create a YouTube object. Next, we select the stream we are wanting (more information on this can be found here) before downloading the video itself.
from pytube import YouTube while 1 == 1: URL = input("Please enter YouTube URL: ") yt = YouTube(URL) stream = yt.streams.get_by_itag(251) stream.download()