Posted on

Lately, Iā€™ve been vibing to some synthwave tunes. YouTube is my go-to music source. Since I spend a lot of time in the MacOS terminal, I did not want to drain my battery by opening a web browser just to listen to music.

In order to do so I've wrote a short script that uses yt-dlp and mpv

#!/usr/env/bin bash

if [ $# -eq 0 ]; then
    echo "Usage: pm <SONG_NAME>"
    return 1


while true; do
    yt-dlp -f bestaudio ytsearch$s_index:"$query" -I $s_index -o - 2>/dev/null | mpv --no-video -
    s_index=$((s_index + 1))

Don't forget to make the script executable with chmod +x and optionally, alias it to your shell profile for convenience, ex:

alias pm='source ~/.config/scripts/ "@"'

You can then use it simply by running

pm synthwave 80

Enjoy the tunes! šŸŽ¶