From 0f948bf04b043866b1eda22faaa6ff8f1b32ddd4 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 28 Feb 2019 16:00:58 +0100 Subject: [PATCH] Add support for stream aliases Signed-off-by: Knut Ahlers --- bin/mpc-yt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/mpc-yt b/bin/mpc-yt index 97f9cdb..41852ed 100755 --- a/bin/mpc-yt +++ b/bin/mpc-yt @@ -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})