2022-12-28 15:39:06 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-12-28 16:41:42 +00:00
|
|
|
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
|
2022-12-28 16:41:42 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
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
|
2022-12-28 16:41:42 +00:00
|
|
|
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
|
2024-03-28 01:06:24 +00:00
|
|
|
if [ ${playbackCount} -eq 0 ]; then
|
|
|
|
WipeHistory
|
|
|
|
SetupHistory
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2022-12-28 16:41:42 +00:00
|
|
|
break
|
|
|
|
done
|
|
|
|
|
|
|
|
WipePlayback
|