This nifty little script in Python3 allows you to download a complete playlist as .mp4’s.
If you don’t have python get it via the link below. Make sure to import the needed libraries using pip (pip3).
import re
from pytube import Playlist
def clean_title(title):
# Remove non-alphanumeric characters and spaces from the title
cleaned_title = re.sub(r'[^\w\s]', '', title)
return cleaned_title
def download_playlist(playlist_url, resolution='720p'):
playlist = Playlist(playlist_url)
# Filter out videos with the desired resolution
videos =
# Download each video
for video in videos:
try:
# Clean the video title before downloading
cleaned_title = clean_title(video.title)
print(f"Downloading {cleaned_title}...")
video.streams.filter(res=resolution).first().download()
print(f"{cleaned_title} downloaded successfully.")
except Exception as e:
print(f"Error downloading {video.title}: {e}")
if __name__ == "__main__":
playlist_url = input("Enter the URL of the YouTube playlist: ")
download_playlist(playlist_url, resolution='720p')
Add comment