Redo mpvqueue script
This commit is contained in:
parent
86641f0368
commit
04a7d03d8e
1 changed files with 9 additions and 9 deletions
|
@ -4,11 +4,11 @@ MPVPIPE=/tmp/mpvqueue.playlist
|
||||||
|
|
||||||
notify="notify-send -i mpv -a mpv"
|
notify="notify-send -i mpv -a mpv"
|
||||||
|
|
||||||
# if link is a youtube playlist, open recursively
|
# if link is a youtube playlist, clean up url
|
||||||
if [[ ${1} =~ (^.*(youtu.be\/|list=)([^#\&\?]*).*) ]]; then
|
if [[ ${1} =~ /^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$ ]]; then
|
||||||
$notify "Adding playlist ${@}"
|
url="https://youtube.com/playlist?list=${1#*list=}"
|
||||||
/usr/local/bin/mpvqueue $(youtube-dl -j --flat-playlist "${1}" | jq -r '.id' | sed 's_^_https://youtube.com/watch?v=_')
|
else
|
||||||
exit
|
url="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# See if MPV is already running
|
# See if MPV is already running
|
||||||
|
@ -18,16 +18,16 @@ if [ -z "$(pidof mpv)" ]; then
|
||||||
rm -f $MPVPIPE && mkfifo $MPVPIPE
|
rm -f $MPVPIPE && mkfifo $MPVPIPE
|
||||||
|
|
||||||
# start mpv
|
# start mpv
|
||||||
/usr/bin/mpv --no-terminal --input-file="${MPVPIPE}" "${@}" & disown
|
/usr/bin/mpv --no-terminal --input-file="${MPVPIPE}" "$url" & disown
|
||||||
|
|
||||||
# Wait for mpv to be up before moving on to adding anything else to playlist
|
# Wait for mpv to be up before moving on to adding anything else to playlist
|
||||||
while [ -z "$(pidof mpv)" ]; do
|
while [ -z "$(pidof mpv)" ]; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
$notify "Playing ${@}"
|
$notify "Playing $url"
|
||||||
|
|
||||||
else
|
else
|
||||||
# mpv is running, so add stuff to playlist
|
# mpv is running, so add stuff to playlist
|
||||||
$notify "Adding ${@}"
|
$notify "Adding $url"
|
||||||
echo "loadfile \"${@}\" append-play" >> "${MPVPIPE}"
|
echo "loadfile \"$url\" append-play" >> "${MPVPIPE}"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue