diff --git a/.github/RELEASE/subs2srs.conf b/.github/RELEASE/subs2srs.conf index db40892..d2bb938 100644 --- a/.github/RELEASE/subs2srs.conf +++ b/.github/RELEASE/subs2srs.conf @@ -38,6 +38,13 @@ note_tag=subs2srs menu_font_size=24 menu_font_name=Noto Serif CJK JP +# AnkiConnect server address +# The default address for a server on the same device is http://127.0.0.1:8765. +# If Anki is running and AnkiConnect is installed, opening this URL should +# open a page showing the current version of AnkiConnect. +# Change this if you have changed webBindAddress in AnkiConnect's settings. +ankiconnect_url=127.0.0.1:8765 + ## ## Toggleables. ## Possible values: `yes` or `no`. diff --git a/ankiconnect.lua b/ankiconnect.lua index 425a84f..5be515d 100644 --- a/ankiconnect.lua +++ b/ankiconnect.lua @@ -18,7 +18,7 @@ self.execute = function(request, completion_fn) if error ~= nil or request_json == "null" then return completion_fn and completion_fn() else - return self.platform.curl_request(request_json, completion_fn) + return self.platform.curl_request(self.config.ankiconnect_url, request_json, completion_fn) end end diff --git a/platform/nix.lua b/platform/nix.lua index b0b3be6..8fc9edc 100644 --- a/platform/nix.lua +++ b/platform/nix.lua @@ -27,8 +27,8 @@ self.copy_to_clipboard = function(text) handle:close() end -self.curl_request = function(request_json, completion_fn) - local args = { 'curl', '-s', '127.0.0.1:8765', '-X', 'POST', '-d', request_json } +self.curl_request = function(url, request_json, completion_fn) + local args = { 'curl', '-s', url, '-X', 'POST', '-d', request_json } return h.subprocess(args, completion_fn) end diff --git a/platform/win.lua b/platform/win.lua index ed8f246..a5c1e08 100644 --- a/platform/win.lua +++ b/platform/win.lua @@ -28,14 +28,14 @@ self.copy_to_clipboard = function(text) mp.commandv("run", "cmd.exe", "/d", "/c", string.format("@echo off & chcp 65001 >nul & echo %s|clip", text)) end -self.curl_request = function(request_json, completion_fn) +self.curl_request = function(url, request_json, completion_fn) local handle = io.open(curl_tmpfile_path, "w") handle:write(request_json) handle:close() local args = { 'curl', '-s', - '127.0.0.1:8765', + url, '-H', 'Content-Type: application/json; charset=UTF-8', '-X', diff --git a/subs2srs.lua b/subs2srs.lua index fe784b6..2249bee 100644 --- a/subs2srs.lua +++ b/subs2srs.lua @@ -94,6 +94,7 @@ local config = { image_template = 'snapshot', append_media = true, -- True to append video media after existing data, false to insert media before disable_gui_browse = false, -- Lets you disable anki browser manipulation by mpvacious. + ankiconnect_url = '127.0.0.1:8765', -- Note tagging -- The tag(s) added to new notes. Spaces separate multiple tags.