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