A script to turn a Youtube playlist into mp3s

There are a lot of interesting lectures on Youtube. Recently I’ve taken to adding these lectures to a playlist and processing them on my mac using the following script:

youtube-dl -o '%(stitle)s.%(ext)s' $YOUR_YOUTUBE_PLAYLIST

for file in ./*.mp4; do
	echo "processing $file"
	file = $(print '%q' "$file")
	ffmpeg -i "$file" -filter:a "atempo=2.0, pan=stereo|c1<c0+c1" -c:a libmp3lame -q:a 4 "$file.mp3"

rm -rf *.mp4

You’ll need youtube-dl and ffmpeg installed for this script to work. Both of these are available from brew.

This script also encodes the youtube video at 2x speed and combines the left and right channels into the right channel. Remove the filter flag if you don’t want your files processed this way.

No related content found.


Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.