bash_tv/tv.sh

53 lines
940 B
Bash

#!/bin/bash
set -e
source ./common.sh
# 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
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