Trying to automate making cards into Anki from Drafts with the following shell script, using AnkiConnect plugin:
// See online documentation for examples
// https://docs.getdrafts.com/docs/actions/scripting
// define text of bash script
let script = `#!/bin/bash
/usr/bin/curl localhost:8765 -X POST -d "{
\"action\": \"guiAddCards\",
\"version\": 6,
\"params\": {
\"note\": {
\"deckName\": \"Master\",
\"modelName\": \"Basic\",
\"fields\": {
\"Front\": \"Test\",
\"Back\": \"Test\"
},
\"options\": {
\"closeAfterAdding\": true
},
\"tags\": [
\"countries\"
]
}
}
}"
`;
let runner = ShellScript.create(script);
if (runner.execute(["1", "2"])) {
alert("STDOUT:\n" + runner.standardOutput);
}
else {
alert("STDERR:\n" + runner.standardError);
}
Getting this error:
STDERR:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
curl: (7) Failed to connect to localhost port 8765: Connection refused
Wondering if any of you have any thoughts?