Skip to content

Instantly share code, notes, and snippets.

@t-buss
Created May 15, 2020 18:46
Show Gist options
  • Save t-buss/37effb4b16006be4780eb02bddf7fe84 to your computer and use it in GitHub Desktop.
Save t-buss/37effb4b16006be4780eb02bddf7fe84 to your computer and use it in GitHub Desktop.
mq - mpd queue: Search YouTube for a music video, then add the track to mpd
#!/usr/bin/env bash
QUERY_RESULT=$(mktemp)
youtube-dl -J -f140 "ytsearch15:$*" | jq ".entries" > $QUERY_RESULT
TITLE=$(jq -r ".[] | .title" $QUERY_RESULT | fzf)
LINK=$(jq -r ".[]
| select(.title==\"$TITLE\")
| .formats
| .[]
| select(.format==\"140 - audio only (tiny)\")
| .url" $QUERY_RESULT)
mpc add "$LINK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment