~xdavidwu/dotfiles

e59e24d6e9926a46ac4ad2d53063fe3f5a66db1e — xdavidwu 4 years ago 7d920b4
play-playlist: move to mpv

and make script a lot shorter to nicely fit in a bashrc function
2 files changed, 8 insertions(+), 26 deletions(-)

M .bashrc
D .local/bin/play-playlist
M .bashrc => .bashrc +8 -0
@@ 77,6 77,14 @@ batlvl() {
		$(cat /sys/class/power_supply/BAT0/charge_full_design) ))
}

play-playlist() {
	ARGS=
	for list in $@;do
		ARGS="$ARGS --playlist=$list"
	done
	mpv --ytdl-raw-options=audio-format=best --no-video $ARGS
}

# application envs
# policy: should here even if global like /etc/environments
export GPG_TTY=$(tty)

D .local/bin/play-playlist => .local/bin/play-playlist +0 -26
@@ 1,26 0,0 @@
#!/bin/sh

set -e

[ ! -f "$1" ] && exit 1

IFS=$'\n'

FLAG=1
TITLE=
ARGS=
for i in $(youtube-dl -xeg --audio-format best $(cat $@));do
	if [ $FLAG -eq 1 ];then #title
		FLAG=2
		TITLE=$i
	else #url
		FLAG=1
		ARGS="$ARGS"$'\n'"$i"$'\n'":meta-title=$TITLE"
		TITLE=
	fi
done

echo cvlc $ARGS

cvlc $ARGS