Created
July 20, 2021 23:46
-
-
Save ehashman/97d57b4a873c7064fb2feaefe87dfa89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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