Simple Bash script to download a YouTube video as an MP3 using yt-dlp.
- Clipboard URL detection before prompting for input (via
xclipon Linux,pbpasteon macOS, andGet-Clipboardon Windows). - Optional URL argument; otherwise reads from the clipboard and falls back to a prompt.
- Installs required tools on supported platforms:
- Debian/Ubuntu:
yt-dlp,ffmpeg,xclip(viaapt-get). - RPM-based Linux:
yt-dlp,ffmpeg,xclip(viadnf/yum). - macOS:
yt-dlp,ffmpeg(via Homebrew). - Windows:
yt-dlp,ffmpeg(viawinget).
- Debian/Ubuntu:
./YTMP3.sh "https://www.youtube.com/watch?v=example"
# or
./YTMP3.sh # attempts clipboard, then prompts for a URLUses
apt-getand may requiresudoprivileges. Requiresxclipfor clipboard detection.
./YTMP3_rpm.sh "https://www.youtube.com/watch?v=example"
# or
./YTMP3_rpm.shUses
dnf/yumand may requiresudoprivileges. Requiresxclipfor clipboard detection.
./YTMP3_mac.sh "https://www.youtube.com/watch?v=example"
# or
./YTMP3_mac.shRequires Homebrew. Clipboard detection uses
pbpaste.
powershell -ExecutionPolicy Bypass -File .\YTMP3_windows.ps1 "https://www.youtube.com/watch?v=example"
# or
powershell -ExecutionPolicy Bypass -File .\YTMP3_windows.ps1Requires PowerShell with
wingetavailable to installyt-dlpandffmpeg. Clipboard detection usesGet-Clipboard. =======
- Installs required tools (
yt-dlp,ffmpeg,xclip) on Debian/Ubuntu systems when missing. - Detects URLs in the clipboard (via
xclip), falling back to prompting if none is found. - Accepts a URL passed as an argument or reads it from the clipboard; otherwise prompts for input.
./YTMP3.sh "https://www.youtube.com/watch?v=example"
# or
./YTMP3.sh # will attempt clipboard, then prompt for a URLNote: Package installation uses
apt-getand may requiresudoprivileges.