download youtube videos using api python

#download pytube with pip install pytube
import pytube

#made it a function so that you can call it from any script and just pass in
#the url in ""
def downloadVideo(url):
    youtube = pytube.YouTube(url)
    video = youtube.streams.get_highest_resolution()
    print(video.title)
    video.download()
    

Here is what the above code is Doing:
1. We import the pytube module
2. We create a function called downloadVideo()
3. We pass in the url of the video we want to download
4. We create a variable called youtube and pass in the url
5. We create a variable called video and pass in the highest resolution
6. We print the title of the video
7. We download the video