pip install pytube
Create a new file named playlist_downloader.py and paste the following code:
Here is a complete, production-ready script. It handles the fetching of the playlist, filters for the highest resolution available, and downloads the videos sequentially.
download_playlist("YOUR_PLAYLIST_URL_HERE")