mirror of
https://github.com/mpv-player/mpv
synced 2025-01-27 18:13:15 +00:00
skip-logo.lua: fix some lint warnings
This commit is contained in:
parent
885cc30596
commit
0f7aab534a
@ -22,14 +22,14 @@ Example script-opts/skip-logo.conf:
|
|||||||
name = "black frame", -- print if matched
|
name = "black frame", -- print if matched
|
||||||
skip = 10, -- number of seconds to skip forward
|
skip = 10, -- number of seconds to skip forward
|
||||||
score = 0.3, -- required score
|
score = 0.3, -- required score
|
||||||
fingerprint = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
fingerprint = string.rep("0", 512),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
-- Skip ahead 20 seconds if a white frame was detected
|
-- Skip ahead 20 seconds if a white frame was detected
|
||||||
-- Note: this is dangerous non-sense. It's just for demonstration.
|
-- Note: this is dangerous non-sense. It's just for demonstration.
|
||||||
name = "fun2",
|
name = "fun2",
|
||||||
skip = 20,
|
skip = 20,
|
||||||
fingerprint = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
fingerprint = string.rep("f", 512),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,6 @@ frames of a video. This could be fixed, but the author was too lazy to do so.
|
|||||||
|
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
local utils = require "mp.utils"
|
|
||||||
local msg = require "mp.msg"
|
local msg = require "mp.msg"
|
||||||
|
|
||||||
local label = "skip-logo"
|
local label = "skip-logo"
|
||||||
@ -121,8 +120,10 @@ end
|
|||||||
local function load_config()
|
local function load_config()
|
||||||
local conf_file = mp.find_config_file("script-opts/skip-logo.conf")
|
local conf_file = mp.find_config_file("script-opts/skip-logo.conf")
|
||||||
local conf_fn
|
local conf_fn
|
||||||
local err = nil
|
local err
|
||||||
if conf_file then
|
if conf_file then
|
||||||
|
-- luacheck: push
|
||||||
|
-- luacheck: ignore setfenv
|
||||||
if setfenv then
|
if setfenv then
|
||||||
conf_fn, err = loadfile(conf_file)
|
conf_fn, err = loadfile(conf_file)
|
||||||
if conf_fn then
|
if conf_fn then
|
||||||
@ -131,12 +132,13 @@ local function load_config()
|
|||||||
else
|
else
|
||||||
conf_fn, err = loadfile(conf_file, "t", config)
|
conf_fn, err = loadfile(conf_file, "t", config)
|
||||||
end
|
end
|
||||||
|
-- luacheck: pop
|
||||||
else
|
else
|
||||||
err = "config file not found"
|
err = "config file not found"
|
||||||
end
|
end
|
||||||
|
|
||||||
if conf_fn and (not err) then
|
if conf_fn and (not err) then
|
||||||
local ok, err2 = pcall(conf_fn)
|
local _, err2 = pcall(conf_fn)
|
||||||
err = err2
|
err = err2
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -146,7 +148,7 @@ local function load_config()
|
|||||||
|
|
||||||
if config.cases then
|
if config.cases then
|
||||||
for n, case in ipairs(config.cases) do
|
for n, case in ipairs(config.cases) do
|
||||||
local err = nil
|
err = nil
|
||||||
case.bitmap = hex_to_norm8(case.fingerprint)
|
case.bitmap = hex_to_norm8(case.fingerprint)
|
||||||
if case.bitmap == nil then
|
if case.bitmap == nil then
|
||||||
err = "invalid or missing fingerprint field"
|
err = "invalid or missing fingerprint field"
|
||||||
@ -241,7 +243,7 @@ mp.observe_property(meta_property, "native", function()
|
|||||||
read_frames()
|
read_frames()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
mp.observe_property("seeking", "bool", function(name, val)
|
mp.observe_property("seeking", "bool", function(_, val)
|
||||||
seeking = val
|
seeking = val
|
||||||
if seeking == false then
|
if seeking == false then
|
||||||
playback_start_pts = mp.get_property_number("playback-time")
|
playback_start_pts = mp.get_property_number("playback-time")
|
||||||
@ -259,7 +261,7 @@ for _, f in ipairs(filters) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if found then
|
if found then
|
||||||
mp.command(("no-osd vf add @%s:fingerprint"):format(label, filter))
|
mp.command(("no-osd vf add @%s:fingerprint"):format(label))
|
||||||
else
|
else
|
||||||
msg.warn("vf_fingerprint not found")
|
msg.warn("vf_fingerprint not found")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user