Browse Source

Scripts: Update play queue to use the --input-ipc-server option

master
Riyyi 2 years ago
parent
commit
62e3d3f5e5
  1. 38
      .local/bin/play
  2. 1
      packages

38
.local/bin/play

@ -1,6 +1,8 @@
#!/bin/sh
PIPE="$XDG_CACHE_HOME/mpv/umpv_fifo"
# Depends: socat
SOCK="/tmp/umpv-fifo"
help() {
B=$(tput bold)
@ -35,10 +37,10 @@ ${B}OPTIONS${N}
EOF
}
CLIP="$(xclip -se c -o)"
CLIP="$(xclip -selection clipboard -out)"
play() {
MPV="mpv --ytdl-raw-options=external-downloader=aria2c"
MPV="mpv --ytdl-raw-options=add-metadata=,external-downloader=aria2c"
if [ -z "$1" ]; then
MPV="$MPV $CLIP"
# Cut off everything after space
@ -59,22 +61,21 @@ play() {
shuffle() {
# Skip first argument
shift 1
mpv --no-video --shuffle \
--ytdl-format='bestaudio[ext=m4a]' \
--ytdl-raw-options='external-downloader=aria2c' \
"${@:-$CLIP}"
setsid -f mpv --no-video --shuffle \
--ytdl-format='bestaudio[ext=m4a]' \
"${@:-$CLIP}"
}
queue() {
OPTIONS="--no-terminal --force-window --input-file=$PIPE --ytdl-raw-options=external-downloader=aria2c"
OPTIONS="--no-terminal --force-window --input-ipc-server=$SOCK --"
# Create mpv cache directory
DIR="$(dirname "$PIPE")"
DIR="$(dirname "$SOCK")"
[ ! -d "$DIR" ] && mkdir -p "$DIR"
# Delete named pipe if no umpv is running
# Delete socket if no umpv is running
if ! pgrep -f "mpv $OPTIONS" > /dev/null; then
rm -f "$PIPE"
rm -f "$SOCK"
fi
# Skip first argument
@ -82,19 +83,16 @@ queue() {
# Set url to argument if provided, clipboard otherwise
URLS="${*:-$CLIP}"
if [ -p "$PIPE" ]; then
if [ -S "$SOCK" ]; then
notify-send -t 2500 "Added video to queue.."
# Add video to named pipe
echo "$URLS" \
| awk -v RS=' ' '{ print "raw loadfile "$1" append" }' > "$PIPE"
echo "$URLS" | awk -v RS=' ' '{ print "raw loadfile "$1" append" }' \
| socat UNIX-CONNECT:"$SOCK" -
else
# Create named pipe
mkfifo "$PIPE"
# Play video
play "$OPTIONS" "$URLS"
rm -f "$PIPE"
notify-send -t 2500 "Loading video: $URLS"
# shellcheck disable=2086
setsid -f mpv $OPTIONS $URLS
fi
}

1
packages

@ -158,6 +158,7 @@ rtmpdump
rxvt-unicode
signal-desktop
smartmontools
socat
sqlitebrowser
sshfs
stalonetray

Loading…
Cancel
Save