diff options
| author | Tyler Hoang <tyler@tylerhoang.xyz> | 2022-02-06 22:32:14 -0800 |
|---|---|---|
| committer | Tyler Hoang <tyler@tylerhoang.xyz> | 2022-02-06 22:32:14 -0800 |
| commit | 0a334f0c0dc98f3eb654f9291f9b3e7b0c548c29 (patch) | |
| tree | 0021c69a18461fe732aa9ff465a9632fa7c72e46 /mpv/scripts/autosubsync.lua | |
| parent | e48219b726e26e2e54bfec062832454b29b305ff (diff) | |
updated mpv
Diffstat (limited to 'mpv/scripts/autosubsync.lua')
| -rw-r--r-- | mpv/scripts/autosubsync.lua | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/mpv/scripts/autosubsync.lua b/mpv/scripts/autosubsync.lua deleted file mode 100644 index fb3a6c3..0000000 --- a/mpv/scripts/autosubsync.lua +++ /dev/null @@ -1,44 +0,0 @@ --- default keybinding: n --- add the following to your input.conf to change the default keybinding: --- keyname script_binding auto_sync_subs -local utils = require 'mp.utils' - -function display_error() - mp.msg.warn("Subtitle synchronization failed: ") - mp.osd_message("Subtitle synchronization failed") -end - --- Courtesy of https://stackoverflow.com/questions/4990990/check-if-a-file-exists-with-lua -function file_exists(filepath) - local f=io.open(filepath,"r") - if f~=nil then io.close(f) return true else return false end -end - -function sync_sub_fn() - path = mp.get_property("path") - srt_path = string.gsub(path, "%.%w+$", ".srt") - if file_exists(srt_path)==false then - mp.msg.warn("Couldn't find",srt_path) - display_error() - do return end - end - subsync = "/home/user/.local/bin/ffsubsync" -- use 'which ffsubsync' to find the path - t = {} - t.args = {subsync, path, "-i",srt_path,"-o",srt_path} - - mp.osd_message("Sync subtitle...") - mp.msg.info("Starting ffsubsync...") - res = utils.subprocess(t) - if res.error == nil then - if mp.commandv("sub_add", srt_path) then - mp.msg.info("Subtitle updated") - mp.osd_message("Subtitle at'" .. srt_path .. "' synchronized") - else - display_error() - end - else - display_error() - end -end - -mp.add_key_binding("n", "auto_sync_subs", sync_sub_fn) |
