animation/log.sh

44 lines
1.4 KiB
Bash

#!/bin/bash
source ./common.sh
loglines="$(cat /dev/stdin)"
id=$(uuid)
file=$(echo "${loglines}" | grep 'FILE:' | awk -F'FILE:' '{print $2}')
starttime=$(echo "${loglines}" | grep 'START:' | awk -F':' '{print $2}')
endtime=$(echo "${loglines}" | grep 'END:' | awk -F':' '{print $2}')
pen=$(echo "${loglines}" | grep 'PEN:' | awk -F':' '{print $2}')
drawn=$(echo "${loglines}" | grep 'Length of path drawn' | awk -F':' '{print $2}' | awk '{print $1}')
moved=$(echo "${loglines}" | grep 'Total distance moved' | awk -F':' '{print $2}' | awk '{print $1}')
hash=$(hashFile "${file}")
info=$(svginfo "${file}")
paths=$(echo "$info" | grep -m 1 'number of paths' | awk -F': ' '{print $2}')
total=$(echo "$info" | grep 'total path length' | awk -F': ' '{print $2}')
ratio=$(echo "$info" | grep 'pen move ratio' | awk -F': ' '{print $2}')
bboxclean=$(echo "$info" | grep 'bbox' | awk -F ')' '{print $1}' | awk -F'(' '{print $2}')
xmin=$(echo "$bboxclean" | awk -F', ' '{print $1}')
xmax=$(echo "$bboxclean" | awk -F', ' '{print $2}')
ymin=$(echo "$bboxclean" | awk -F', ' '{print $3}')
ymax=$(echo "$bboxclean" | awk -F', ' '{print $4}')
query="INSERT OR IGNORE INTO svg (id, file, drawn, moved, starttime, endtime, pen, hash, paths, total, ratio, xmin, xmax, ymin, ymax) VALUES (\
'$id', \
'$file',\
$drawn,\
$moved,\
$starttime,\
$endtime,\
'$pen',\
'$hash',\
$paths,\
$total,\
$ratio,\
$xmin,\
$xmax,\
$ymin,\
$ymax
);"
db "${query}"
echo "${loglines}"