Commit: 781252cdcad2460794783d8fb4e845c9f7aed2c2
Parent: d0d9827ee91a042e9e20013f42c2d11102336f49
Author: Ren Tatsumoto
Date: Sat, 12 Dec 2020 20:10:30 +0300
add facilities for storing local media files
Diffstat:
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/subs2srs.lua b/subs2srs.lua
@@ -719,6 +719,26 @@ ankiconnect.parse_result = function(curl_output)
return stdout_json.result, nil
end
+ankiconnect.store_file = function(filename, file_path)
+ local args = {
+ action = "storeMediaFile",
+ version = 6,
+ params = {
+ filename = filename,
+ path = file_path
+ }
+ }
+
+ local ret = ankiconnect.execute(args)
+ local _, error = ankiconnect.parse_result(ret)
+ if not error then
+ msg.info(string.format("File stored: '%s'.", filename))
+ else
+ msg.error(string.format("Couldn't store file '%s': %s", filename, error))
+ end
+ os.remove(file_path)
+end
+
ankiconnect.create_deck = function(deck_name)
local args = {
action = "changeDeck",