Skip to content

Instantly share code, notes, and snippets.

@tcoppex
Created March 23, 2024 12:01
Show Gist options
  • Save tcoppex/b4a6f082f542e82c75828c1e0a72a137 to your computer and use it in GitHub Desktop.
Save tcoppex/b4a6f082f542e82c75828c1e0a72a137 to your computer and use it in GitHub Desktop.
Create a single file mix from a youtube playlist.
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <id_de_la_playlist>"
exit 1
fi
playlist_id="$1"
temp_dir=$(mktemp -d)
./yt-dlp_linux -x --audio-format mp3 --output "$temp_dir/%(title)s.%(ext)s" "https://www.youtube.com/playlist?list=$playlist_id"
cd "$temp_dir" || exit 1
rename "s/'//g" *.mp3
for f in *.mp3; do echo "file '$PWD/$f'"; done > list.txt
ffmpeg -f concat -safe 0 -i list.txt -acodec libmp3lame -q:a 2 final_mix.mp3
mv final_mix.mp3 "$OLDPWD"/
cd "$OLDPWD" || exit 1
rm -rf "$temp_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment