You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- 获取history.log文件路径
local historyFile = mp.command_native({"expand-path", "~~/history.log"})
-- 读取文件内容
local file = io.open(historyFile, "r")
local playlist = {}
if file then
for line in file:lines() do
-- 使用正则表达式提取文件路径
local path = string.match(line, '"([^"]+%.%w+)"') -- 匹配以引号包含的文件名
if path then
local localPath = string.match(line, '|%s*(.+)$') -- 匹配竖线后面的位置信息
if localPath then
local fullPath = mp.command_native({"expand-path", localPath})
table.insert(playlist, fullPath)
end
end
end
file:close()
-- 播放最近播放的视频文件
if #playlist > 0 then
local recentVideo = playlist[#playlist]
mp.commandv("loadfile", recentVideo)
end
end
放在了script文件夹里,可以自动播放最近视频,但是我想用快捷键激活这时候它就像智障一样重复几个建议,然而都不行,是哪里出现了问题啊?
还需要编辑script-opt文件吗
input.conf w script-binding recents-playlist/start
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
想设置一个快捷键直接播放最近文件(划掉,实际上是知道gpt可以写代码之后想玩一下,当然也有这个需求),知道有recent.脚本,但是需要按一个快捷键才能显示这个
还需要按enter,怎么写能直接一个快捷键操作,然后在chatgpt的努力下,这个完成了
-- recents-playlist.lua
-- 获取history.log文件路径
local historyFile = mp.command_native({"expand-path", "~~/history.log"})
-- 读取文件内容
local file = io.open(historyFile, "r")
local playlist = {}
if file then
for line in file:lines() do
-- 使用正则表达式提取文件路径
local path = string.match(line, '"([^"]+%.%w+)"') -- 匹配以引号包含的文件名
if path then
local localPath = string.match(line, '|%s*(.+)$') -- 匹配竖线后面的位置信息
if localPath then
local fullPath = mp.command_native({"expand-path", localPath})
table.insert(playlist, fullPath)
end
end
end
file:close()
end
放在了script文件夹里,可以自动播放最近视频,但是我想用快捷键激活这时候它就像智障一样重复几个建议,然而都不行,是哪里出现了问题啊?
还需要编辑script-opt文件吗
input.conf w script-binding recents-playlist/start
Beta Was this translation helpful? Give feedback.
All reactions