#!/usr/bin/env bash if [[ $# != 1 ]] then echo "genpl: must specify specfile" exit 1 fi LISTNAME="$1" SPECFILE="${HOME}/.config/genpl/${LISTNAME}" if [[ ! -f "${SPECFILE}" ]] then echo "genpl: ${SPECFILE} not found" exit 2 fi BASEDIR=$(cat "${SPECFILE}" | grep -E "^BASEDIR:" | cut -d: -f2) BASELIST="BASE${LISTNAME}" INLISTS=$(cat "${SPECFILE}" | grep -E "^LISTS:" | cut -d: -f2) if [[ -f "${BASELIST}" ]] then LISTS="${BASELIST},${INLISTS}" else LISTS="${INLISTS}" fi IFS="," for LIST in $LISTS do OLIST="${OLIST} ${LIST}.m3u" done unset IFS OLIST=$(echo "${OLIST}" | tr ' ' ',') LISTS="${OLIST:1}" if [[ ! -d "${BASEDIR}" ]] then echo "genpl: ${BASEDIR} base directory not found" exit 3 fi pushd "${BASEDIR}" &> /dev/null echo echo "Creating playlist ${LISTNAME} from:" for LIST in $(echo ${OLIST} | tr ',' ' ') do echo " * ${LIST}" done pl --merge --input="${LISTS}" --output="${LISTNAME}.m3u" --overwrite popd &> /dev/null