Add mpc-yt wrapper script
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
851ac04b39
commit
0ab4a0a256
1 changed files with 26 additions and 0 deletions
26
bin/mpc-yt
Executable file
26
bin/mpc-yt
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
source ${HOME}/bin/script_framework.sh
|
||||
|
||||
ydl=$(which youtube-dl)
|
||||
yurl=${1:-}
|
||||
|
||||
[ -n "${ydl}" ] || fail "Missing youtube-dl command"
|
||||
[ -n "${yurl}" ] || fail "Missing YouTube URL"
|
||||
|
||||
step "Fetching video information..."
|
||||
title=$(${ydl} -e ${yurl})
|
||||
playlist=$(${ydl} -g ${yurl})
|
||||
|
||||
step "Writing playlist..."
|
||||
cat -s <<EOF >${HOME}/.config/mpd/playlists/mpc-yt.m3u
|
||||
#EXTM3U
|
||||
#EXTINF:0,${title}
|
||||
${playlist}
|
||||
EOF
|
||||
|
||||
step "Loading playlist and starting playback..."
|
||||
mpc clear
|
||||
mpc load mpc-yt
|
||||
mpc play
|
Loading…
Reference in a new issue