bash_tv/common.sh

45 lines
653 B
Bash
Raw Normal View History

#!/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}"
}
SetupPlayback () {
echo "${PLAYBACK_SETUP}" | sqlite3 "${PLAYBACK}"
}
WipePlayback () {
rm -f "${PLAYBACK}"
}
PDB () {
sqlite3 "${PLAYBACK}" "${1}"
}
HDB () {
sqlite3 "${HISTORY}" "${1}"
}