Skip to content

Instantly share code, notes, and snippets.

@DanielBoerlage
Created May 12, 2015 20:24
Show Gist options
  • Save DanielBoerlage/bed476640ea7b4fb4257 to your computer and use it in GitHub Desktop.
Save DanielBoerlage/bed476640ea7b4fb4257 to your computer and use it in GitHub Desktop.
music stuff
alias getsong='youtube-dl --default-search "gvsearch1:" -x --audio-format opus --audio-quality 64K -o ~/Music/%\(title\)s.%\(ext\)s'
playsong() {
search_q="^`printf "(?=.*%s)" "$@"`.+"
song_file=`find ~/Music | grep -iP --color=never "$search_q"`
if [[ -z "$song_file" ]]
then
echo -e "\e[1mno local songs found"
wget $(youtube-dl -f 140 -g --default-search "gvsearch1:" "song $*") -O - 2>/dev/null | \
mplayer -nolirc -msgcolor -msglevel all=0:statusline=5 /dev/fd/3 3<&0 </dev/tty
else
file_name=`basename "$song_file"`
echo -e "playing local song \e[1m${file_name%.*}\e[m"
mplayer -nolirc -msgcolor -msglevel all=0:statusline=5 "$song_file"
#mplayer -nolirc -msgcolor -msgmodule "$song_file"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment