Hi there,
just if anyone is interested: I used this bash script (on Ubuntu Bionic) to import a (master) dark to the Darks Library, following Jasem's tip of handling directly the sqlite database. Sorry, no warranty provided.
It assumes that the FITS file has some keywords (INSTRUME, XBINNING, YBINNING, EXPTIME) with the correct values (and that it has the correct bit depth, etc.), so you only have to input the path to the filename, and the temperature value (my guide camera doesn't provide it). Copy the code below and save with filename import-dark.sh. You should then give execution permission to the file: $ chmod u+x import-dark.sh
To import a dark: $ <path.to>/import-dark.sh <filename> <temperature>
After importing you may have to hit "Refresh" on the Dark Library configuration page on KStars to actually see the new row.
Hope it helps.
#!/bin/bash
#
# Requires package 'sqlite': $ sudo apt install sqlite
# Requires package 'astropy-utils': $ sudo apt install astropy-utils
# Requires 'readlink -e' command
if [[ -z "$1" || -z "$2" ]] ; then
echo "Usage: import-dark.sh <filename> <temperature>"
exit 1
fi
TIMESTAMP=`date +"%Y-%m-%d %H:%M:%S"`
echo "Timestamp: $TIMESTAMP (now)"
TEMP=$2
echo "Temperature: $TEMP (ºC, provided as argument)"
SOURCE=$(readlink -e "$1")
BASENAME=$(basename "$1")
FILENAME="$HOME/.local/share/kstars/darks/$BASENAME"
echo "Copying $BASENAME to $FILENAME..."
cp "$SOURCE" "$FILENAME"
echo "Reading headers of file $FILENAME..."
declare -a FITSKEYS
readarray -t FITSKEYS <<< "$(fitsheader -e 0 -t ascii.csv -k INSTRUME -k XBINNING -k YBINNING -k EXPTIME "$FILENAME" | cut -f 4 -d , | tail -n +2)"
CCD="${FITSKEYS[0]}"
BINX="${FITSKEYS[1]}"
BINY="${FITSKEYS[2]}"
DURATION="${FITSKEYS[3]}"
echo " CCD: $CCD"
echo " BinX: $BINX"
echo " BinY: $BINY"
echo " Duration: $DURATION (s)"
SQL="insert into darkframe(ccd, chip, binX, binY, temperature, duration, filename, timestamp) values('$CCD', '0', '$BINX', '$BINY', '$TEMP', '$DURATION', '$FILENAME', '$TIMESTAMP')"
# echo "Importing dark..."
echo "Executing '$SQL'..."
sqlite3 ~/.local/share/kstars/userdb.sqlite "$SQL" && echo "Done."
exit $?