More changed for mpc/mpd

This commit is contained in:
inigoortega 2020-04-11 18:47:51 +02:00
parent e87b48defc
commit d93c3650d3
3 changed files with 34 additions and 32 deletions

View File

@ -6,10 +6,10 @@ usage() {
printf " printf "
-f <format> Sets the format the audio will be downloaded on. -f <format> Sets the format the audio will be downloaded on.
Default: ogg opus when possible, otherwise vorbis ogg. Default: ogg opus when possible, otherwise vorbis ogg.
-d <directory> Sets the directory where downloaded audio will be stored. -d <directory> Sets the directory where downloaded audio will be stored.
Default: \$HOME/Downloads/youtube-dl/ Default: \$HOME/Downloads/youtube-dl/
" >&2 " >&2
exit 1 exit 1
} }
@ -50,7 +50,7 @@ if [ "$format" = "opus" ]; then
youtube-dl -x --audio-quality 0 --audio-format opus "$link" youtube-dl -x --audio-quality 0 --audio-format opus "$link"
size="$(stat --printf="%s" "$filename")" size="$(stat --printf="%s" "$filename")"
if [ "$size" < 500000 ]; then if [ "$size" -lt 500000 ]; then
youtube-dl -x --audio-quality 0 --audio-format vorbis "$link" youtube-dl -x --audio-quality 0 --audio-format vorbis "$link"
rm "$filename" rm "$filename"
fi fi

View File

@ -1,7 +1,5 @@
#!/usr/bin/env sh #!/usr/bin/env sh
player="$AUDIOPLAYER"
if [ -f "$1" ] && [ -n "$(printf "%b\n" "$1" | sed -r "s|\\.[^\\.]+$||")" ]; then if [ -f "$1" ] && [ -n "$(printf "%b\n" "$1" | sed -r "s|\\.[^\\.]+$||")" ]; then
media="$1" media="$1"
else else
@ -24,18 +22,10 @@ else
media="$HOME/$media" media="$HOME/$media"
fi fi
if [ "$media" != "$HOME/" ]; then [ "$media" != "$HOME/" ] && {
dash $HOME/bin/cmusd.sh > /dev/null 2>&1 if [ "$(command -v disown > /dev/null)" ]; then
sleep 1 st -c "Music Player" -e "$AUDIOPLAYER" "$media" 2>/dev/null & disown
else
dash -c "$player -C 'view tree'" st -c "Music Player" -e "$AUDIOPLAYER" "$media" 2>/dev/null &
dash -c "$player -C clear" fi
dash -c "$player -C \"view queue\"" }
dash -c "$player -C clear"
# sleep 1
dash -c "$player -C \"add $media\""
sleep 1
dash -c "$player -C player-next"
dash -c "$player -C player-play"
# dash -c "$player -C win-remove"
fi

View File

@ -1,15 +1,27 @@
#!/usr/bin/env sh #!/usr/bin/env sh
dash $HOME/bin/cmusd.sh dash $SCRIPTS/musicplayerui.sh
case "$MUSICPLAYER" in
"cmus-remote")
dash -c "$AUDIOPLAYER -C 'view tree'" dash -c "cmus-remote -C 'view tree'"
dash -c "$AUDIOPLAYER -C clear" dash -c "cmus-remote -C clear"
dash -c "$AUDIOPLAYER -C \"view queue\"" dash -c "cmus-remote -C \"view queue\""
dash -c "$AUDIOPLAYER -C clear" dash -c "cmus-remote -C clear"
sleep 1 sleep 1
dash -c "$AUDIOPLAYER -C \"view sorted\"" dash -c "cmus-remote -C \"view sorted\""
dash -c "$AUDIOPLAYER -C clear" dash -c "cmus-remote -C clear"
dash -c "$AUDIOPLAYER -C \"add $MUSIC\"" dash -c "cmus-remote -C \"add $MUSIC\""
sleep 1 sleep 1
dash -c "$AUDIOPLAYER -C player-next" dash -c "cmus-remote -C player-next"
dash -c "$AUDIOPLAYER -C player-play" dash -c "cmus-remote -C player-play"
;;
"mpc")
mpc clear
mpc update
mpc ls | mpc add
mpc shuffle
mpc play
;;
esac