from pytube import YouTube SAVE_DIRECTORY = "./videos" def Download(video, fname): video = video.streams.get_highest_resolution() try: video.download(SAVE_DIRECTORY, filename=fname) print("Download is completed successfully") except: print("A video error has occurred")