mirror of
https://github.com/mpv-player/mpv
synced 2025-02-17 04:58:06 +00:00
TOOLS/lua: use double quotes unless there's a good reason
This commit is contained in:
parent
c91373a202
commit
20b5fecdf1
@ -40,11 +40,11 @@ end
|
||||
function del_filter_if_present(label)
|
||||
-- necessary because mp.command('vf del @label:filter') raises an
|
||||
-- error if the filter doesn't exist
|
||||
local vfs = mp.get_property_native('vf')
|
||||
local vfs = mp.get_property_native("vf")
|
||||
for i,vf in pairs(vfs) do
|
||||
if vf['label'] == label then
|
||||
if vf["label"] == label then
|
||||
table.remove(vfs, i)
|
||||
mp.set_property_native('vf', vfs)
|
||||
mp.set_property_native("vf", vfs)
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -77,21 +77,21 @@ end
|
||||
function do_crop()
|
||||
-- get the metadata
|
||||
local cropdetect_metadata = mp.get_property_native(
|
||||
string.format('vf-metadata/%s', cropdetect_label)
|
||||
string.format("vf-metadata/%s", cropdetect_label)
|
||||
)
|
||||
-- use it to crop if its valid
|
||||
if cropdetect_metadata then
|
||||
if cropdetect_metadata['lavfi.cropdetect.w']
|
||||
and cropdetect_metadata['lavfi.cropdetect.h']
|
||||
and cropdetect_metadata['lavfi.cropdetect.x']
|
||||
and cropdetect_metadata['lavfi.cropdetect.y']
|
||||
if cropdetect_metadata["lavfi.cropdetect.w"]
|
||||
and cropdetect_metadata["lavfi.cropdetect.h"]
|
||||
and cropdetect_metadata["lavfi.cropdetect.x"]
|
||||
and cropdetect_metadata["lavfi.cropdetect.y"]
|
||||
then
|
||||
mp.command(string.format('vf add @%s:crop=%s:%s:%s:%s',
|
||||
mp.command(string.format("vf add @%s:crop=%s:%s:%s:%s",
|
||||
crop_label,
|
||||
cropdetect_metadata['lavfi.cropdetect.w'],
|
||||
cropdetect_metadata['lavfi.cropdetect.h'],
|
||||
cropdetect_metadata['lavfi.cropdetect.x'],
|
||||
cropdetect_metadata['lavfi.cropdetect.y']))
|
||||
cropdetect_metadata["lavfi.cropdetect.w"],
|
||||
cropdetect_metadata["lavfi.cropdetect.h"],
|
||||
cropdetect_metadata["lavfi.cropdetect.x"],
|
||||
cropdetect_metadata["lavfi.cropdetect.y"]))
|
||||
else
|
||||
mp.msg.error(
|
||||
"Got empty crop data. You might need to increase detect_seconds."
|
||||
|
@ -21,17 +21,17 @@ script_name=mp.get_script_name()
|
||||
|
||||
function print_state(params)
|
||||
if params then
|
||||
mp.osd_message(script_name..':\n'
|
||||
.."method = "..params['method'].."\n"
|
||||
.."target = "..params['target'])
|
||||
mp.osd_message(script_name..":\n"
|
||||
.."method = "..params["method"].."\n"
|
||||
.."target = "..params["target"])
|
||||
else
|
||||
mp.osd_message(script_name..':\noff')
|
||||
mp.osd_message(script_name..":\noff")
|
||||
end
|
||||
end
|
||||
|
||||
function get_index_of_drc(afs)
|
||||
for i,af in pairs(afs) do
|
||||
if af['label']==script_name then
|
||||
if af["label"]==script_name then
|
||||
return i
|
||||
end
|
||||
end
|
||||
@ -46,30 +46,30 @@ function append_drc(afs)
|
||||
target="0.25"
|
||||
}
|
||||
}
|
||||
print_state(afs[#afs]['params'])
|
||||
print_state(afs[#afs]["params"])
|
||||
end
|
||||
|
||||
function modify_or_create_af(fun)
|
||||
afs=mp.get_property_native('af')
|
||||
afs=mp.get_property_native("af")
|
||||
i=get_index_of_drc(afs)
|
||||
if not i then
|
||||
append_drc(afs)
|
||||
else
|
||||
fun(afs,i)
|
||||
end
|
||||
mp.set_property_native('af',afs)
|
||||
mp.set_property_native("af",afs)
|
||||
end
|
||||
|
||||
function drc_toggle_method_handler()
|
||||
modify_or_create_af(
|
||||
function (afs,i)
|
||||
new_method=(afs[i]['params']['method']+1)%3
|
||||
new_method=(afs[i]["params"]["method"]+1)%3
|
||||
if new_method==0 then
|
||||
table.remove(afs,i)
|
||||
print_state(nil)
|
||||
else
|
||||
afs[i]['params']['method']=tostring((afs[i]['params']['method'])%2+1)
|
||||
print_state(afs[i]['params'])
|
||||
afs[i]["params"]["method"]=tostring((afs[i]["params"]["method"])%2+1)
|
||||
print_state(afs[i]["params"])
|
||||
end
|
||||
end
|
||||
)
|
||||
@ -78,8 +78,8 @@ end
|
||||
function drc_scale_target(factor)
|
||||
modify_or_create_af(
|
||||
function (afs)
|
||||
afs[i]['params']['target']=tostring(afs[i]['params']['target']*factor)
|
||||
print_state(afs[i]['params'])
|
||||
afs[i]["params"]["target"]=tostring(afs[i]["params"]["target"]*factor)
|
||||
print_state(afs[i]["params"])
|
||||
end
|
||||
)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user