This Python script downloads videos from a YouTube playlist in 1080p or the highest available resolution below 1080p, and zips them into a single file. It uses the pytube library to download videos and the python-dotenv library to load environment variables from a .env file.
-
Clone the repository:
git clone https://github.com/prathamsoni11/Youtube-Playlist-Downloader.git
-
Navigate to the project directory:
cd Youtube-Playlist-Downloader -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install the required dependencies:
pip install pytube python-dotenv
-
Create a
.envfile in the project directory and add your playlist URL and desired zip file name:PLAYLIST_URL=YOUR_PLAYLIST_URL_HERE ZIP_FILE_NAME=YOUR_ZIP_FILE_NAME_HERE -
Run the script:
python3 script.py
-
Once the script finishes, deactivate the virtual environment:
deactivate
You can customize the script by editing the .env file with your playlist URL and desired zip file name. Ensure that the PLAYLIST_URL is the URL of the YouTube playlist you want to download, and ZIP_FILE_NAME is the desired name of the zip file.
- pytube - For downloading YouTube videos.
- python-dotenv - For loading environment variables from a
.envfile.