Skip to content

Instantly share code, notes, and snippets.

@ehashman
Created July 20, 2021 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehashman/97d57b4a873c7064fb2feaefe87dfa89 to your computer and use it in GitHub Desktop.
Save ehashman/97d57b4a873c7064fb2feaefe87dfa89 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# != 1 ]; then
echo "yoink.sh: Usage: yoink <youtube link>"
exit 1
fi
source $HOME/.virtualenvs/youtube-dl/bin/activate
output=$(youtube-dl -x -o "$HOME/music/YouTube/%(title)s-%(id)s.%(ext)s" "$1" 2>&1 | tee /dev/tty)
filename=$(youtube-dl -x -o "$HOME/music/YouTube/%(title)s-%(id)s.%(ext)s" --get-filename "$1")
ext=$(echo -e $output | egrep -oe '\.([a-z0-9]+) (exists|Deleting)' | egrep -oe '\.([a-z0-9]+)')
echo "Downloaded to ${filename%.*}$ext"
mpc update && sleep 1
mpc insert "file://${filename%.*}$ext"
mpc play && mpc next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment