bash_tv/tv.sh

53 lines
940 B
Bash
Raw Normal View History

2022-12-28 15:39:06 +00:00
#!/bin/bash
set -e
source ./common.sh
2022-12-28 15:39:06 +00:00
# Steps : enumerate all files at beginning of every playback decision
# Compare to files in folder
# if file is in playback database, skip
# else add to candidates list
# if candidate list is empty, destroy and recreate playback database
# continue
# generate random selection
# add to playback database
# add to history database
# start playback
#
Play () {
ffmpeg -threads 1 -re -i "${1}" -c copy -f flv "${DESTINATION}"
}
AllFiles () {
fileList=$(mktemp)
ls -1 "${VIDEOS}/"*.flv > "${fileList}"
echo "${fileList}"
}
SetupHistory
2022-12-29 02:36:26 +00:00
WipePlayback
SetupPlayback
last=""
while true; do
files=$(AllFiles)
fileCount=$(cat "${files}" | wc -l)
playbackCount=$(PDB "SELECT COUNT(*) FROM playback")
if [ ${fileCount} -eq 0 ]; then
echo "No files to play :("
break
fi
if [ ${playbackCount} -eq 0 ]; then
WipeHistory
SetupHistory
continue
fi
break
done
WipePlayback