Skip to content

Instantly share code, notes, and snippets.

@vtmx
Last active October 16, 2024 22:25
Show Gist options
  • Select an option

  • Save vtmx/e52df7a83b2c014f410008588bf70c45 to your computer and use it in GitHub Desktop.

Select an option

Save vtmx/e52df7a83b2c014f410008588bf70c45 to your computer and use it in GitHub Desktop.
play.sh
# Play
play() {
if type mpv >& /dev/null; then
local music="$HOME/Music"
local args="--no-video --display-tags=Title,Artist"
usage() {
echo -e "\nr Recents\ns Search"; return 1
}
to_play() {
if [[ -d "$1" ]]; then
# find "$1" -type f -name "*.mp3" -exec mpv $args {} +
ls -R "$1" | awk '!/:$/ && !/^$/ {print $NF}' | xargs mpv $args
elif [[ "$1" =~ ^"http" ]]; then
mpv $args "$1"
else
mpv $args **/*.mp3
fi
}
case "$1" in
@(ani?(me))) to_play "$music/anime" ;;
@(jaz?(z))) to_play "$music/jazz" ;;
lof|lofi) to_play "https://www.youtube.com/live/jfKfPfyJRdk" ;;
ost) to_play "$music/ost" ;;
@(r?(ecent)?(s))) ls -t "$music"/** | head -n 30 | xargs mpv $args ;;
@(retro?(wave))) to_play "$music/retrowave" ;;
@(syn?(th)?(wave))) to_play "https://www.youtube.com/live/4xDzrJKXOOY" ;;
*) to_play $1 ;;
esac
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment