Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ankiconnect url to config #106

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/RELEASE/subs2srs.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
## General settings
##

ankiconnect_url=127.0.0.1:8765
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs an explanation.


# Anki deck for new cards. Subdecks are supported.
deck_name=Bank::subs2srs

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