summaryrefslogtreecommitdiffstats
path: root/.local/bin/music
blob: 14352a4b3909d8a6216c599f8218052589b47b70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

library="$(awk '/-----/{y=1;next}y' "$HOME/vault/src/blog.$DOMAIN/content/music.md")"
function _play() {
	if [ -z "$1" ]
		then
			echo "Selection is empty, quitting"
			exit 1
		fi
	mpv --volume=100 --no-video --ytdl-format=bestaudio ytdl://ytsearch:"$1 audio"
	}
function find_song() {
	choice=$(printf "%s" "$library" | fzf)
	_play "$(echo "$choice" | tr "\|" "-")"
	}
function main {
	case "$1" in
		alb|album) find_album ;;
		gen|genre) find_genre ;;
		*) find_song ;;
	esac
}

main "$@"