@teejcee
I agree with your "guesses".
I was able, by adapting your pal's script, to put the values into $variables and use these variables to get the wanted response from sqlite3 using the same script:
Code:
SQL="select title, author_sort from books where id="$VAR" ;"
TITLE=$(sqlite3 $DATABASE "$SQL")
Where:
$VAR = (the value of id=)
$DATABASE = (/path/to/calibredatabase/metadata.db) -> needs work to make this variable with db=[value])
I'll work on the script some more tomorrow (it's not publishable now. It confuses even me now and then with all the commented out lines with failed attempts.)
As to your "showstopper":
1 - I observed that some clients had a distinguishable response when something was actually downloaded compared to when it was not, but for instance Firefox had not.

2 - But what is the problem? What's the difference between backing out of downloading and downloading and directly deleting the downloaded content (what I usually do when I do not like what I just downloaded).
Did you arrive at the same code as I did?