Requirements
python3 -m pip install pytube
sudo apt-get install rename
Script
Save the following lines as a file, eg pytubemp3.py
. Don’t forget to set your own playlists
from pytube import Playlist
links = ["https://www.youtube.com/watch?v=vvvvv&list=xxxxxxx",
"https://www.youtube.com/watch?v=vvvvv&list=xxxxxxx"]
for link in links:
playlist = Playlist("https://youtube.com/playlist?" + link.split("&")[1])
for video in playlist.videos:
print("Downloading: ", video.title,"from", video.watch_url)
video.streams.filter(only_audio=True).first().download()
Make sure your script is formatted with indents as the image below:

Then run:
python pytubemp3.py
. This step save the audio of youtube video asmp4
file.rename "s/mp4$/mp3/" *.mp4
. This step replace the suffixmp4
withmp3