Created
March 9, 2026 21:33
-
-
Save scottj/e476e16ed5cc190092385c118628b225 to your computer and use it in GitHub Desktop.
Download and play audio from Youtube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # create array of links to youtube videos or playlists | |
| declare -a ytLinks=( | |
| "https://youtu.be/dQw4w9WgXcQ" | |
| "https://youtu.be/LLFhKaqnWwk" | |
| ) | |
| # ytdl binary name | |
| ytdl=yt-dlp_macos | |
| # update ytdl first | |
| $ytdl -U | |
| # download all the things, extracting audio to mp3 | |
| for y in ${ytLinks[@]}; do | |
| $ytdl \ | |
| --extract-audio \ | |
| --audio-format mp3 \ | |
| --ignore-errors \ | |
| --download-archive .archive \ | |
| --path home:mp3 \ | |
| --yes-playlist \ | |
| --no-check-certificate \ | |
| $y | |
| done | |
| # playlist creation | |
| ls -tr mp3 | awk '{print "mp3/" $0}' > music.m3u | |
| # launch playlist | |
| open music.m3u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment