From 0a334f0c0dc98f3eb654f9291f9b3e7b0c548c29 Mon Sep 17 00:00:00 2001 From: Tyler Hoang Date: Sun, 6 Feb 2022 22:32:14 -0800 Subject: updated mpv --- mpv/scripts/autosubsync.lua | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 mpv/scripts/autosubsync.lua (limited to 'mpv/scripts/autosubsync.lua') 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) -- cgit v1.2.3-13-gbd6f