Skip to content

Commit

Permalink
add ankiconnect url to config (#106)
Browse files Browse the repository at this point in the history
* add ankiconnect url to config

* update config readme

---------

Co-authored-by: Ren Tatsumoto <tatsu@autistici.org>
  • Loading branch information
MicrochipQ and tatsumoto-ren authored Aug 21, 2023
1 parent ac29983 commit 178674f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .github/RELEASE/subs2srs.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion ankiconnect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions platform/nix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions platform/win.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions subs2srs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ local config = {
image_template = '<img alt="snapshot" src="%s">',
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.
Expand Down

0 comments on commit 178674f

Please sign in to comment.