mpv2oboeru

mpv helpers to create flashcards from movies and TV shows
git clone anongit@rnpnr.xyz:mpv2oboeru.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 9bfe06f8d3c450bc6d927e505be56cd3e653336f
Parent: 655122ed47dba51e551cc7972010c7517dee7f10
Author: Ren Tatsumoto
Date:   Mon,  7 Sep 2020 01:29:51 +0300

parse results in a separate function

Diffstat:
Msubs2srs.lua | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/subs2srs.lua b/subs2srs.lua @@ -376,6 +376,27 @@ ankiconnect.execute = function(request) return ret end +ankiconnect.parse_result = function(curl_output) + -- there are two values that we actually care about: result and error + -- but we need to crawl inside to get them. + + if curl_output.status ~= 0 then + return nil, "Ankiconnect isn't running" + end + + local stdout_json = utils.parse_json(curl_output.stdout) + + if stdout_json == nil then + return nil, "Fatal error from Ankiconnect" + end + + if stdout_json.error ~= nil then + return nil, tostring(stdout_json.error) + end + + return stdout_json.result, nil +end + ankiconnect.create_deck_if_doesnt_exist = function(deck_name) local args = { action = "changeDeck",