aboutsummaryrefslogtreecommitdiffstats
path: root/mpv/scripts/autosub.lua
diff options
context:
space:
mode:
Diffstat (limited to 'mpv/scripts/autosub.lua')
-rw-r--r--mpv/scripts/autosub.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/mpv/scripts/autosub.lua b/mpv/scripts/autosub.lua
new file mode 100644
index 0000000..a05206f
--- /dev/null
+++ b/mpv/scripts/autosub.lua
@@ -0,0 +1,24 @@
+-- default keybinding: b
+-- add the following to your input.conf to change the default keybinding:
+-- keyname script_binding auto_load_subs
+local utils = require 'mp.utils'
+function load_sub_fn()
+ subl = "/usr/bin/subliminal" -- use 'which subliminal' to find the path
+ mp.msg.info("Searching subtitle")
+ mp.osd_message("Searching subtitle")
+ t = {}
+ t.args = {subl, "download", "-s", "-l", "en", mp.get_property("path")}
+ res = utils.subprocess(t)
+ if res.status == 0 then
+ sub_path = string.gsub(mp.get_property("path"), "%.%w+$", ".srt")
+ mp.osd_message(sub_path)
+ mp.commandv("sub_add", sub_path)
+ mp.msg.info("Subtitle download succeeded")
+ mp.osd_message("Subtitle download succeeded")
+ else
+ mp.msg.warn("Subtitle download failed")
+ mp.osd_message("Subtitle download failed")
+ end
+end
+
+mp.add_key_binding("b", "auto_load_subs", load_sub_fn)