Annotation of plm/genpl, revision 1.2

1.1       snw         1: #!/usr/bin/env bash
                      2: 
1.2     ! snw         3: #
        !             4: # $Id$
        !             5: #  Playlist generator for plm
        !             6: #
        !             7: #  Copyright (C) 2025 Serena Willis
        !             8: #
        !             9: #   $Log$
        !            10: #
        !            11: # SPDX-FileCopyrightText: (C) 2025 Serena Willis
        !            12: #
        !            13: # SPDX-License-Identifier: AGPL-3.0
        !            14: 
1.1       snw        15: 
                     16: if [[ $# != 1 ]]
                     17: then
                     18:     echo "genpl: must specify specfile"
                     19:     exit 1
                     20: fi
                     21: 
                     22: LISTNAME="$1"
                     23: SPECFILE="${HOME}/.config/genpl/${LISTNAME}"
                     24: 
                     25: if [[ ! -f "${SPECFILE}" ]]
                     26: then
                     27:     echo "genpl: ${SPECFILE} not found"
                     28:     exit 2
                     29: fi
                     30: 
                     31: BASEDIR=$(cat "${SPECFILE}" | grep -E "^BASEDIR:" | cut -d: -f2)
                     32: BASELIST="BASE${LISTNAME}"
                     33: INLISTS=$(cat "${SPECFILE}" | grep -E "^LISTS:" | cut -d: -f2)
                     34: 
                     35: if [[ -f "${BASELIST}" ]]
                     36: then
                     37:     LISTS="${BASELIST},${INLISTS}"
                     38: else
                     39:     LISTS="${INLISTS}"
                     40: fi
                     41: 
                     42: IFS=","
                     43: for LIST in $LISTS
                     44: do
                     45:     OLIST="${OLIST} ${LIST}.m3u"
                     46: done
                     47: unset IFS
                     48: 
                     49: OLIST=$(echo "${OLIST}" | tr ' ' ',')
                     50: LISTS="${OLIST:1}"
                     51: 
                     52: if [[ ! -d "${BASEDIR}" ]]
                     53: then
                     54:     echo "genpl: ${BASEDIR} base directory not found"
                     55:     exit 3
                     56: fi
                     57: 
                     58: pushd "${BASEDIR}" &> /dev/null
                     59: 
                     60: echo
                     61: echo "Creating playlist ${LISTNAME} from:"
                     62: for LIST in $(echo ${OLIST} | tr ',' ' ')
                     63: do
                     64:     echo "  * ${LIST}"
                     65: done
                     66: 
                     67: pl --merge --input="${LISTS}" --output="${LISTNAME}.m3u" --overwrite
                     68: 
                     69: popd &> /dev/null

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>