# register_video \ # file_name raw_file duration mp4_file \ # rotated_file thumbnail_file record_datetime \ # day_of_week record_time \ # lat long address register_video() { local file_name=$1 local raw_file=$2 local duration=$3 local mp4_file=$4 local rotated_file=$5 local thumbnail_file=$6 local record_datetime=${7:-$(date +%s)} local day_of_week=${8:-$(date +'%A')} local lat=${9:-0.000000} local long=${10:-0.000000} local address=${11:-Unknown} address=$(sed "s|'| |g" <<< $address) if [ -z "$raw_file" ] || [ -z "$mp4_file" ]; then echo "Error: raw_file and mp4_file are required" exit 1 fi local mp4_file_name=$(basename $(dirname $mp4_file)) sqlite3 $DANCE_VIDEOS_DB "PRAGMA busy_timeout = 10000; INSERT OR REPLACE INTO videos (file_name, raw_file, duration, mp4_file, mp4_file_name, rotated_file, thumbnail_file, record_datetime, day_of_week, lat, long, address) VALUES('$file_name','$raw_file', '$duration', '$mp4_file', '$mp4_file_name', '$rotated_file', '$thumbnail_file', $record_datetime, '$day_of_week', $lat, $long, '$address');" } export -f register_video