forked from buttstuf/soapdish
57 lines
1.5 KiB
Bash
Executable File
57 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# SHOW: CREATE/UPDATE PLAYLIST
|
|
# Creates and/or updates a playlist to reflect what's in openmic-audio_queued folder
|
|
|
|
|
|
# Includes and Declarations (global variables, formatting, and functions)
|
|
source "$APPLICATION_ROOT/scripts/system/system-functions"
|
|
source "$APPLICATION_ROOT/scripts/system/system-declarations"
|
|
|
|
|
|
# Check if directory is empty
|
|
if [[ $(ls "$AUDIO_QUEUED_DIRECTORY") ]]; then
|
|
|
|
# If not empty, render list
|
|
echo -e "${COLOR_GREEN}[Q] \"audio_queued\" folder contents (${i} items):${COLOR_DEFAULT}"
|
|
echo -e ""
|
|
echo -e ""
|
|
echo -e " ${FONT_BOLD}SHOW QUEUED FOLDER CONTENTS${FONT_DEFAULT}"
|
|
echo -e ""
|
|
|
|
|
|
# Cycle through openmic audio queued directory, and print each line (just filename)
|
|
i=1
|
|
for FILE in "$AUDIO_QUEUED_DIRECTORY"/*; do
|
|
|
|
|
|
# Check i's length. If less than 10, add zero to front
|
|
STRLENGTH=${#i}
|
|
if [[ $STRLENGTH == 1 ]]; then
|
|
LEADING_ZERO_INSERTION="0"
|
|
else
|
|
LEADING_ZERO_INSERTION=""
|
|
fi
|
|
|
|
# Render line (FILE printout) with number in front
|
|
JUST_FILENAME=$(echo "$FILE" | sed "s/.*\///")
|
|
echo -e " $LEADING_ZERO_INSERTION$i: \"$JUST_FILENAME\""
|
|
|
|
# Increment i
|
|
i=$((i+1));
|
|
|
|
done
|
|
FILE_COUNT=$((i-1))
|
|
echo -e "";
|
|
echo -e " ${FONT_BOLD}[${FILE_COUNT} Files Found]${FONT_DEFAULT}\n"
|
|
echo -e "";
|
|
echo -e "";
|
|
echo -e "";
|
|
|
|
else
|
|
|
|
# If directory is empty
|
|
error_message "[Q] The \"audio_queued\" directory is empty. Add audio files.";
|
|
echo ""
|
|
|
|
fi
|