Skip to content

Commit

Permalink
脚本: 移除滤镜式次字幕的实现
Browse files Browse the repository at this point in the history
https://mpv.io/manual/master/#options-secondary-sub-ass-override
现在应使用上述的原生方法作为替代
  • Loading branch information
hooke007 committed Dec 18, 2023
1 parent b6677b5 commit 8cdbf55
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 62 deletions.
3 changes: 0 additions & 3 deletions portable_config/input_scripts.conf
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
W script-binding load_plus/import_url # 使用PowerShell加载网址
Ctrl+w script-binding load_plus/append_aid # 使用资源管理器加载其它音轨
Alt+w script-binding load_plus/append_sid # 使用资源管理器加载其它字幕
e script-binding load_plus/append_vfSub # 使用资源管理器加载/变更次字幕(滤镜型)
E script-binding load_plus/toggle_vfSub # 隐藏/显示 当前的次字幕(滤镜型)
Ctrl+e script-binding load_plus/remove_vfSub # 移除次字幕(滤镜型)

Shift+DEL script-binding osc_plus/visibility # 切换osc_plus的可见性
Shift+Alt+DEL script-message-to osc_plus osc_layout slimbox # <bottombar|topbar|bottombox|box|slimbox> 切换 osc_plus 的布局为 slimbox
Expand Down
3 changes: 0 additions & 3 deletions portable_config/scripts/contextmenu_gui/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,6 @@ local function playmenuList()
{COMMAND, "【外置脚本】地址", "", "script-binding load_plus/import_url", "", false},
{COMMAND, "【外置脚本】追加音轨", "", "script-binding load_plus/append_aid", "", false},
{COMMAND, "【外置脚本】追加字幕轨", "", "script-binding load_plus/append_sid", "", false},
{COMMAND, "【外置脚本】指定次字幕(滤镜)", "", "script-binding load_plus/append_vfSub", "", false},
{COMMAND, "【外置脚本】显示/隐藏次字幕(滤镜)", "", "script-binding load_plus/toggle_vfSub", "", false},
{COMMAND, "【外置脚本】移除次字幕(滤镜)", "", "script-binding load_plus/remove_vfSub", "", false},
{SEP},
{COMMAND, "播放列表乱序重排", "", "playlist-shuffle", "", false},
{CHECK, "列表循环", "", "cycle-values loop-playlist inf no", function() return statePlayLoop() end, false, true},
Expand Down
56 changes: 0 additions & 56 deletions portable_config/scripts/load_plus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ COMMIT_ 04fe818fc703d8c5dcc3a6aabe1caeed8286bdbb
<KEY> script-binding load_plus/append_aid # 追加其它音轨(不切换)
<KEY> script-binding load_plus/append_sid # 追加其它字幕(切换)
<KEY> script-binding load_plus/append_vfSub # 装载次字幕(滤镜型)
<KEY> script-binding load_plus/toggle_vfSub # 隐藏/显示 当前的次字幕(滤镜型)
<KEY> script-binding load_plus/remove_vfSub # 移除次字幕(滤镜型)
]]

local msg = require "mp.msg"
Expand Down Expand Up @@ -530,56 +527,6 @@ function append_sid()
end
end

function append_vfSub()
local was_ontop = mp.get_property_native("ontop")
if was_ontop then mp.set_property_native("ontop", false) end
local res = utils.subprocess({
args = {'powershell', '-NoProfile', '-Command', [[& {
Trap {
Write-Error -ErrorRecord $_
Exit 1
}
Add-Type -AssemblyName PresentationFramework
$u8 = [System.Text.Encoding]::UTF8
$out = [Console]::OpenStandardOutput()
$ofd = New-Object -TypeName Microsoft.Win32.OpenFileDialog
$ofd.Multiselect = $false
If ($ofd.ShowDialog() -eq $true) {
ForEach ($filename in $ofd.FileNames) {
$u8filename = $u8.GetBytes("$filename")
$out.Write($u8filename, 0, $u8filename.Length)
}
}
}]]},
cancellable = false,
})
if was_ontop then mp.set_property_native("ontop", true) end
if (res.status ~= 0) then return end
for filename in string.gmatch(res.stdout, '[^\n]+') do
local vfSub = "vf append ``@LUA-load_plus:subtitles=filename=\"" .. res.stdout .. "\"``"
mp.command(vfSub)
end
end

function filter_state(label, key, value)
local filters = mp.get_property_native("vf")
for _, filter in pairs(filters) do
if filter["label"] == label and (not key or key and filter[key] == value) then
return true
end
end
return false
end

function toggle_vfSub()
local vfSub = "vf toggle @LUA-load_plus"
if filter_state("LUA-load_plus") then mp.command(vfSub) end
end

function remove_vfSub()
local vfSub = "vf remove @LUA-load_plus"
if filter_state("LUA-load_plus") then mp.command(vfSub) end
end


mp.register_event("end-file", remove_vfSub)
Expand All @@ -590,6 +537,3 @@ mp.add_key_binding(nil, "import_files", import_files)
mp.add_key_binding(nil, "import_url", import_url)
mp.add_key_binding(nil, "append_aid", append_aid)
mp.add_key_binding(nil, "append_sid", append_sid)
mp.add_key_binding(nil, "append_vfSub", append_vfSub)
mp.add_key_binding(nil, "toggle_vfSub", toggle_vfSub)
mp.add_key_binding(nil, "remove_vfSub", remove_vfSub)

0 comments on commit 8cdbf55

Please sign in to comment.