Listen to YouTube Music for Free (No App, No Premium)
• How To
This is a basic way to play music from YouTube from your terminal.
Terminal Command (One-Liner)
Install tools once:
brew install yt-dlp mpv
Play a track by search term:
mpv --no-video --volume=100 "$(yt-dlp -f 'bestaudio' --get-url --no-playlist 'ytsearch1:Nujabes Aruarian Dance' | head -n 1)"
What this does:
yt-dlpsearches YouTube and resolves the best audio stream URLmpvplays that URL as audio only
To play something else, change the text inside ytsearch1:....
Make it reusable with a tiny script
Create ytmusic:
#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -eq 0 ]; then
echo "Usage: ytmusic <search terms>"
exit 1
fi
query="$*"
url="$(yt-dlp -f 'bestaudio' --get-url --no-playlist "ytsearch1:${query}" | head -n 1)"
if [ -z "$url" ]; then
echo "No result found for: $query"
exit 1
fi
mpv --no-video --volume=100 "$url"
Make it executable:
chmod +x ytmusic
Run it:
./ytmusic nujabes aruarian dance
./ytmusic aphex twin xtal
Does this always avoid ads?
You do not need YouTube Premium for this method.
Ad behavior can still vary by video, region, account state, and YouTube policy changes. In practice, these flows are often lighter than the normal YouTube watch page, but nothing here guarantees zero ads forever.
Quick troubleshooting
If mpv opens but you hear nothing, make sure your command includes -f 'bestaudio':
mpv --no-video --volume=100 "$(yt-dlp -f 'bestaudio' --get-url --no-playlist 'ytsearch1:YOUR SEARCH HERE' | head -n 1)"
The key part is -f 'bestaudio'.