Skip to content

Instantly share code, notes, and snippets.

@AleixMT
Last active November 15, 2021 14:14
Show Gist options
  • Save AleixMT/4d26f6d81cff5aa724bbc5bd48555e96 to your computer and use it in GitHub Desktop.
Save AleixMT/4d26f6d81cff5aa724bbc5bd48555e96 to your computer and use it in GitHub Desktop.
Scratch MP3 files from a Youtube public playlist
# Install dependencies
sudo apt-get install -y python3 python python-pip curl ffmpeg git
# Install PyTube
python -m pip install git+https://github.com/pytube/pytube
# Use command line to scratch audio from videos in a public YouTube playlist
# This will create the folder _Music which will contain all the downloaded audio in mp4 format.
pytube https://www.youtube.com/playlist?list=PLsS6gopj1BA1Pi-PlaYlIssTtt -a
# Transform into mp3 using ffmpeg and conserving filename (assuming that ".mp4" extension is always present).
for file_name in *; do
ffmpeg -i "${filename}" "$(echo "${filename}" | rev | cut -d "." -f2- | rev)".mp3
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment