2022-12-28 16:41:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ ! -f .env ]; then
|
|
|
|
cp default.env .env
|
|
|
|
fi
|
|
|
|
|
|
|
|
source .env
|
|
|
|
|
|
|
|
if [ ! -d "${INPUT}" ]; then
|
|
|
|
mkdir -p "${INPUT}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "${VIDEOS}" ]; then
|
|
|
|
mkdir -p "${VIDEOS}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
HISTORY_SETUP="CREATE TABLE IF NOT EXISTS history (
|
|
|
|
video VARCHAR PRIMARY KEY,
|
|
|
|
playcount INT DEFAULT 0,
|
|
|
|
last INT
|
|
|
|
)"
|
|
|
|
|
|
|
|
PLAYBACK_SETUP="CREATE TABLE IF NOT EXISTS playback (
|
|
|
|
video VARCHAR PRIMARY KEY
|
|
|
|
)"
|
|
|
|
|
|
|
|
SetupHistory () {
|
|
|
|
echo "${HISTORY_SETUP}" | sqlite3 "${HISTORY}"
|
|
|
|
}
|
|
|
|
|
2024-03-28 01:06:24 +00:00
|
|
|
WipeHistory () {
|
|
|
|
rm -f "${HISTORY}"
|
|
|
|
}
|
|
|
|
|
2022-12-28 16:41:42 +00:00
|
|
|
SetupPlayback () {
|
|
|
|
echo "${PLAYBACK_SETUP}" | sqlite3 "${PLAYBACK}"
|
|
|
|
}
|
|
|
|
|
|
|
|
WipePlayback () {
|
|
|
|
rm -f "${PLAYBACK}"
|
|
|
|
}
|
|
|
|
|
2024-03-28 01:06:24 +00:00
|
|
|
GetRandom () {
|
|
|
|
QUERY="SELECT video FROM playback ORDER BY RANDOM() LIMIT 1;"
|
|
|
|
sqlite3 "${HISTORY}" "${QUERY}"
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateHistory () {
|
|
|
|
QUERY="INSERT INTO"
|
|
|
|
}
|
|
|
|
|
2022-12-28 16:41:42 +00:00
|
|
|
PDB () {
|
|
|
|
sqlite3 "${PLAYBACK}" "${1}"
|
|
|
|
}
|
|
|
|
|
|
|
|
HDB () {
|
|
|
|
sqlite3 "${HISTORY}" "${1}"
|
2024-03-28 01:06:24 +00:00
|
|
|
}
|
|
|
|
|