Skip to content

Instantly share code, notes, and snippets.

@gtataranni
Last active January 29, 2016 10:21
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 gtataranni/3cb3d0b7c1b185555838 to your computer and use it in GitHub Desktop.
Save gtataranni/3cb3d0b7c1b185555838 to your computer and use it in GitHub Desktop.
find the first closer match in your music folder and play it. The first word should be in the song filename, the others can be either in the filename or in the path, as for artist name
#!/bin/bash
MUSIC_DIR="/media/Volume/Musica personale/"
find "$MUSIC_DIR" -iname "*$1*.mp3" -o -iname "*$1*.wma" -type f | while read line; do
good=1;
for arg in $@ ; do
if [ $good -eq 1 ]; then
echo $line | grep -i -q "$arg"
if [ $? -eq 1 ] ; then
good=0;
fi
fi
done
if [ $good -eq 1 ]; then
#echo $line
mplayer -volume 75 "$line" </dev/tty
#exit this subshell
exit 1
fi
done
#if song is not in MUSIC_DIR: play it form youtube
if [ $? -eq 0 ] ; then
#echo "YOUTUBEEEEE!"
mpsyt ."$@",1,q
fi
echo "Bye!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment