Add support for stream aliases

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2019-02-28 16:00:58 +01:00
parent b23edce0d1
commit 0f948bf04b
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -1,14 +1,23 @@
#!/bin/bash
set -euo pipefail
declare -A streamalias
source ${HOME}/bin/script_framework.sh
[ -f ${HOME}/.config/mpc-yt.cfg ] && source ${HOME}/.config/mpc-yt.cfg
ydl=$(which youtube-dl)
yurl=${1:-}
[ -n "${ydl}" ] || fail "Missing youtube-dl command"
[ -n "${yurl}" ] || fail "Missing YouTube URL"
[ -n "${streamalias[${yurl}]:-}" ] && {
info "Found alias \"${yurl}\", continuing with configured URL \"${streamalias[${yurl}]}\""
yurl=${streamalias[${yurl}]}
}
step "Fetching video information..."
title=$(${ydl} -e ${yurl})
playlist=$(${ydl} -g ${yurl})