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

fix: integration with dandanplay API changes #114 #115

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
49 changes: 29 additions & 20 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ function set_episode_id(input, from_menu)
end
end

-- 使用 curl 发送 HTTP POST 请求获取弹幕 episodeId
local function match_file(file_name, file_hash)
local url = options.api_server .. "/api/v2/match"
local body = utils.format_json({
Expand All @@ -430,17 +429,28 @@ local function match_file(file_name, file_hash)
matchMode = "hashAndFileName"
})

local dandanplay_path = utils.join_path(mp.get_script_directory(), "bin")
if platform == "windows" then
dandanplay_path = utils.join_path(dandanplay_path, "dandanplay/dandanplay.exe")
else
dandanplay_path = utils.join_path(dandanplay_path, "dandanplay/dandanplay")
end

local arg = {
"curl", "-s", "-X", "POST", url,
"-H", "Content-Type: application/json",
"-d", body
dandanplay_path,
url,
"--query-type",
"POST",
"--accept",
"application/json",
"--content-type",
"application/json",
"--user-agent",
options.user_agent,
"--body",
body
}

if options.proxy ~= "" then
table.insert(arg, '-x')
table.insert(arg, options.proxy)
end

local result = mp.command_native({ name = 'subprocess', capture_stdout = true, args = arg })
if result.status == 0 then
return result.stdout
Expand Down Expand Up @@ -502,25 +512,24 @@ function get_video_data(url)
return mp.command_native(cmd)
end

-- Use curl command to get the JSON data
function get_danmaku_contents(url)
local dandanplay_path = utils.join_path(mp.get_script_directory(), "bin")
if platform == "windows" then
dandanplay_path = utils.join_path(dandanplay_path, "dandanplay/dandanplay.exe")
else
dandanplay_path = utils.join_path(dandanplay_path, "dandanplay/dandanplay")
end
local arg = {
"curl",
"-L",
"-X",
dandanplay_path,
"--query-type",
"GET",
"--header",
"Accept: application/json",
"--accept",
"application/json",
"--user-agent",
options.user_agent,
url,
}

if options.proxy ~= "" then
table.insert(arg, '-x')
table.insert(arg, options.proxy)
end

local cmd = {
name = 'subprocess',
capture_stdout = true,
Expand Down
Binary file added bin/dandanplay/dandanplay
Binary file not shown.
Binary file added bin/dandanplay/dandanplay.exe
Binary file not shown.